public void Add(D.Role role) { EF.Role efRole = ConvertToEF(role); _context.Roles.Add(efRole); _context.SaveChanges(); }
private D.Role ConverToDomain(EF.Role efRole) { D.Role role = new D.Role(efRole.RoleID, efRole.Name); IEnumerable <string> permissions = efRole.Permissions.Split(';'); foreach (var permission in permissions) { role.AddPermission(permission); } return(role); }
public HttpResponseMessage CreateRole([FromBody] Role role) { D.Role temp = new D.Role(role.Name, role.Permissions); try { Service.Add(temp); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (InvalidRoleException) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage EditRole([FromBody] Role role) { D.Role temp = new D.Role(role.RoleID, role.Name, role.Permissions); Service.Edit(temp); return(Request.CreateResponse(HttpStatusCode.OK)); }
private EF.Role ConvertToEFwithID(D.Role role) { return(new EF.Role(role.RoleID, role.Name, string.Join(";", role.Permissions))); }
public void Edit(D.Role role) { EF.Role efRole = ConvertToEFwithID(role); _context.Entry(efRole).State = EntityState.Modified; _context.SaveChanges(); }
public void Edit(D.Role role) { RoleRepository.Edit(role); }
public void Add(D.Role role) { RoleRepository.Add(role); }