public async Task <GenericResponse <IEnumerable <UserDto> > > GetList([FromBody] FilterCriteria filterCriteria) { IEnumerable <UserBo> listBo = null; IEnumerable <UserDto> listDto = null; ServiceResult <IEnumerable <UserBo> > resultList; CultureInfo enCulture = new CultureInfo("en-US"); long organizationId = 0; if (filterCriteria == null) { filterCriteria = new FilterCriteria(); } DictonaryFilter dictonaryFilter = filterCriteria.DictonaryBasedFilter.FirstOrDefault(x => x.Key == "organizationId"); if (dictonaryFilter == null || !long.TryParse(dictonaryFilter.Data, out organizationId)) { organizationId = 0; } if (organizationId > 0) { // Yetki kontrolü yapılıyor ServiceResult <bool> resultAutorized = await GetAutorizedOrganizationStatusById(organizationId); if (!resultAutorized.Success || !resultAutorized.Data) { return(GenericResponse <IEnumerable <UserDto> > .Error(ResultType.Error, "Not Autorized Access!", "U_GL_01", StatusCodes.Status203NonAuthoritative)); } } else { ServiceResult <UserBo> userDtoResult = await GetCurrentUser(); if (!userDtoResult.Success || userDtoResult.Data == null) { return(GenericResponse <IEnumerable <UserDto> > .Error(ResultType.Error, "User Not Found!", "U_GL_02", StatusCodes.Status404NotFound)); } organizationId = userDtoResult.Data.OrganizationId; } resultList = await serviceManager.User_Service.GetListAsync(organizationId, filterCriteria); if (!resultList.Success || resultList.Data == null) { return(GenericResponse <IEnumerable <UserDto> > .Error(ResultType.Error, resultList.Error, "U_GL_03", StatusCodes.Status500InternalServerError)); } listBo = resultList.Data; listDto = listBo.Select(x => UserBo.ConvertToDto(x)).ToList(); return(GenericResponse <IEnumerable <UserDto> > .Ok(listDto)); }
public async Task <GenericResponse <UserDto> > Get(long id) { UserBo userBo = null; FilterCriteria filterCriteria = new FilterCriteria(); filterCriteria.QueryFilter = "Id = " + id; filterCriteria.IncludeProperties = "UserRole,UserRole.Role,UserRole.Role.GrandRole,UserRole.Role.GrandRole.Grand"; ServiceResult <IEnumerable <UserBo> > result = await serviceManager.User_Service.FindAsync(filterCriteria); if (result.Success) { userBo = result.Data.FirstOrDefault(); if (userBo == null) { return(GenericResponse <UserDto> .Error(ResultType.Error, "Not Found!", "U_G_01", StatusCodes.Status404NotFound)); } else { // Yetki kontrolü yapılıyor ServiceResult <bool> resultAutorized = await GetAutorizedUserStatusById(userBo); if (!resultAutorized.Success || !resultAutorized.Data) { return(GenericResponse <UserDto> .Error(ResultType.Error, "Not Autorized Access!", "U_G_02", StatusCodes.Status203NonAuthoritative)); } } UserDto userDto = UserBo.ConvertToDto(userBo); userDto.Password = ""; return(GenericResponse <UserDto> .Ok(userDto)); } else { Log(result.Error, LogLevel.Error, this.ControllerContext.RouteData.Values); return(GenericResponse <UserDto> .Error(ResultType.Error, result.Error, "U_G_03", StatusCodes.Status500InternalServerError)); } }