Esempio n. 1
0
        public void Add(D.Role role)
        {
            EF.Role efRole = ConvertToEF(role);

            _context.Roles.Add(efRole);
            _context.SaveChanges();
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
            }
        }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 private EF.Role ConvertToEFwithID(D.Role role)
 {
     return(new EF.Role(role.RoleID, role.Name, string.Join(";", role.Permissions)));
 }
Esempio n. 6
0
 public void Edit(D.Role role)
 {
     EF.Role efRole = ConvertToEFwithID(role);
     _context.Entry(efRole).State = EntityState.Modified;
     _context.SaveChanges();
 }
Esempio n. 7
0
 public void Edit(D.Role role)
 {
     RoleRepository.Edit(role);
 }
Esempio n. 8
0
 public void Add(D.Role role)
 {
     RoleRepository.Add(role);
 }