Ejemplo n.º 1
0
        public async Task <UsersManagementDto> getUsersManagement(GridInitialDto gridInitialDto)
        {
            if (gridInitialDto.pageNo < 1)
            {
                gridInitialDto.pageNo = 1;
            }

            IQueryable <User> oUsers = _Users.AsQueryable().Where(x => x.companyId == gridInitialDto.companyId);

            if (!string.IsNullOrEmpty(gridInitialDto.filter))
            {
                oUsers = oUsers.Where(x => x.username.Contains(gridInitialDto.filter) == true &&
                                      x.fullName.Contains(gridInitialDto.filter) == true
                                      // &&  x.isItemAdmin.getDataAdminText().Contains(filter) == true &&
                                      //&& x.isReal.getRealLegalText().Contains(filter) == true
                                      // x.isActive.getIsActiveText().Contains(filter) == true
                                      );
            }


            int intTotalRecordCount = await oUsers.AsNoTracking().CountAsync();

            var oUsersManagementDto = new UsersManagementDto();

            if (intTotalRecordCount != 0)
            {
                int intTotalPages = (int)Math.Ceiling((double)intTotalRecordCount / gridInitialDto.recordCountPerPage);
                if (gridInitialDto.pageNo > intTotalPages)
                {
                    gridInitialDto.pageNo = intTotalPages;
                }


                foreach (var oUser in await oUsers.GetPageRecords(gridInitialDto.pageNo, gridInitialDto.recordCountPerPage).ToListAsync())
                {
                    var oUserDto = new UserDto
                    {
                        id              = oUser.id,
                        fullName        = oUser.fullName,
                        username        = oUser.username,
                        isItemAdminText = oUser.isItemAdmin == true ? "Yes" : "No",
                        isDataAdminText = oUser.isDataAdmin == true ? "Yes" : "No",
                        isActiveText    = oUser.isActive == true ? "Yes" : "No",
                    };


                    oUsersManagementDto.usersDto.Add(oUserDto);
                }

                oUsersManagementDto.currentPage      = gridInitialDto.pageNo;
                oUsersManagementDto.totalRecordCount = intTotalRecordCount;
            }
            return(oUsersManagementDto);
        }
Ejemplo n.º 2
0
        public async Task <AccessgroupsManagementDto> getAccessgroupsManagement(GridInitialDto gridInitialDto)
        {
            if (gridInitialDto.pageNo < 1)
            {
                gridInitialDto.pageNo = 1;
            }

            var oAccessgroupsManagementDto = new AccessgroupsManagementDto();

            var lnqAccessgroup = _Accessgroups
                                 .Where(current =>
                                        current.ownerCompanyId == gridInitialDto.companyId
                                        )
            ;

            if (!string.IsNullOrEmpty(gridInitialDto.filter))
            {
                lnqAccessgroup = lnqAccessgroup
                                 .Where(current =>
                                        current.groupName.Contains(gridInitialDto.filter) == true
                                        )
                ;
            }

            var intTotalRecordCount = await lnqAccessgroup.AsNoTracking().CountAsync();

            if (intTotalRecordCount != 0)
            {
                int intTotalPages = (int)Math.Ceiling((double)intTotalRecordCount / gridInitialDto.recordCountPerPage);
                if (gridInitialDto.pageNo > intTotalPages)
                {
                    gridInitialDto.pageNo = intTotalPages;
                }

                oAccessgroupsManagementDto.accessgroupsDto = Mapper.Map <IEnumerable <Accessgroup>, List <AccessgroupDto> >(await lnqAccessgroup.GetPageRecords(gridInitialDto.pageNo, gridInitialDto.recordCountPerPage).ToListAsync());

                ///Previouse Code
                //foreach (var itmAccessgroup in lnqAccessgroup)
                //{
                //    var oAccessgroup = new Dto.AccessgroupDto();
                //    oAccessgroup.groupName = itmAccessgroup.groupName;
                //    oAccessgroup.id = itmAccessgroup.id;
                //    oAccessgroupsManagementDto.accessgroupsDto.Add(oAccessgroup);
                //}

                oAccessgroupsManagementDto.currentPage      = gridInitialDto.pageNo;
                oAccessgroupsManagementDto.totalRecordCount = intTotalRecordCount;
            }

            return(oAccessgroupsManagementDto);
        }
Ejemplo n.º 3
0
        public async Task <AccessgroupsManagementDto> getAccessgroupsManagement(int pageNo, string filter)
        {
            if (Setting.payloadDto.isItemAdmin == false)
            {
                return(null);
            }

            GridInitialDto gridInitialDto = new GridInitialDto {
                recordCountPerPage = Setting.RECORD_COUNT_PAGE, pageNo = pageNo, filter = filter,
                userId             = Setting.payloadDto.userId, companyId = Setting.payloadDto.companyId
            };

            return(await _AccessgroupService.getAccessgroupsManagement(gridInitialDto));
        }
Ejemplo n.º 4
0
        public async Task <GetCustomersManagementDto> getCustomersManagement(GridInitialDto gridInitialDto)
        {
            int pageNo = gridInitialDto.pageNo;

            if (gridInitialDto.pageNo < 1)
            {
                pageNo = 1;
            }

            IQueryable <Customer> oCustomers = _Customers.AsQueryable();

            if (!string.IsNullOrEmpty(gridInitialDto.filter))
            {
                oCustomers = oCustomers
                             .Where(w => w.fullName.Contains(gridInitialDto.filter) == true);
            }

            int totalRecordCount = await oCustomers.AsNoTracking().CountAsync();

            GetCustomersManagementDto oGetCustomersManagementDto = new GetCustomersManagementDto();

            if (totalRecordCount != 0)
            {
                int totalPages = (int)Math.Ceiling((double)totalRecordCount / gridInitialDto.recordCountPerPage);

                if (pageNo > totalPages)
                {
                    pageNo = totalPages;
                }


                oGetCustomersManagementDto.getCustomersDto = Mapper.Map <IEnumerable <Customer>, List <GetCustomersDto> >
                                                                 (await oCustomers.GetPageRecords(pageNo, gridInitialDto.recordCountPerPage).ToListAsync());

                oGetCustomersManagementDto.currentPage      = pageNo;
                oGetCustomersManagementDto.totalRecordCount = totalRecordCount;
            }

            return(oGetCustomersManagementDto);
        }
Ejemplo n.º 5
0
        public async Task <GetNegotiationsManagementDto> getNegotiationsManagement(GridInitialDto gridInitialDto)
        {
            if (gridInitialDto.pageNo < 1)
            {
                gridInitialDto.pageNo = 1;
            }


            var oNegotiationsManagementDto = new GetNegotiationsManagementDto();


            IQueryable <Negotiation> oNegotiations = _Negotiations.Include(r => r.placeofDeliveryLocation)
                                                     .Include(r => r.placeofReceiptLocation)
                                                     .Include(i => i.currency).Include(i => i.contractor);

            if (!string.IsNullOrEmpty(gridInitialDto.filter))
            {
                oNegotiations = oNegotiations
                                .Where(w => w.referenceNo.Contains(gridInitialDto.filter) == true);
            }

            int totalRecordCount = await oNegotiations.AsNoTracking().CountAsync();

            if (totalRecordCount != 0)
            {
                int totalPages = (int)Math.Ceiling((double)totalRecordCount / gridInitialDto.recordCountPerPage);
                if (gridInitialDto.pageNo > totalPages)
                {
                    gridInitialDto.pageNo = totalPages;
                }

                var intFrom = (gridInitialDto.pageNo - 1) * gridInitialDto.recordCountPerPage;
                oNegotiationsManagementDto.getOutNegotiationsDto = Mapper.Map <IEnumerable <Negotiation>, List <GetNegotiationsDto> >(await oNegotiations.GetPageRecords(gridInitialDto.pageNo, gridInitialDto.recordCountPerPage).ToListAsync());

                oNegotiationsManagementDto.currentPage      = gridInitialDto.pageNo;
                oNegotiationsManagementDto.totalRecordCount = totalRecordCount;
            }

            return(oNegotiationsManagementDto);
        }
Ejemplo n.º 6
0
        public async Task <GetLocationsManagementDto> getLocationsManagement(GridInitialDto gridInitialDto)
        {
            if (gridInitialDto.pageNo < 1)
            {
                gridInitialDto.pageNo = 1;
            }


            var oLocationsManagementDto = new GetLocationsManagementDto();


            IQueryable <Location> oLocations = _Locations.Include(r => r.country);

            if (!string.IsNullOrEmpty(gridInitialDto.filter))
            {
                oLocations = oLocations
                             .Where(w => w.locationName.Contains(gridInitialDto.filter) == true);
            }

            int totalRecordCount = await oLocations.AsNoTracking().CountAsync();

            if (totalRecordCount != 0)
            {
                int totalPages = (int)Math.Ceiling((double)totalRecordCount / gridInitialDto.recordCountPerPage);
                if (gridInitialDto.pageNo > totalPages)
                {
                    gridInitialDto.pageNo = totalPages;
                }

                var intFrom = (gridInitialDto.pageNo - 1) * gridInitialDto.recordCountPerPage;
                oLocationsManagementDto.getLocationsDto = Mapper.Map <IEnumerable <Location>, List <GetLocationsDto> >(await oLocations.GetPageRecords(gridInitialDto.pageNo, gridInitialDto.recordCountPerPage).ToListAsync());

                oLocationsManagementDto.currentPage      = gridInitialDto.pageNo;
                oLocationsManagementDto.totalRecordCount = totalRecordCount;
            }

            return(oLocationsManagementDto);
        }