public ContactEditorViewModel(ICommandInvoker commandInvoker, IQueryInvoker queryInvoker) { this.queryInvoker = queryInvoker; Contacts = queryInvoker.Query<AllContactsQueryResult>().Contacts; SaveCommand = new DelegateCommand(() => { if (CurrentContact.Command is UpdateContactCommand) { commandInvoker.Execute<UpdateContactCommand, UpdateContactQueryResult>((UpdateContactCommand) CurrentContact.Command); } else { commandInvoker.Execute<CreateContactCommand, CreateContactQueryResult>(CurrentContact.Command); } Contacts = queryInvoker.Query<AllContactsQueryResult>().Contacts; }); NewCommand = new DelegateCommand(() => { var modifyContactQueryResult = queryInvoker.Query<CreateContactQueryResult>(); CurrentContact = new CreateContactViewModel(modifyContactQueryResult, new ValidationService()); }); NewCommand.Execute(null); }
public async Task PostAsync([FromBody] CreateOrderModel model) { var command = _mapper.Map <CreateOrder>(model); command.InitiatorId = Guid.NewGuid(); await _commandInvoker.Execute(command); }
public async Task PostAsync([FromBody] UserModel model) { var command = _mapper.Map <CreateUser>(model); //ToDo:3 command.InitiatorId = User.Identity.Id; command.InitiatorId = Guid.NewGuid(); await _commandInvoker.Execute(command); }
public ActionResult End() { var wk = _workoutService.CurrentWorkout().WorkoutId; _commandInvoker.Execute(new EndWorkoutCommand()); return(RedirectToAction("Summary", new { id = wk })); }
public void the_submission_is_saved_to_the_database() { A.CallTo(() => _fakeCommandInvoker .Execute <CreateLrap1SubmissionCommand, CreateLrap1SubmissionQueryResult>(A <CreateLrap1SubmissionCommand> .That.Matches(c => c.Username == _username && c.Payload == _package.Payload))) .MustHaveHappened(Repeated.Exactly.Once); }
public async Task PostArticleAsync([FromBody] RegisterArticleModel model) { var command = _mapper.Map <RegisterArticle>(model); //ToDo:3 command.InitiatorId = User.Identity.Id; command.InitiatorId = Guid.NewGuid(); await _commandInvoker.Execute(command); }
public IActionResult Index(int userId, string userName, string password, string confirmPassword) { if (string.IsNullOrWhiteSpace(password) || password != confirmPassword) { var info = _getUserInfoCommandInvorker.Execute(new GetUserCommand()); ViewBag.Message = "您的密码输入不正确"; return(View(info)); } MD5 md5 = MD5.Create(); var passwordBytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(password)); var passwordStr = BitConverter.ToString(passwordBytes).Replace("-", ""); ModifyUserCommand command = new ModifyUserCommand(); command.UserId = userId; command.UserName = userName; command.Password = passwordStr; var modifyInfo = _modifyUserInfoCommandInvorker.Execute(command); if (modifyInfo.State == 1) { ViewBag.Message = "更新用户信息成功"; } else { ViewBag.Message = "更新用户信息失败"; } var result = _getUserInfoCommandInvorker.Execute(new GetUserCommand()); return(View(result)); }
public void Start() { ICanvas <TPixelData> canvas = null; bool error; do { error = false; try { var commandInput = _receiver.ReceiveInput(); canvas = _commandInvoker.Execute(canvas, commandInput); _canvasRenderer.Render(canvas); } catch (ValidationException ex) { error = true; _logger.LogWarning(ex.Message); } catch (Exception ex) { error = true; // log _logger.LogError("There has been an error. Please contact application support :/", ex); } // currently just loops until canvas == null. This is not ideal but the class would probably need redesigning to // accomodate other implementations, anyway. } while (error || canvas != null); }
public async Task <Guid> PostAsync([FromBody] RegisterCustomerModel model) { var command = _mapper.Map <RegisterCustomer>(model); //ToDo:3 command.InitiatorId = User.Identity.Id; command.InitiatorId = Guid.NewGuid(); await _commandInvoker.Execute(command); return(command.Id); }
public IActionResult Update(long postId) { var result = _getPostInfoCommandInvorker.Execute(new GetPostInfoCommand() { PostId = postId }); return(View(result)); }
public ActionResult New(string currentUserId, HttpPostedFileBase file, ImageNewViewModel model) { if (ModelState.IsValid) { if (file != null) { byte[] allData = new byte[file.ContentLength]; file.InputStream.Read(allData, 0, allData.Length); commandInvoker.Execute(new UploadUserImageCommand(currentUserId, model.Title, model.Tags, allData)); return(RedirectToAction("Index", "Home")); } else { this.ModelState.AddModelError("file", "Please select a file for upload"); } } return(View(model)); }
public ActionResult Cardio(AddCardioInputModel input) { if (!ModelState.IsValid) { return(View(input)); } var command = new AddCardioCommand { Duration = input.Duration, ExerciseId = input.ExerciseId, Level = input.Level, Notes = input.Notes }; _commandInvoker.Execute(command); return(RedirectToAction("Index", "Workout")); }
// GET: /<controller>/ public IActionResult Index() { var result = _postManagerIndexCommandInvorker.Execute(new PostIndexCommand()); if (result == null) { result = new List <PostManagerListViewModel>(); } return(View(result)); }
public void Execute() { if (this.MarsRoverMissionState != MarsRoverMissionState.CommandsInitialized) { throw new MarsDomainModelException("Commands cannot be executed before they are initialized."); } commandInvoker.Execute(commandsOfRowers); this.MarsRoverMissionState = MarsRoverMissionState.Completed; }
public SubmitLrap1Result Submit(string username, string password, Lrap1Package lrap1Package) { var applicationId = Guid.NewGuid().ToString(); var saveResult = _commandInvoker.Execute <CreateLrap1SubmissionCommand, CreateLrap1SubmissionQueryResult>(new CreateLrap1SubmissionCommand() { ApplicationId = applicationId, Username = username, Payload = lrap1Package.Payload }); var saveAttachmentResult = _commandInvoker.Execute <CreateLrap1AttachmentCommand, CreateLrap1AttachmentQueryResult>(new CreateLrap1AttachmentCommand() { AttachmentId = Guid.NewGuid().ToString(), ApplicationId = saveResult.Command.ApplicationId, Username = username, Payload = lrap1Package.Attachments[0].Payload }); var sendResult = _messageSender.Send(new SubmitLrap1Command() { ApplicationId = saveResult.Command.ApplicationId, Username = username, Password = password, Payload = lrap1Package.Payload }); foreach (var attachment in lrap1Package.Attachments) { _messageSender.Send(new SubmitLrap1AttachmentCommand() { AttachmentId = saveAttachmentResult.Command.AttachmentId, ApplicationId = saveResult.Command.ApplicationId, Username = username, Password = password, Payload = attachment.Payload }); } return(sendResult); }
public ActionResult Add(AddExerciseInputModel inputModel) { if (ModelState.IsValid) { _invoker.Execute(new AddExerciseCommand(inputModel.Description, inputModel.Type)); TempData["Message"] = "Added new {0} exercise -- {1}".ToFormat(inputModel.Type, inputModel.Description); return(RedirectToAction("Index")); } else { return(View("Index", inputModel)); } }
public ActionResult Register(UserRegisterViewModel model) { if (ModelState.IsValid) { commandInvoker.Execute(new RegisterNewUserCommand(model.Username, model.Password)); authenticationService.SignIn(model.Username, model.StayLoggedIn); return(RedirectToAction("Index", "Home")); } else { return(View(model)); } }
public IActionResult IndexInfo() { IndexInfoViewModel model = new IndexInfoViewModel(); var infos = _indexInfoCommand.Execute(new IndexInfoCommand()); if (infos.State == 0) { model.BlogCount = 0; model.TagCount = 0; } else { model = infos.Value; } return(View(model)); }
// [ValidateInput(false)] public IActionResult Add(string postTitle, string postSlug, string postSubTitle, string headMask, int layoutType, string postMarkDown, string tags, int published, string pubDate, string postHeadImageUrl) { AddPostCommand command = new AddPostCommand(); command.HeadMask = headMask; command.LayoutType = layoutType; command.PostHeadImageUrl = postHeadImageUrl; command.PostMarkDown = postMarkDown; command.PostSlug = postSlug; command.postSubTitle = postSubTitle; command.PostTitle = postTitle; command.Published = published; command.Tags = tags; var result = _addPostCommandInvorker.Execute(command); return(RedirectToAction("Index")); }
public IActionResult Login(string returnUrl, string userName, string password, string verifyCode) { MD5 md5 = MD5.Create(); var passwordBytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(password)); var passwordStr = BitConverter.ToString(passwordBytes).Replace("-", ""); // this._adminUserInitCommand.Execute(new AdminUserInitCommand() { EMail = adminUserConfig.EMail, Password = passwordStr, UserName = adminUserConfig.UserName }); string sessionId = this.HttpContext.Session.Id; var verfiyResult = _verificationCodeTool.VerfiyVerificationCode(verifyCode, sessionId); if (verfiyResult) { var result = _command.Execute(new LoginCommand() { Password = passwordStr, UserName = userName }); if (result.State == 1) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, userName), }; var id = new ClaimsIdentity(claims, "CustomApiKeyAuth"); ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(); claimsPrincipal.AddIdentity(id); HttpContext.Authentication.SignInAsync("MyCookieMiddlewareInstance", claimsPrincipal); if (!string.IsNullOrWhiteSpace(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index")); } } ViewBag.Message = "帐号密码不正确!"; return(View()); }
public async Task PutSupplierAddressAsync(Guid id, [FromBody] ChangeSupplierAddressModel model) { var command = _mapper.Map <ChangeSupplierAddress>(model); command.Id = id; //ToDo:3 command.InitiatorId = User.Identity.Id; command.InitiatorId = Guid.NewGuid(); await _commandInvoker.Execute(command); }
public void BeginNew() { var command = new BeginWorkoutCommand(System.Threading.Thread.CurrentPrincipal.Identity.Name); _commandInvoker.Execute(command); }
// GET: /<controller>/ public IActionResult Index() { var result = _tagListCommandInvorker.Execute(new TagManagerCommand()); return(View(result)); }
public When_the_submissions_service_is_asked_to_send_an_LRAP1_package() { _applicationId = "01234567890"; _username = "******"; _password = "******"; _fakeCommandInvoker = A.Fake<ICommandInvoker>(); var attachments = new List<Lrap1Attachment> { new Lrap1Attachment() {Payload = "Attachment 1 payload data"}, new Lrap1Attachment() {Payload = "Attachment 2 payload data"} }; _package = new Lrap1Package() { Payload = "Lrap1 Payload Data", Attachments = attachments }; A.CallTo( () => _fakeCommandInvoker.Execute<CreateLrap1SubmissionCommand, CreateLrap1SubmissionQueryResult>( A<CreateLrap1SubmissionCommand>.Ignored)).Returns(new CreateLrap1SubmissionQueryResult() { Command = new CreateLrap1SubmissionCommand() { ApplicationId = _applicationId, Username = _username, Payload = _package.Payload } }); A.CallTo( () => _fakeCommandInvoker.Execute<CreateLrap1AttachmentCommand, CreateLrap1AttachmentQueryResult>( A<CreateLrap1AttachmentCommand>.Ignored)).Returns(new CreateLrap1AttachmentQueryResult() { Command = new CreateLrap1AttachmentCommand() { AttachmentId = "98765", ApplicationId = _applicationId, Username = _username, Payload = _package.Payload } }); _fakeMessageSender = A.Fake<ISendMessages>(); A.CallTo(() => _fakeMessageSender.Send(A<SubmitLrap1Command>.That.Matches( c => c.Username == _username && c.Password == _password && c.Payload == _package.Payload))) .Returns(new SubmitLrap1Result() { Command = new SubmitLrap1Command() { ApplicationId = _applicationId, Username = _username, Password = _password, Payload = _package.Payload } }); var sut = new Lrap1SubmissionService(_fakeMessageSender, _fakeCommandInvoker); _response = sut.Submit(_username, _password, _package); }
public IActionResult Index() { var result = _getUserInfoCommandInvorker.Execute(new GetUserCommand()); return(View(result)); }
public When_the_submissions_service_is_asked_to_send_an_LRAP1_package() { _applicationId = "01234567890"; _username = "******"; _password = "******"; _fakeCommandInvoker = A.Fake <ICommandInvoker>(); var attachments = new List <Lrap1Attachment> { new Lrap1Attachment() { Payload = "Attachment 1 payload data" }, new Lrap1Attachment() { Payload = "Attachment 2 payload data" } }; _package = new Lrap1Package() { Payload = "Lrap1 Payload Data", Attachments = attachments }; A.CallTo( () => _fakeCommandInvoker.Execute <CreateLrap1SubmissionCommand, CreateLrap1SubmissionQueryResult>( A <CreateLrap1SubmissionCommand> .Ignored)).Returns(new CreateLrap1SubmissionQueryResult() { Command = new CreateLrap1SubmissionCommand() { ApplicationId = _applicationId, Username = _username, Payload = _package.Payload } }); A.CallTo( () => _fakeCommandInvoker.Execute <CreateLrap1AttachmentCommand, CreateLrap1AttachmentQueryResult>( A <CreateLrap1AttachmentCommand> .Ignored)).Returns(new CreateLrap1AttachmentQueryResult() { Command = new CreateLrap1AttachmentCommand() { AttachmentId = "98765", ApplicationId = _applicationId, Username = _username, Payload = _package.Payload } }); _fakeMessageSender = A.Fake <ISendMessages>(); A.CallTo(() => _fakeMessageSender.Send(A <SubmitLrap1Command> .That.Matches( c => c.Username == _username && c.Password == _password && c.Payload == _package.Payload))) .Returns(new SubmitLrap1Result() { Command = new SubmitLrap1Command() { ApplicationId = _applicationId, Username = _username, Password = _password, Payload = _package.Payload } }); var sut = new Lrap1SubmissionService(_fakeMessageSender, _fakeCommandInvoker); _response = sut.Submit(_username, _password, _package); }