示例#1
0
        public ActionResult AddConfirmation(AddSaleConfirmationViewModel salesConfirmVm)
        {
            var cookie = this.Request.Cookies.Get("sessionId");

            if (cookie == null || !AuthenticationManager.IsAuthenticated(cookie.Value))
            {
                return(this.RedirectToAction("Login", "Users"));
            }

            return(this.View(salesConfirmVm));
        }
示例#2
0
        public ActionResult AddSales([Bind(Include = "CustomerId, CarId, Discount")] AddSaleBm addSaleBm)
        {
            if (this.ModelState.IsValid)
            {
                AddSaleConfirmationViewModel salesConfirmVm = this.service.GetConfirmatinModel(addSaleBm);
                return(this.RedirectToAction("AddConfirmation", salesConfirmVm));
            }
            AddSalesViewModel addSalesVm = service.GenerateAddSalesForm();

            return(this.View(addSalesVm));
        }
示例#3
0
        public AddSaleConfirmationViewModel GetConfirmatinModel(AddSaleBm addSaleBm)
        {
            AddSaleConfirmationViewModel confVm = new AddSaleConfirmationViewModel();

            confVm.CarId      = addSaleBm.CarId;
            confVm.CustomerId = addSaleBm.CustomerId;

            Customer customer = this.Context.Customers.Find(confVm.CustomerId);
            Car      car      = this.Context.Cars.Find(confVm.CarId);

            if (customer.IsYoungDriver)
            {
                confVm.TotalDiscount = 5 + addSaleBm.Discount;
            }

            confVm.CustomerName  = customer.Name;
            confVm.TotalDiscount = addSaleBm.Discount;
            confVm.CarName       = car.Make + " " + car.Model;
            confVm.CarPrice      = (decimal)car.Parts.Sum(p => p.Price).Value;
            confVm.FinalCarPrice = confVm.CarPrice - confVm.CarPrice * confVm.TotalDiscount / 100;
            return(confVm);
        }