示例#1
0
 public ActionResult MakePolygraphyOrder(PolygraphyViewModel order)
 {
     try
     {
         var orderDto = new PolygraphyDTO {
             AdvertisingID = order.AdvertisingID, PhoneNumber = order.PhoneNumber, Amount = order.Amount
         };
         orderService.MakePolygrahyOrder(orderDto);
         return(RedirectToAction("Index", "Home"));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError(ex.Property, ex.Message);
     }
     return(View(order));
 }
示例#2
0
        public void MakePolygrahyOrder(PolygraphyDTO polygraphyDto)
        {
            Advertising ad = Database.Ads.Get(polygraphyDto.AdvertisingID);

            if (ad == null)
            {
                throw new ValidationException("No ads found", "");
            }

            decimal sum   = new Polygraphy(polygraphyDto.Amount).GetSummarizedPrice(ad.Price);
            Order   order = new Order
            {
                Date          = DateTime.Now,
                Amount        = polygraphyDto.Amount,
                AdvertisingID = ad.ID,
                Sum           = sum,
                PhoneNumber   = polygraphyDto.PhoneNumber
            };

            Database.Orders.Create(order);
            Database.Save();
        }