public void GivenAnInvalidCommand_ShouldNotBeValid() { var command = new CreatePromotionCommand("", "", "", ""); command.Validate(); Assert.AreEqual(false, command.Valid); }
public void GivenAnInvalidCommand_ShouldNotCreatePromotion() { var command = new CreatePromotionCommand("", "", "", ""); var result = (GenericCommandResult)_handler.Handle(command); Assert.AreEqual(false, result.Success); }
public void GivenAValidCommandWithInvalidUrl_ShouldNotBeValid() { var url = "NotAnUrl"; var command = new CreatePromotionCommand("Playstation 5 Controller", "Amazon", url, "usertest123"); command.Validate(); Assert.AreEqual(false, command.Valid); }
public void GivenAValidCommand_ShouldBeValid() { var url = "https://www.amazon.com/DualSense-Wireless-Controller-PlayStation-5/dp/B08FC6C75Y/ref=lp_16225016011_1_2?s=videogames-intl-ship&ie=UTF8&qid=1600544279&sr=1-2"; var command = new CreatePromotionCommand("Playstation 5 Controller", "Amazon", url, "usertest123"); command.Validate(); Assert.AreEqual(true, command.Valid); }
public Task <IActionResult> CreatePromotion([FromForm] CreatePromotionRequest request) { var command = new CreatePromotionCommand(request.Name, request.ImageUrl, request.Description, request.DescriptionEng, request.MinimumQuantity, request.MinimumBillAmount, request.IsFixedPriceDiscount, request.DiscountAmount, request.DiscountPercentage, request.MaximumDiscount, request.StartDate, request.EndDate); return(HandleActionResultFor(command)); }
public ActionResult New(CreatePromotionCommand command) { if (!ModelState.IsValid) { return(View()); } command.PromotionId = Guid.NewGuid(); _createPromotionHandler.Handle(command); return(RedirectToAction("Details", new { id = command.PromotionId })); }
public ActionResult New(CreatePromotionCommand command) { if (!ModelState.IsValid) { return View(); } command.PromotionId = Guid.NewGuid(); _createPromotionHandler.Handle(command); return RedirectToAction("Details", new { id = command.PromotionId }); }
public GenericCommandResult Create([FromBody] CreatePromotionCommand command, [FromServices] PromotionHandler handler) { return((GenericCommandResult)handler.Handle(command)); }