public ActionResult Index(RolesMenuModel model) { try { AT_Roles objRoles = null; if (model.RoleId == null) { objRoles = new AT_Roles(); objRoles.IsVisible = true; objRoles.CreatedBy = User.Identity.Name; objRoles.CreatedDate = DateTime.Now; CoreContext.AT_Roles.Add(objRoles); } else { objRoles = (from a in CoreContext.AT_Roles where a.RoleId == model.RoleId select a).FirstOrDefault(); objRoles.ModifiedBy = User.Identity.Name; objRoles.ModifiedDate = DateTime.Now; } objRoles.Name = model.RoleName; CoreContext.SaveChanges(); return(Success(M("savedsucessfully"))); } catch (Exception e) { return(Error("InternalError")); } }
public ActionResult DeleteRole(int RoleId) { try { AT_Roles objRoles = (from a in CoreContext.AT_Roles where a.RoleId == RoleId select a).FirstOrDefault(); CoreContext.AT_Roles.Remove(objRoles); CoreContext.SaveChanges(); return(Success(M("savedsucessfully"))); } catch (Exception e) { return(Error("InternalError")); } }