public Role Search(Role role) { try { var result = new DbModel.Role(); if (role.Id != Guid.Empty) { result = _roleDataAccess.SearchByRoleId(role.Id); } else if (!string.IsNullOrWhiteSpace(role.Name)) { result = _roleDataAccess.SearchByRoleName(role.Name); } else { result = null; } if (result != null) { var returnValue = new Role { Id = result.Id, Name = result.Name, Description = result.Description, StatusId = result.StatusId, Status = result.Status.Name }; return(returnValue); } else { return(null); } } catch (Exception ex) { throw ex; } }
public bool Add(Role role) { try { var roleData = new DbModel.Role { Id = Guid.NewGuid(), Name = role.Name, Description = role.Description, StatusId = role.StatusId, CreatedDate = DateTime.UtcNow, CreatedBy = _username }; var result = _roleDataAccess.Add(roleData); var returnValue = result > 0 ? true : false; return(returnValue); } catch (Exception ex) { throw ex; } }