Пример #1
0
        public async Task <DepartmentGetResponse> Get(DepartmentGetRequest request)
        {
            DepartmentGetResponse response = new DepartmentGetResponse();

            //var userLogin = await _context.GetCurrentCustomer();
            try
            {
                if (!string.IsNullOrEmpty(request.Id))
                {
                    RDepartment department = await _roleService.DepartmentGetFromDb(request.Id);

                    if (department == null)
                    {
                        response.SetFail(BaseResponse.ErrorCodeEnum.DepartmentNotFound);
                        return(response);
                    }
                    response.Department = department.ToModel();
                }
                else
                {
                    response.Department = new DepartmentViewModel()
                    {
                        Status = false,
                    };
                }
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }
 public static KeyValueTypeStringModel ToKeyValueTypeStringModel(this RDepartment department)
 {
     if (department == null)
     {
         return(null);
     }
     return(new KeyValueTypeStringModel()
     {
         Value = department.Id,
         Text = department.Name
     });
 }
 public static DepartmentViewModel ToModel(this RDepartment department)
 {
     if (department == null)
     {
         return(null);
     }
     return(new DepartmentViewModel()
     {
         Name = department.Name,
         Id = department.Id,
         Status = department.Status == EnumDefine.DepartmentStatusEnum.Active,
         StatusName = department.Status.ToString()
     });
 }
Пример #4
0
 public static RoleViewModel ToModel(this RRole role, RDepartment department)
 {
     if (role == null)
     {
         return(null);
     }
     return(new RoleViewModel()
     {
         Name = role.Name,
         Id = role.Id,
         Status = role.Status == EnumDefine.RoleStatusEnum.Active,
         StatusName = role.Status.ToString(),
         DepartmentId = role.DepartmentId,
         DepartmentName = department?.Name
     });
 }