Example #1
0
        Task IUserRoleStore <User, int> .AddToRoleAsync(User user, string roleName)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            if (string.IsNullOrEmpty(roleName))
            {
                throw new ArgumentException("roleName");
            }

            DAL.Models.Role role = this.unitOfWork.Roles.GetByName(roleName);
            if (user.Roles == null)
            {
                user.Roles = new List <DAL.Models.Role>();
            }
            if (role != null && user.Roles.All(r => r.Id != role.Id))
            {
                user.Roles.Add(role);
            }

            return(Task.FromResult(0));
        }
Example #2
0
 void IRoleService.Update(RoleDTO roleToUpdate)
 {
     DAL.Models.Role role = this.mapper.Map <DAL.Models.Role>(roleToUpdate);
     this.unitOfWork.Roles.Update(role);
     this.unitOfWork.Save();
 }
Example #3
0
 void IRoleService.Insert(RoleDTO newRole)
 {
     DAL.Models.Role role = this.mapper.Map <DAL.Models.Role>(newRole);
     this.unitOfWork.Roles.Insert(role);
     this.unitOfWork.Save();
 }
Example #4
0
 RoleDTO IRoleService.GetByName(string rolename)
 {
     DAL.Models.Role role = this.unitOfWork.Roles.GetByName(rolename);
     return(this.mapper.Map <RoleDTO>(role));
 }
Example #5
0
 RoleDTO IRoleService.GetById(int id)
 {
     DAL.Models.Role role = this.unitOfWork.Roles.GetById(id);
     return(this.mapper.Map <RoleDTO>(role));
 }
Example #6
0
 public static DTO.Models.Role RoleDTOToRoleDAO(this DAL.Models.Role role)
 {
     return(new DTO.Models.Role(role.Id, role.RoleName));
 }