public IActionResult OrderDoor() { var model = new DoorOrderViewModel(); DoorOrderVMInitializer(model); return(View(model)); }
private OrderDetails FormEditedOrderDetails(DoorOrderViewModel model) { return(new OrderDetails() { DoorQuantity = model.OrderDetails.DoorQuantity, Door = _doors[_editIndex], }); }
private OrderDetails FormOrderDetails(DoorOrderViewModel model) { return(new OrderDetails() { DoorQuantity = model.OrderDetails.DoorQuantity, Door = _currentDoor, }); }
private void DoorOrderVMInitializer(DoorOrderViewModel model) { var colorsList = _dbContext.Colors.ToList(); var colors = new SelectList(colorsList, "ColorId", "Name"); var doorCategoriesList = _dbContext.DoorCategories.ToList(); var doorCategories = new SelectList(doorCategoriesList, "DoorsCategoriesId", "CategoryName"); var openingStylesList = _dbContext.OpeningStyles.ToList(); var openingStyles = new SelectList(openingStylesList, "OpeningStylesId", "Name"); var styleTypesList = _dbContext.StyleTypes.ToList(); var styleTypes = new SelectList(styleTypesList, "StyleTypesId", "Name"); var materialsCategoriesList = _dbContext.MaterialsCategory.Where(mc => mc.MaterialCategoryId < 3).ToList(); var materialCategories = new SelectList(materialsCategoriesList, "MaterialCategoryId", "Name"); var lockCategoriesList = _dbContext.MaterialsCategory.Where(mc => mc.MaterialCategoryId >= 3).ToList(); var lockCategories = new SelectList(lockCategoriesList, "MaterialCategoryId", "Name"); var baseMaterialsList = new List <Materials>(); var baseMaterials = new SelectList(materialsCategoriesList, "MaterialId", "Name"); var locksList = new List <Materials>(); var locks = new SelectList(lockCategoriesList, "MaterialId", "Name"); if (model.BaseMaterialCategoryID == 0) { baseMaterialsList = _dbContext.Materials .Where(m => m.MaterialCategoryId == 1) .ToList(); baseMaterials = new SelectList(baseMaterialsList, "MaterialId", "Name"); } else { baseMaterialsList = _dbContext.Materials .Where(m => m.MaterialCategoryId == model.BaseMaterialCategoryID) .ToList(); baseMaterials = new SelectList(baseMaterialsList, "MaterialId", "Name"); } if (model.LockCategoryID == 0) { locksList = _dbContext.Materials .Where(m => m.MaterialCategoryId == 3) .ToList(); locks = new SelectList(locksList, "MaterialId", "Name"); } else { locksList = _dbContext.Materials .Where(m => m.MaterialCategoryId == model.LockCategoryID) .ToList(); locks = new SelectList(locksList, "MaterialId", "Name"); } model.Colors = colors; model.DoorCategories = doorCategories; model.OpeningStyles = openingStyles; model.StyleTypes = styleTypes; model.MaterialCategories = materialCategories; model.LockCategories = lockCategories; model.BaseMaterials = baseMaterials; model.Locks = locks; }
public IActionResult OrderDoor(DoorOrderViewModel model) { if (ModelState.IsValid) { _orderCreator.ReadData(model, _dbContext); return(RedirectToAction("OrderDoor")); } DoorOrderVMInitializer(model); return(View(model)); }
public IActionResult EditDoor(DoorOrderViewModel model) { if (ModelState.IsValid) { _orderCreator.EditItem(model, _dbContext); return(RedirectToAction("EditOrder")); } DoorOrderVMInitializer(model); return(View(model)); }
public void ReadData(DoorOrderViewModel model, DoorsDatabaseContext dbContext) { if (_order == null) { _order = new Orders(); } _currentDoor = DesignDoor(model, dbContext); _doors.Add(_currentDoor); _currentOrderDetails = FormOrderDetails(model); _orderDetails.Add(_currentOrderDetails); _doorVM.Add(model); ResetCurrentFields(); }
private Doors DesignDoor(DoorOrderViewModel model, DoorsDatabaseContext dbContext) { var doorToDesign = model.Door; double baseMaterialCount = doorToDesign.Height / 100.0 * doorToDesign.Width / 100.0 * doorToDesign.Thickness / 100.0; var baseMaterial = dbContext.Materials.First(m => m.MaterialId == model.BaseMaterialID); var doorLock = dbContext.Materials.First(m => m.MaterialId == model.LockID); doorToDesign.MaterialsDoor.Add(new MaterialsDoor() { Door = doorToDesign, MaterialId = baseMaterial.MaterialId, CountMaterial = baseMaterialCount }); doorToDesign.MaterialsDoor.Add(new MaterialsDoor() { Door = doorToDesign, MaterialId = doorLock.MaterialId, CountMaterial = 1 }); var doorPrice = baseMaterialCount * (double)baseMaterial.Price + (double)doorLock.Price; const double doorRate = 0.42; doorToDesign.Price = Decimal.Round((decimal)doorPrice, 2); doorToDesign.Rate = doorRate; doorToDesign.DoorName = "Тест"; return(doorToDesign); }
public void EditItem(DoorOrderViewModel model, DoorsDatabaseContext dbContext) { _doors[_editIndex] = DesignDoor(model, dbContext); _orderDetails[_editIndex] = FormEditedOrderDetails(model); _doorVM[_editIndex] = model; }