public Int32 GetRoleID(string rolename, Int32 companyid) { Int32 roleid = -1; roleid = SearchRoleID(rolename, companyid); if (roleid > 0) { return roleid; } else { var role = new ACLRole { Name = rolename, Description="Admin Role", CompanyID = companyid, CreatedTime = DateTime.Now, ModifiedTime = DateTime.Now, IsDeleted=false }; context.ACLRoles.Add(role); context.SaveChanges(); roleid = role.RoleID;//SearchRoleID(rolename, companyid); return roleid; } }
public int InsertRole(string roleName, string description) { Int32 companyid = Convert.ToInt32(HttpContext.Current.Session["CompanyID"]); int roleid = 0; var role = new ACLRole { CompanyID = companyid, Name = roleName, Description = description, CreatedTime = DateTime.Now, ModifiedTime = DateTime.Now, IsDeleted = false }; context.ACLRoles.Add(role); context.SaveChanges(); roleid = role.RoleID; return roleid; }