public ActionResult Details(int id) { var model = new RepairDetailsViewModel(); model.Repair = db.GetRepair(id); if (model.Repair == null) { return(View("NotFound")); } if (model.Repair.Image != null) { WebImage image = new WebImage(model.Repair.Image); image.Resize(250, image.Height, true, true); model.Repair.Image = image.GetBytes(); } model.RepairParts = db.GetRepairParts(id); if (model.RepairParts.Count() > 1) { model.PartsTotalPrice = db.GetRepairPartsPriceSum(id); } return(View(model)); }
public ActionResult Index() { var model = new IndexViewModel(); var repairs = db.GetRepairs(); model.RepairCount = repairs.Count(); if (model.RepairCount != 0) { model.RepairPartsCount = db.GetRepairPartsCount(); if (model.RepairPartsCount != 0) { model.RepairPartsTotalPrice = db.GetRepairPartsPriceSum(); } model.RepairStatusCounts = new Dictionary <Status, int>(); model.RepairStatusCounts.Add(Status.Pending, 0); model.RepairStatusCounts.Add(Status.InProgress, 0); model.RepairStatusCounts.Add(Status.WaitingForParts, 0); model.RepairStatusCounts.Add(Status.Completed, 0); foreach (var repair in repairs) { model.RepairStatusCounts[repair.Status]++; } } return(View(model)); }
// GET: RepairParts public ActionResult Index(int id) { var model = new RepairPartsViewModel(); model.RepairId = id; model.RepairParts = db.GetRepairParts(id); if (model.RepairParts.Count() > 1) { model.PartsTotalPrice = db.GetRepairPartsPriceSum(id); } model.Parts = new List <SelectListItem>(); foreach (var part in db.GetParts()) { var item = new SelectListItem() { Text = part.Name, Value = part.Id.ToString() }; model.Parts.Add(item); } return(View(model)); }