public ActionResult Edit(SubAssembly model) { try { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); string ref_no = new SubAssemblyRepository().UpdateSubAssembly(model); TempData["success"] = "Updated Successfully - " + ref_no; return(RedirectToAction("Index")); } catch (SqlException sx) { if (sx.Errors[0].Number == 547) { TempData["error"] = "Cannot update, because the record is in use elsewhere"; } else { TempData["error"] = "Some error occured while connecting to database|" + sx.Message; } } catch (Exception ex) { TempData["error"] = "Some error occured while saving. Please try again.|" + ex.Message; } FillDropdowns(); return(View("Create", model)); }
public ActionResult Create(SubAssembly model) { try { if (ModelState.IsValid) { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); string ref_no = new SubAssemblyRepository().CreateSubAssembly(model); TempData["success"] = "Saved Successfully. Reference No. is " + ref_no; } else { var allErrors = ModelState.Values.SelectMany(v => v.Errors); FillDropdowns(); return(View(model)); } } catch (Exception ex) { TempData["error"] = "Some error occured while saving. Please try again.|" + ex.Message; FillDropdowns(); return(View(model)); } return(RedirectToAction("Create")); }
public ActionResult Edit(int id = 0)//StockCreationId is received here { if (id == 0) { TempData["error"] = "That was an invalid/unknown request"; return(RedirectToAction("Index", "Home")); } var model = new SubAssemblyRepository().GetSubAssembly(id, OrganizationId); if (model == null) { TempData["error"] = "Requested item not found!"; return(RedirectToAction("Index", "Home")); } FillDropdowns(); return(View(model)); }