Ejemplo n.º 1
0
        public async Task <GenericResponse> Put(long id, UserTokenDto dto)
        {
            if (id != dto.Id)
            {
                return(GenericResponse.Error(ResultType.Error, "Ids are mismatch!", "RT_PT_01", StatusCodes.Status500InternalServerError));
            }
            try
            {
                UserTokenBo   bo            = UserTokenBo.ConvertToBusinessObject(dto);
                ServiceResult serviceResult = await serviceManager.UserToken_Service.UpdateAsync(id, bo);

                if (serviceResult.Success)
                {
                    await serviceManager.CommitAsync();

                    return(GenericResponse.Ok());
                }
                else
                {
                    return(GenericResponse.Error(ResultType.Error, serviceResult.Error, "RT_PT_02", StatusCodes.Status500InternalServerError));
                }
            }
            catch (Exception ex)
            {
                Log(ex.Message, LogLevel.Error, this.ControllerContext.RouteData.Values);
                return(GenericResponse.Error(ResultType.Error, ex.Message, "RT_PT_03", StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 2
0
        public async Task <GenericResponse> Put(long id, OrganizationDto dto)
        {
            if (id != dto.Id)
            {
                return(GenericResponse.Error(ResultType.Error, "Ids are mismatch!", "O_PT_01", StatusCodes.Status500InternalServerError));
            }
            try
            {
                // Yetki kontrolü yapılıyor
                ServiceResult <bool> resultAutorized = await GetAutorizedOrganizationStatusById(dto.Id);

                if (!resultAutorized.Success || !resultAutorized.Data)
                {
                    return(GenericResponse.Error(ResultType.Error, "Not Autorized Access!", "O_PT_02", StatusCodes.Status203NonAuthoritative));
                }
                OrganizationBo bo            = OrganizationBo.ConvertToBusinessObject(dto);
                ServiceResult  serviceResult = await serviceManager.Organization_Service.UpdateAsync(id, bo);

                if (serviceResult.Success)
                {
                    await serviceManager.CommitAsync();

                    return(GenericResponse.Ok());
                }
                else
                {
                    return(GenericResponse.Error(ResultType.Error, serviceResult.Error, "O_PT_03", StatusCodes.Status500InternalServerError));
                }
            }
            catch (Exception ex)
            {
                Log(ex.Message, LogLevel.Error, this.ControllerContext.RouteData.Values);
                return(GenericResponse.Error(ResultType.Error, ex.Message, "O_PT_04", StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 3
0
        public async Task <GenericResponse <OrganizationDto> > Post([FromBody] OrganizationDto dto)
        {
            if (dto.ParentId.HasValue && dto.ParentId > 0)
            {
                // Yetki kontrolü yapılıyor
                ServiceResult <bool> resultAutorized = await GetAutorizedOrganizationStatusById(dto.ParentId.Value);

                if (!resultAutorized.Success || !resultAutorized.Data)
                {
                    return(GenericResponse <OrganizationDto> .Error(ResultType.Error, "Not Autorized Access!", "O_PST_01", StatusCodes.Status203NonAuthoritative));
                }
            }
            else
            {
                return(GenericResponse <OrganizationDto> .Error(ResultType.Error, "Parent organization identifer not found!", "O_PST_02", StatusCodes.Status404NotFound));
            }

            OrganizationBo bo = OrganizationBo.ConvertToBusinessObject(dto);
            ServiceResult <OrganizationBo> result = await serviceManager.Organization_Service.CreateAsync(bo);

            if (result.Success)
            {
                bo = result.Data;

                await serviceManager.CommitAsync();

                return(GenericResponse <OrganizationDto> .Ok(OrganizationBo.ConvertToDto(bo)));
            }
            else
            {
                return(GenericResponse <OrganizationDto> .Error(ResultType.Error, "Parent organization identifer not found!", "O_PST_03", StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <GenericResponse> Delete(long id)
        {
            UserBo userDto = null;
            ServiceResult <UserBo> result = await serviceManager.User_Service.GetByIdAsync(id);

            if (result.Success)
            {
                userDto = result.Data;

                // Yetki kontrolü yapılıyor
                ServiceResult <bool> resultAutorized = await GetAutorizedUserStatusById(userDto);

                if (!resultAutorized.Success || !resultAutorized.Data)
                {
                    return(GenericResponse.Error(ResultType.Error, "Not Autorized Access!", "U_DLT_01", StatusCodes.Status203NonAuthoritative));
                }
            }
            else
            {
                return(GenericResponse.Error(ResultType.Error, "Not Found!", "U_DLT_02", StatusCodes.Status404NotFound));
            }

            ServiceResult serviceResult = await serviceManager.User_Service.DeleteAsync(id);

            if (serviceResult.Success)
            {
                return(GenericResponse.Ok());
            }
            else
            {
                Log(serviceResult.Error, LogLevel.Error, this.ControllerContext.RouteData.Values);

                return(GenericResponse.Error(ResultType.Error, serviceResult.Error, "U_DLT_03", StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 5
0
        public async Task <GenericResponse <OrganizationDto> > Get(long id)
        {
            // Yetki kontrolü yapılıyor
            ServiceResult <bool> resultAutorized = await GetAutorizedOrganizationStatusById(id);

            if (!resultAutorized.Success || !resultAutorized.Data)
            {
                return(GenericResponse <OrganizationDto> .Error(ResultType.Error, "Not Autorized Access!", "O_G_01", StatusCodes.Status203NonAuthoritative));
            }

            OrganizationBo bo = null;
            ServiceResult <OrganizationBo> result = await serviceManager.Organization_Service.GetByIdAsync(id);

            if (result.Success)
            {
                bo = result.Data;
            }
            else
            {
                Log(result.Error, LogLevel.Error, this.ControllerContext.RouteData.Values);
            }

            if (bo == null)
            {
                return(GenericResponse <OrganizationDto> .Error(ResultType.Error, "User Not Found!", "O_G_02", StatusCodes.Status404NotFound));
            }

            return(GenericResponse <OrganizationDto> .Ok(OrganizationBo.ConvertToDto(bo)));
        }
        public async Task <GenericResponse> Logout()
        {
            try{
                Claim  claim        = null;
                long   userTokenId  = 0;
                string access_token = "";
                IHttpContextAccessor httpContextAccessor = (IHttpContextAccessor)serviceManager.serviceContext.Items["IHttpContextAccessor"];
                if (httpContextAccessor != null && httpContextAccessor.HttpContext != null && httpContextAccessor.HttpContext.User != null)
                {
                    claim = httpContextAccessor.HttpContext.User.Claims.FirstOrDefault(c => c.Type == "utid");
                    if (claim != null)
                    {
                        if (!long.TryParse(claim.Value, out userTokenId))
                        {
                            userTokenId = 0;
                        }
                    }
                }

                if (userTokenId == 0)
                {
                    access_token = serviceManager.serviceContext.Items["Token"].ToString();
                    if (string.IsNullOrEmpty(access_token))
                    {
                        return(GenericResponse.Error(ResultType.Error, "Token not found into the request!", "U_LO_01", StatusCodes.Status404NotFound));
                    }
                }

                UserTokenBo userTokenBo = null;
                ServiceResult <IEnumerable <UserTokenBo> > result = null;
                if (userTokenId > 0)
                {
                    result = await serviceManager.UserToken_Service.GetAsync(
                        filter : (rt => rt.Id == userTokenId && rt.UserId == this.currentUserId),
                        orderBy : (rt => rt.OrderByDescending(x => x.ExpiryDate)));
                }
                else
                {
                    result = await serviceManager.UserToken_Service.GetAsync(
                        filter : (rt => rt.AccessToken == access_token && rt.UserId == this.currentUserId),
                        orderBy : (rt => rt.OrderByDescending(x => x.ExpiryDate)));
                }
                if (!result.Success)
                {
                    return(GenericResponse.Error(ResultType.Error, "User Token Not Found!", "U_LO_02", StatusCodes.Status404NotFound));
                }

                userTokenBo            = result.Data.FirstOrDefault();
                userTokenBo.LogoutTime = DateTime.Now;
                userTokenBo.IsLogout   = true;
                await serviceManager.UserToken_Service.UpdateAsync(userTokenBo.Id, userTokenBo);

                return(GenericResponse.Ok());
            }
            catch (Exception ex) {
                return(GenericResponse.Error(ResultType.Error, ex.Message, "U_LO_03", StatusCodes.Status500InternalServerError));
            }
        }
        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));
        }
Ejemplo n.º 8
0
        public async Task <GenericResponse> Delete(long id)
        {
            ServiceResult serviceResult = await serviceManager.UserToken_Service.DeleteAsync(id);

            if (serviceResult.Success)
            {
                return(GenericResponse.Ok());
            }
            else
            {
                Log(serviceResult.Error, LogLevel.Error, this.ControllerContext.RouteData.Values);
                return(GenericResponse.Error(ResultType.Error, serviceResult.Error, "RT_DLT_01", StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <GenericResponse> TestMail(MailDto mailDto)
        {
            // Deneme amaçlı eklendi
            //ServiceResult service = await mailer.SendAsync(new string[]{"*****@*****.**","*****@*****.**"}, null, null, "test","denemem eerer", null);

            ServiceResult result = await mailer.SendAsync(mailDto.recipients, mailDto.bccList, mailDto.ccList, mailDto.subject, mailDto.body, mailDto.attachments);

            if (result.Success)
            {
                return(GenericResponse.Ok());
            }
            else
            {
                return(GenericResponse.Error(ResultType.Error, result.Error, "TC_TM_01", StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <GenericResponse <TokenResponseDto> > RefreshToken(string refresh_token)
        {
            //ServiceResult<UserBo> userResult = await GetUserFromAccessToken(refreshRequestDto.Access_Token);
            if (currentUserId <= 0)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "User not found into the token!", "U_RT_01", StatusCodes.Status404NotFound));
            }

            string access_token = serviceManager.serviceContext.Items["Token"].ToString();

            if (string.IsNullOrEmpty(access_token))
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "Token not found into the request!", "U_RT_02", StatusCodes.Status404NotFound));
            }

            ServiceResult validationResult = await ValidateUserToken(currentUserId, access_token, refresh_token);

            if (!validationResult.Success)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, validationResult.Error, "U_RT_03", StatusCodes.Status404NotFound));
            }

            UserBo         user           = null;
            FilterCriteria filterCriteria = new FilterCriteria();

            filterCriteria.QueryFilter       = "Id = " + this.currentUserId;
            filterCriteria.IncludeProperties = "UserType,UserRole,UserRole.Role,UserRole.Role.GrandRole";
            ServiceResult <IEnumerable <UserBo> > userResult = await serviceManager.User_Service.FindAsync(filterCriteria);

            if (!userResult.Success || userResult.Data == null)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "Logged user not found!", "U_RT_04", StatusCodes.Status404NotFound));
            }
            else
            {
                user = userResult.Data.FirstOrDefault();
            }

            ServiceResult <TokenResponseDto> userTokenResult = await GetTokenResponseAsync(user);

            if (!userTokenResult.Success)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, userTokenResult.Error, "U_RT_05", StatusCodes.Status500InternalServerError));
            }

            return(GenericResponse <TokenResponseDto> .Ok(userTokenResult.Data));
        }
        public async Task <GenericResponse <string> > TestCompileHtml()
        {
            // Deneme amaçlı eklendi
            string  templateName = "example";
            UserDto userDto      = new UserDto()
            {
                FirstName = "Mühüttün",
                LastName  = "GANDAK"
            };
            ServiceResult <string> result = await printer.CompileHtmlAsync(templateName, userDto);

            if (result.Success)
            {
                return(GenericResponse <string> .Ok(result.Data));
            }
            else
            {
                return(GenericResponse <string> .Error(ResultType.Error, result.Error, "TC_TM_01", StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <GenericResponse <UserDto> > Post([FromBody] UserDto dto)
        {
            UserBo bo = UserBo.ConvertToBusinessObject(dto);

            // Yetki kontrolü yapılıyor
            ServiceResult <bool> resultAutorized = await GetAutorizedUserStatusById(bo);

            if (!resultAutorized.Success || !resultAutorized.Data)
            {
                return(GenericResponse <UserDto> .Error(ResultType.Error, "Not Autorized Access!", "U_PST_01", StatusCodes.Status203NonAuthoritative));
            }

            ServiceResult <UserBo> result = await serviceManager.User_Service.CreateAsync(bo);

            if (result.Success)
            {
                bo     = result.Data;
                dto.Id = bo.Id;

                if (dto.Role != null && dto.Role.Count > 0)
                {
                    UserRoleBo userRoleBo;
                    foreach (var role in dto.Role)
                    {
                        userRoleBo = new UserRoleBo()
                        {
                            UserId = dto.Id, RoleId = role.Id
                        };
                        await serviceManager.UserRole_Service.CreateAsync(userRoleBo);
                    }
                }

                await serviceManager.CommitAsync();
            }
            else
            {
                return(GenericResponse <UserDto> .Error(ResultType.Error, result.Error, "U_PST_02", StatusCodes.Status500InternalServerError));
            }

            return(GenericResponse <UserDto> .Ok(dto));
        }
Ejemplo n.º 13
0
        public async Task <GenericResponse> Delete(long id)
        {
            // Yetki kontrolü yapılıyor
            ServiceResult <bool> resultAutorized = await GetAutorizedOrganizationStatusById(id);

            if (!resultAutorized.Success || !resultAutorized.Data)
            {
                return(GenericResponse.Error(ResultType.Error, "Not Autorized Access!", "O_DLT_01", StatusCodes.Status203NonAuthoritative));
            }
            ServiceResult serviceResult = await serviceManager.Organization_Service.DeleteAsync(id);

            if (serviceResult.Success)
            {
                return(GenericResponse.Ok());
            }
            else
            {
                Log(serviceResult.Error, LogLevel.Error, this.ControllerContext.RouteData.Values);
                return(GenericResponse.Error(ResultType.Error, serviceResult.Error, "O_DLT_02", StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 14
0
        public async Task <GenericResponse <UserTokenDto> > Get(long id)
        {
            UserTokenBo bo = null;
            ServiceResult <UserTokenBo> result = await serviceManager.UserToken_Service.GetByIdAsync(id);

            if (result.Success)
            {
                bo = result.Data;
            }
            else
            {
                Log(result.Error, LogLevel.Error, this.ControllerContext.RouteData.Values);
            }

            if (bo == null)
            {
                return(GenericResponse <UserTokenDto> .Error(ResultType.Error, "User Not Found!", "RT_G_01", StatusCodes.Status404NotFound));
            }

            return(GenericResponse <UserTokenDto> .Ok(UserTokenBo.ConvertToDto(bo)));
        }
        public async Task <GenericResponse <TokenResponseDto> > GetToken([FromBody] TokenDto tokenDto)
        {
            UserBo user = null;
            ServiceResult <IEnumerable <UserBo> > result;

            FilterCriteria filterCriteria = new FilterCriteria();

            filterCriteria.QueryFilter       = "EmailAddress = \"" + tokenDto.EmailAddress + "\"";
            filterCriteria.IncludeProperties = "UserType,UserRole,UserRole.Role,UserRole.Role.GrandRole";
            result = await serviceManager.User_Service.FindAsync(filterCriteria);

            if (result.Success)
            {
                user = result.Data.FirstOrDefault();
            }
            else
            {
                Log(result.Error, LogLevel.Error, this.ControllerContext.RouteData.Values);
            }

            if (user == null)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "Not Found!", "U_GT_01", StatusCodes.Status404NotFound));
            }

            Microsoft.AspNetCore.Identity.PasswordVerificationResult verificationResult = passwordHasher.VerifyHashedPassword(user, user.Password, tokenDto.Password);
            if (verificationResult == Microsoft.AspNetCore.Identity.PasswordVerificationResult.Failed)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, "Password verification failed!", "U_GT_02", StatusCodes.Status404NotFound));
            }

            ServiceResult <TokenResponseDto> userTokenResult = await GetTokenResponseAsync(user);

            if (!userTokenResult.Success)
            {
                return(GenericResponse <TokenResponseDto> .Error(ResultType.Error, userTokenResult.Error, "U_GT_03", StatusCodes.Status500InternalServerError));
            }

            return(GenericResponse <TokenResponseDto> .Ok((userTokenResult.Data)));
        }
        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));
            }
        }
Ejemplo n.º 17
0
        public async Task <GenericResponse <UserTokenDto> > Post([FromBody] UserTokenDto dto)
        {
            UserTokenBo bo = UserTokenBo.ConvertToBusinessObject(dto);
            ServiceResult <UserTokenBo> result = await serviceManager.UserToken_Service.CreateAsync(bo);

            if (result.Success)
            {
                bo = result.Data;

                await serviceManager.CommitAsync();
            }
            else
            {
                return(GenericResponse <UserTokenDto> .Error(ResultType.Error, result.Error, "RT_PST_01", StatusCodes.Status500InternalServerError));
            }

            if (bo == null)
            {
                return(GenericResponse <UserTokenDto> .Error(ResultType.Error, "NOt Found!", "RT_PST_02", StatusCodes.Status404NotFound));
            }

            return(GenericResponse <UserTokenDto> .Ok(UserTokenBo.ConvertToDto(bo)));
        }
Ejemplo n.º 18
0
        public async Task <GenericResponse <IEnumerable <OrganizationDto> > > GetList([FromBody] FilterCriteria filterCriteria)
        {
            IEnumerable <OrganizationBo> listBo = null;
            ServiceResult <IEnumerable <OrganizationBo> > 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 <OrganizationDto> > .Error(ResultType.Error, "Not Autorized Access!", "O_GL_01", StatusCodes.Status203NonAuthoritative));
                }
            }
            else
            {
                ServiceResult <UserBo> userDtoResult = await GetCurrentUser();

                if (!userDtoResult.Success || userDtoResult.Data == null)
                {
                    return(GenericResponse <IEnumerable <OrganizationDto> > .Error(ResultType.Error, "User Not Found!", "O_GL_02", StatusCodes.Status404NotFound));
                }
                organizationId = userDtoResult.Data.OrganizationId;
            }

            resultList = await serviceManager.Organization_Service.GetHierarchicalyByOrganizationIdAsync(organizationId);

            if (!resultList.Success || resultList.Data == null)
            {
                return(GenericResponse <IEnumerable <OrganizationDto> > .Error(ResultType.Error, resultList.Error, "O_GL_03", StatusCodes.Status500InternalServerError));
            }
            listBo = resultList.Data;

            foreach (DictonaryFilter item in filterCriteria.DictonaryBasedFilter)
            {
                switch (item.Key.ToLower(enCulture))
                {
                case "title":
                    switch (item.OperandType)
                    {
                    case OperandType.Equal:
                        listBo = listBo.Where(x => x.Title.ToLower() == item.Data.ToLower());
                        break;

                    case OperandType.NotEqual:
                        listBo = listBo.Where(x => x.Title.ToLower() != item.Data.ToLower());
                        break;

                    case OperandType.Like:
                        listBo = listBo.Where(x => x.Title.ToLower().Contains(item.Data.ToLower()));
                        break;
                    }
                    break;

                case "description":
                    switch (item.OperandType)
                    {
                    case OperandType.Equal:
                        listBo = listBo.Where(x => x.Description.ToLower() == item.Data.ToLower());
                        break;

                    case OperandType.NotEqual:
                        listBo = listBo.Where(x => x.Description.ToLower() != item.Data.ToLower());
                        break;

                    case OperandType.Like:
                        listBo = listBo.Where(x => x.Description.ToLower().Contains(item.Data.ToLower()));
                        break;
                    }
                    break;
                }
            }

            IEnumerable <OrganizationDto> listDto = listBo.Select(x => OrganizationBo.ConvertToDto(x));

            return(GenericResponse <IEnumerable <OrganizationDto> > .Ok(listDto));
        }
        public async Task <GenericResponse> Put(long id, UserDto dto)
        {
            if (id != dto.Id)
            {
                return(GenericResponse.Error(ResultType.Error, "Ids are mismatch!", "U_PT_01", StatusCodes.Status500InternalServerError));
            }
            try
            {
                UserBo bo = UserBo.ConvertToBusinessObject(dto);

                // Yetki kontrolü yapılıyor
                ServiceResult <bool> resultAutorized = await GetAutorizedUserStatusById(bo);

                if (!resultAutorized.Success || !resultAutorized.Data)
                {
                    return(GenericResponse.Error(ResultType.Error, "Not Autorized Access!", "U_PT_02", StatusCodes.Status203NonAuthoritative));
                }

                ServiceResult serviceResult = await serviceManager.User_Service.UpdateAsync(id, bo);

                if (serviceResult.Success)
                {
                    if (dto.Role != null && dto.Role.Count > 0)
                    {
                        await serviceManager.UserRole_Service.DeleteByUserIdAsync(dto.Id);

                        UserRoleBo userRole;
                        foreach (var role in dto.Role)
                        {
                            userRole = new UserRoleBo()
                            {
                                UserId = dto.Id, RoleId = role.Id
                            };
                            await serviceManager.UserRole_Service.CreateAsync(userRole);
                        }
                    }

                    await serviceManager.CommitAsync();

                    return(GenericResponse.Ok());
                }
                else
                {
                    return(GenericResponse.Error(ResultType.Error, serviceResult.Error, "U_PT_03", StatusCodes.Status500InternalServerError));
                }
            }
            catch (DbUpdateConcurrencyException ex)
            {
                Log(ex.Message, LogLevel.Error, this.ControllerContext.RouteData.Values);

                bool exist = await UserExists(id);

                if (!exist)
                {
                    return(GenericResponse.Error(ResultType.Error, "Not Found!", "U_PT_04", StatusCodes.Status404NotFound));
                }
                else
                {
                    return(GenericResponse.Error(ResultType.Error, ex.Message, "U_PT_05", StatusCodes.Status500InternalServerError));
                }
            }
        }