public static Role CreateRole(string RoleName) { var db = new DatabaseEntities(); Role role = new Role(); role.Permission = new Permission(); role.RoleName = RoleName; db.Roles.Add(role); db.SaveChanges(); return role; }
public static Role CreateRole(string RoleName,int PermissionId) { var db = new DatabaseEntities(); var p = from permission in db.Permissions where permission.PermissionId == PermissionId select permission; if (p.Any()) { Role role = new Role(); role.Permission = p.First(); role.RoleName = RoleName; db.Roles.Add(role); db.SaveChanges(); return role; } else { return null; } }