コード例 #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));
        }
コード例 #2
0
        public IActionResult Create(SalesFormModel formModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(nameof(Create)));
            }

            return(RedirectToAction(nameof(Review), formModel));
        }
コード例 #3
0
        private SalesFormModel ReloadCollections(SalesFormModel model)
        {
            model.Customers = this.customers
                              .CustomersList()
                              .Select(c => new SelectListItem
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            })
                              .ToList();

            model.Cars = this.cars
                         .CarsList()
                         .Select(c => new SelectListItem
            {
                Value = c.Id.ToString(),
                Text  = c.FullModel
            })
                         .ToList();

            return(model);
        }
コード例 #4
0
        public IActionResult Create()
        {
            SalesFormModel createModel = new SalesFormModel();

            return(this.View(this.ReloadCollections(createModel)));
        }
コード例 #5
0
        public IActionResult Review(SalesFormModel formModel)
        {
            var sale = this.sales.SaleReview(formModel.CarId, formModel.CustomerId, formModel.Discount);

            return(View(sale));
        }