public ActionResult UpdateTypesofEstirack(EshtiracksType Eshtirackstype) { try { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { EshtiracksType updatedTypesofEstiracks = (from c in entities.EshtiracksTypes where c.Id == Eshtirackstype.Id select c).FirstOrDefault(); updatedTypesofEstiracks.Description = Eshtirackstype.Description; updatedTypesofEstiracks.Amount = Eshtirackstype.Amount; entities.SaveChanges(); int id = Eshtirackstype.Id; if (id > 0) { TempData["Success"] = "Successfully Updated"; TempData["Heading"] = 1; return(RedirectToAction("TypesofEstiracks")); } else { TempData["Failed"] = "Not Updated"; return(View()); } } } catch (Exception ex) { TempData["Failed"] = "Exception Occured"; return(View()); } }
public ActionResult TypesofEstiracks(EshtiracksType Eshtirackstype) { try { if (ModelState.IsValid) { using (ArchitectureEntitiesModel entities = new ArchitectureEntitiesModel()) { entities.EshtiracksTypes.Add(Eshtirackstype); entities.SaveChanges(); int id = Eshtirackstype.Id; if (id > 0) { TempData["Success"] = "Successfully Saved"; } else { TempData["Failed"] = "Not Saved"; } } } } catch (Exception ex) { TempData["Failed"] = "Exception Occured"; return(View()); } return(RedirectToAction("TypesofEstiracks")); }
public ActionResult EditTypesofEstiracks(Int32 id) { EshtiracksType TypesofEstiracks = new EshtiracksType(); try { TypesofEstiracks = entities.EshtiracksTypes.Where(x => x.Id == id).FirstOrDefault(); if (TypesofEstiracks != null) { ViewBag.Id = id; TempData["Heading"] = 1; } } catch (Exception ex) { } return(View(TypesofEstiracks)); }