예제 #1
0
        public IActionResult ChangePromotion(PriceOffer dto, [FromServices] IChangePriceOfferService service)
        {
            Request.ThrowErrorIfNotLocal();

            var book = service.UpdateBook(dto);

            SetupTraceInfo();
            return(View("BookUpdated", "Successfully added/changed a promotion"));
        }
        public IActionResult ChangePromotion(int id, [FromServices] IChangePriceOfferService service)
        {
            Request.ThrowErrorIfNotLocal();

            var priceOffer = service.GetOriginal(id);

            ViewData["BookTitle"] = service.OrgBook.Title;
            ViewData["OrgPrice"]  = service.OrgBook.Price < 0
                ? "Not currently for sale"
                : service.OrgBook.Price.ToString("c", new CultureInfo("en-US"));
            SetupTraceInfo();
            return(View(priceOffer));
        }
        public IActionResult ChangePromotion(PriceOffer dto,
                                             [FromServices] IChangePriceOfferService service)
        {
            Request.ThrowErrorIfNotLocal();

            var error = service.AddRemovePriceOffer(dto);

            if (error != null)
            {
                ModelState.AddModelError(error.MemberNames.First(),
                                         error.ErrorMessage);
                return(View(dto));
            }
            SetupTraceInfo();
            return(View("BookUpdated",
                        "Successfully added/changed a promotion"));
        }