public ActionResult newInspection(int bikeId) { if (!authorize()) { return(RedirectToAction("authError", "Error")); } var model = new Inspection(); model.bikeId = bikeId; var vModel = new ViewModels.specWithMaint(); vModel.spec = model; vModel.maint = new MaintenanceEvent(); return(View(vModel)); }
public ActionResult newInspection([Bind] ViewModels.specWithMaint inspection) { if (!authorize()) { return(RedirectToAction("authError", "Error")); } inspection.spec.inspectorId = context.BikeUser.Where(u => u.userName == User.Identity.Name).First().bikeUserId; if (!String.IsNullOrWhiteSpace(inspection.maint.title)) { inspection.maint.submittedById = context.BikeUser.Where(u => u.userName == User.Identity.Name).First().bikeUserId; context.MaintenanceEvent.Add(inspection.maint); context.SaveChanges(); return(RedirectToAction("maintenanceDetails", "Mechanic", new { inspection.maint.MaintenanceEventId })); } inspection.spec.datePerformed = DateTime.Now; context.Inspection.Add(inspection.spec); context.Bike.Find(inspection.spec.bikeId).onInspectionHold = !inspection.spec.isPassed; context.SaveChanges(); return(RedirectToAction("bikeDetails", "Mechanic", new { bikeId = inspection.spec.bikeId })); }
public ActionResult newInspection(int bikeId) { if (!authorize()) { return RedirectToAction("authError", "Error"); } var model = new Inspection(); model.bikeId = bikeId; var vModel = new ViewModels.specWithMaint(); vModel.spec = model; vModel.maint = new MaintenanceEvent(); return View(vModel); }