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 Create(SalesFormModel formModel) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Create))); } return(RedirectToAction(nameof(Review), formModel)); }
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); }
public IActionResult Create() { SalesFormModel createModel = new SalesFormModel(); return(this.View(this.ReloadCollections(createModel))); }
public IActionResult Review(SalesFormModel formModel) { var sale = this.sales.SaleReview(formModel.CarId, formModel.CustomerId, formModel.Discount); return(View(sale)); }