Example #1
0
        public ActionResult AddConfirmation(AddSaleConfirmationVm vm)
        {
            var cookie = this.Request.Cookies.Get("sessionId");

            if (cookie == null || !AuthenticationManager.IsAuthenticated(cookie.Value))
            {
                return(this.RedirectToAction("Login", "User"));
            }
            return(View(vm));
        }
Example #2
0
        public ActionResult Add([Bind(Include = "CustomerId, CarId, Discount")] AddSaleBm bind)
        {
            if (ModelState.IsValid)
            {
                AddSaleConfirmationVm confirmation = this.service.GetSaleConfirmattionVm(bind);
                return(RedirectToAction("AddConfirmation", confirmation));
            }
            AddSaleVm addSaleVm = this.service.GetSaleVm();

            return(this.View(addSaleVm));
        }
Example #3
0
        public AddSaleConfirmationVm GetSaleCofirmationVm(AddSaleBm bind)
        {
            Car      carModel        = this.Context.Cars.Find(bind.CarId);
            Customer customerModel   = this.Context.Customers.Find(bind.CustomerId);
            AddSaleConfirmationVm vm = new AddSaleConfirmationVm()
            {
                Discount          = bind.Discount,
                CarPrice          = (decimal)carModel.Parts.Sum(part => part.Price).Value,
                CarId             = carModel.Id,
                CarRepresentation = $"{carModel.Make} {carModel.Model}",
                CustomerId        = customerModel.Id,
                CustomerName      = customerModel.Name
            };

            vm.Discount     += customerModel.IsYoungDriver ? 5 : 0;
            vm.FinalCarPrice = vm.CarPrice - vm.CarPrice * vm.Discount / 100;
            return(vm);
        }
Example #4
0
        public AddSaleConfirmationVm GetSaleConfirmattionVm(AddSaleBm bind)
        {
            Car      car      = this.Context.Cars.Find(bind.CarId);
            Customer customer = this.Context.Customers.Find(bind.CustomerId);

            AddSaleConfirmationVm vm = new AddSaleConfirmationVm()
            {
                Discount          = bind.Discount,
                CarId             = car.Id,
                CarPrice          = (double)car.Parts.Sum(a => a.Price),
                CustomerId        = customer.Id,
                CustomerName      = customer.Name,
                CarRepresentation = car.Make + " " + car.Model,
            };

            vm.Discount     += customer.IsYoungDriver ? 5 : 0;
            vm.FinalCarPrice = vm.CarPrice + vm.Discount / 100.0;
            return(vm);
        }