public ActionResult Create(MechanicBase newMech) { if (!ModelState.IsValid) { return(View(newMech)); } bool isUnique = m.isMechanicUnique(newMech); if (!isUnique) { string errorMsg = "Duplicate entry. That phone or email already exists."; @TempData["SubmitErrorMsg"] = errorMsg; return(View(newMech)); } var addedMech = m.MechanicAddNew(newMech); if (addedMech == null) { return(View(newMech)); } else { return(RedirectToAction("Details", new { id = addedMech.Id })); } }
public ActionResult Edit(int?id, MechanicBase newItem) { //validate the input if (!ModelState.IsValid) { return(RedirectToAction("Edit", new { id = newItem.Id })); } if (id.GetValueOrDefault() != newItem.Id) { return(RedirectToAction("index")); } bool isUnique = m.isMechanicUnique(newItem); if (!isUnique) { string errorMsg = "Duplicate entry. That phone or email already exists. Resetting info."; @TempData["SubmitErrorMsg"] = errorMsg; return(RedirectToAction("Edit", new { id = newItem.Id })); } //attempt to do the update var editedItem = m.MechanicEdit(newItem); if (editedItem == null) { //there is a problem updating the object return(RedirectToAction("Edit", new { id = newItem.Id })); } else { return(RedirectToAction("Details", new { id = newItem.Id })); } }
public PrevLog(MechanicBase mech, DateTime start, DateTime end) { Mech = mech; startTime = start; endTime = end; }