当前位置: 首页>>代码示例>>C#>>正文


C# IUserRepository.Submit方法代码示例

本文整理汇总了C#中IUserRepository.Submit方法的典型用法代码示例。如果您正苦于以下问题:C# IUserRepository.Submit方法的具体用法?C# IUserRepository.Submit怎么用?C# IUserRepository.Submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUserRepository的用法示例。


在下文中一共展示了IUserRepository.Submit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UserViewModel

 public UserViewModel(IScreen screen, User user, IUserRepository userRepository)
 {
     _userRepository = userRepository;
     HostScreen = screen;
     // Commands
     var canSubmit = this.WhenAny(e => e.Code, code => code.Value.IsValid());
     Submit = ReactiveCommand.CreateAsyncTask(canSubmit, _ => userRepository.Submit(Model));
     Submit.Subscribe(result => MessageBox.Show(result ? "Success" : "Failure"));
     // Observe on UI thread
     Submit.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
         .Select(ex => new UserError("It will fail again, try anyway?", ex.Message))
         .SelectMany(UserError.Throw)
         .Subscribe(resolution =>
         {
             if (resolution == RecoveryOptionResult.RetryOperation)
                 Submit.Execute(null);
         });
     // Model subscription
     this.WhenAnyValue(e => e.Model).Where(e => e != null).Subscribe(model =>
     {
         Code = model.Code;
         Group = model.Group;
     });
     Model = user;
     // Properties subscriptions
     this.WhenAnyValue(e => e.Group).Subscribe(group => Model.Group = group);
     this.WhenAnyValue(e => e.Code).Subscribe(code => Model.Code = code);
     // Subscribe to error handle
     UserError.RegisterHandler(async error =>
     {
         // This shouldn't be a messagebox because is blocking the application, you must provide context and offer a resolution to the user not just showing "error"
         await Task.Delay(1);
         var message = new StringBuilder();
         bool hasRecoveryOptions = error.ErrorCauseOrResolution.IsValid();
         if (hasRecoveryOptions)
             message.AppendLine(error.ErrorCauseOrResolution);
         message.AppendLine(error.ErrorMessage);
         var result = MessageBox.Show(message.ToString(), "Alert!",
             hasRecoveryOptions ? MessageBoxButton.YesNo : MessageBoxButton.OK);
         
         return hasRecoveryOptions && result == MessageBoxResult.Yes ?  RecoveryOptionResult.RetryOperation : RecoveryOptionResult.CancelOperation;
     });
 }
开发者ID:reactiveui-forks,项目名称:FirstsStepsRUI,代码行数:43,代码来源:UserViewModel.cs


注:本文中的IUserRepository.Submit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。