public IActionResult Checkout(CheckoutViewModel model) { if (ModelState.IsValid) { var command = new CheckOutCommand { Address = model.Address, Cart = _cart, City = model.City, FirstName = model.FirstName, LastName = model.LastName, NationalCode = model.NationalCode, Phone = model.Phone, Provience = model.Provience }; var result = _commandDispatcher.Dispatch(command); if (result.IsSuccess) { _cart.Clear(); return(RedirectToAction(nameof(Completed), new { Id = command.OrderId })); } foreach (string item in result.Errors) { ModelState.AddModelError("", item); } } return(View(model)); }
public void Execute_ShouldReturn_InvalidArguments_WhenNoBranchNameIsPresent() { var options = new CheckOutSubOptions(); var instance = new CheckOutCommand(options); var code = instance.Execute(); Assert.AreEqual(ReturnCode.InvalidArguments, code, "Invalid Return Code"); }
public async Task <ActionResult <RegBookResponseObj> > CheckOutBook([FromBody] AddCheckOutActivityRequestObj requestObj) { CheckOutCommand command = _mapper.Map <CheckOutCommand>(requestObj); var response = await _mediator.Send(command); if (response.CheckOutActivityId < 1 || !response.Status.IsSuccessful) { return(BadRequest(response)); } var locatioUri = _uriService.GetBookUri(response.CheckOutActivityId.ToString()); return(Created(locatioUri, response)); }
public void Execute_ShouldReturn_Error_WhenTraverseDependencies_Fails() { const string BRANCH_NAME = "feature/testing_2"; var algorithm = Container.Resolve <IDependencyVisitorAlgorithm>(); algorithm.Arrange(a => a.TraverseDependencies(Arg.IsAny <IVisitor>(), Arg.AnyString)) .DoInstead((IVisitor visitor, string directory) => { visitor.ReturnCode = ReturnCode.FailedToRunGitCommand; }) .MustBeCalled(); var options = new CheckOutSubOptions { BranchName = BRANCH_NAME }; var instance = new CheckOutCommand(options); var code = instance.Execute(); algorithm.Assert(); Assert.AreEqual(ReturnCode.FailedToRunGitCommand, code, "Invalid Return Code"); }
public async Task <IActionResult> CheckOut([FromBody] CheckOutCommand command) { await mediator.Send(command); return((IActionResult)Ok()); }
public async Task Checkout(CheckOutCommand command) { await mediator.Send(command); }