Ejemplo n.º 1
0
        public IActionResult Create(SalesFormModel createModel)
        {
            createModel = this.ReloadCollections(createModel);

            if (!ModelState.IsValid)
            {
                return(this.View(createModel));
            }


            SalesReviewViewModel finalizeModel = new SalesReviewViewModel();

            finalizeModel.CustomerId = createModel.CustomerId;
            CustomerModel customer = this.customers.ById(createModel.CustomerId);

            finalizeModel.CustomerName   = customer.Name;
            finalizeModel.DiscountDriver = customer.IsYoungDriver ? 5 : 0;

            finalizeModel.DiscountCar = createModel.Discount;

            finalizeModel.CarId = createModel.CarId;
            CarBasicServiceModel car = this.cars.ByIdBasic(createModel.CarId);

            finalizeModel.CarMakeModel = car.FullModel;
            finalizeModel.Price        = car.Price;

            return(this.View(nameof(Finalize), finalizeModel));
        }
        public IActionResult Review(SaleFormModel saleModel)
        {
            CustomerBasicServiceModel customerModel = this.customerService.GetBasicCustomerById(saleModel.CustomerId);
            CarBasicServiceModel      carModel      = this.carService.GetBasicCarById(saleModel.CarId);

            SaleReviewFormModel model = new SaleReviewFormModel
            {
                CustomerId    = customerModel.Id,
                CustomerName  = customerModel.Name,
                IsYoungDriver = customerModel.IsYoungDriver,
                CarId         = carModel.Id,
                CarMake       = $"{carModel.Make} {carModel.Model}",
                Discount      = saleModel.Discount,
                CarPrice      = this.saleService.GetCarPrice(carModel.Id),
                FinalCarPrice = this.saleService.GetCarPriceWithDiscount(carModel.Id, saleModel.Discount, customerModel.IsYoungDriver)
            };

            return(View(model));
        }