// GET: ProjectType public ActionResult Index(int?id) { WFM_ProjectType projectType = new WFM_ProjectType(); if (id != null) { projectType = projectTypeService.GetProjectTypeById(id); } return(View(projectType)); }
public void SaveOrUpdate(WFM_ProjectType designation) { using (LinkManagementEntities entities = new LinkManagementEntities()) { if (designation.Id == 0) { entities.WFM_ProjectType.Add(designation); entities.SaveChanges(); } else { entities.Entry(designation).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); } } }
public ActionResult SaveOrUpdate(WFM_ProjectType model) { string newData = string.Empty, oldData = string.Empty; try { int id = model.Id; WFM_ProjectType projectType = null; WFM_ProjectType oldProjectType = null; if (model.Id == 0) { projectType = new WFM_ProjectType { Name = model.Name, IsActive = true }; oldProjectType = new WFM_ProjectType(); oldData = new JavaScriptSerializer().Serialize(oldProjectType); newData = new JavaScriptSerializer().Serialize(projectType); } else { projectType = projectTypeService.GetProjectTypeById(model.Id); oldProjectType = projectTypeService.GetProjectTypeById(model.Id); oldData = new JavaScriptSerializer().Serialize(new WFM_ProjectType() { Id = oldProjectType.Id, Name = oldProjectType.Name, IsActive = oldProjectType.IsActive }); projectType.Name = model.Name; bool Example = Convert.ToBoolean(Request.Form["IsActive.Value"]); projectType.IsActive = model.IsActive; newData = new JavaScriptSerializer().Serialize(new WFM_ProjectType() { Id = projectType.Id, Name = projectType.Name, IsActive = projectType.IsActive }); } projectTypeService.SaveOrUpdate(projectType); CommonService.SaveDataAudit(new DataAudit() { Entity = "ProjectType", NewData = newData, OldData = oldData, UpdatedOn = DateTime.Now, UserId = new Guid(User.Identity.GetUserId()) }); TempData["Message"] = "<div id='flash-success'>Record Saved Successfully.</div>"; } catch (Exception ex) { TempData["Message"] = "<span id='flash-error'>Error.</span>" + ex.InnerException; } return(RedirectToAction("Index", "ProjectType")); }