Exemplo n.º 1
0
        public async Task <ResultListDto> GetBranchesAsync(BranchFilterDto branchFilterDto)
        {
            if (branchFilterDto != null && branchFilterDto.UserBranchDto != null)
            {
                UserBranches userBranches = new UserBranches();
                userBranches = _mapper.Map <UserBranches>(branchFilterDto.UserBranchDto);
                if (branchFilterDto.Branches == null || branchFilterDto.Branches.Count == 0)
                {
                    branchFilterDto.Branches = await _branchService.GetBranchesForFiltersAsync(userBranches);
                }
            }
            var branchFilter = _mapper.Map <BranchFilter>(branchFilterDto);

            var branchList = await _branchService.GetBranchesAsync(branchFilter);

            var branchDtoList = _mapper.Map <IEnumerable <BranchDto> >(branchList.Results);

            ResultListDto finalResult = new ResultListDto()
            {
                MaxPageRows = branchList.MaxPageRows,
                TotalRows   = branchList.TotalRows,
                Results     = branchDtoList
            };

            return(finalResult);
        }
Exemplo n.º 2
0
        public async Task <ResultListDto> GetBranchesBaseOnRoleAsync(BranchFilterDto branchFilterDto)
        {
            List <int>    branchList    = new List <int>();
            ResultListDto resultListDto = new ResultListDto();

            var userRoles = await _userService.GetUserRolesAsync(branchFilterDto.UserBranchDto.BranchId, branchFilterDto.UserBranchDto.UserId);

            foreach (var item in userRoles)
            {
                if (item.RoleId == ConstRoles.Admin)
                {
                    var branchFilter = _mapper.Map <BranchFilter>(branchFilterDto);
                    var resultdto    = await _branchService.GetBranchesAsync(branchFilter);

                    resultListDto = _mapper.Map <ResultListDto>(resultdto);
                    return(resultListDto);
                }
                else if (item.RoleId == ConstRoles.User)
                {
                    var branches = await _branchService.GetUserBranches(branchFilterDto.UserBranchDto.UserId);

                    resultListDto.Results = branches;
                    return(resultListDto);
                }
                else if (item.RoleId == ConstRoles.SuperViser)
                {
                    var branch = await _branchService.GetBranchAsync(branchFilterDto.UserBranchDto.BranchId);

                    var zone = await _zoneService.GetZoneInfoByZoneIDAsync(branch.ZoneID);

                    resultListDto.Results = await _zoneService.GetProvinceBranchesByProvinceCode(zone.OSTANCode);

                    return(resultListDto);
                }
                //else if (item.RoleId == ConstRoles.Customer)
                //{
                //    //var customer = await _customerAppService.GetCustomerByUserIDAsync(branchFilterDto.UserBranchDto.UserId);
                //    //((DepositFilterDto)branchFilterDto).CustomerHeadSerial = customer.Serial;
                //}
                //else
                //{
                //    branchList.Add(branchFilterDto.UserBranchDto.BranchId);
                //    return branchList;
                //}
            }
            resultListDto.Results = await _branchService.GetBranchAsync(branchFilterDto.UserBranchDto.BranchId);

            resultListDto.ServerErrors = null;
            return(resultListDto);
        }
Exemplo n.º 3
0
        public async Task <ResultListDto> GetBranchListAsync(BranchFilterDto branchFilterDto)
        {
            var branchFilter = _mapper.Map <BranchFilter>(branchFilterDto);
            var branchList   = await _branchService.GetBranchListAsync(branchFilter);

            var           branchDtoList = _mapper.Map <IEnumerable <BranchDto> >(branchList.Results);
            ResultListDto finalResult   = new ResultListDto()
            {
                MaxPageRows = branchList.MaxPageRows,
                TotalRows   = branchList.TotalRows,
                Results     = branchDtoList
            };

            return(finalResult);
        }
Exemplo n.º 4
0
        public async Task <ResultListDto> GetBranchListAsync([FromBody] BranchFilterDto branchFilterDto = null)
        {
            ResultListDto branchListdto = await branchAppService.GetBranchListAsync(branchFilterDto);

            return(branchListdto);
        }