예제 #1
0
        public async Task <PagingResponse> GetUsersWithPagingAsync(GetUsersReq getUsersReq)
        {
            try
            {
                int currentPage = getUsersReq.CurrentPage;
                int pageSize    = getUsersReq.PageSize;

                List <UserDetailVM> result = null;
                result = _uow.GetRepository <User>().GetAll()
                         .Select(u => new UserDetailVM {
                    FullName = u.FullName,
                    Email    = u.Email,
                    Phone    = u.Phone
                }).ToList();



                var resultPg = PagingHelper <UserDetailVM> .GetPagingList(result, currentPage, pageSize);

                await Task.FromResult(resultPg);

                return(resultPg);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.InnerException.Message.ToString());
                throw ex;
            }
        }
예제 #2
0
        /*
         * Get FilterPostsWithPagingAsync all category
         */
        public async Task <PagingResponse> FilterPostsWithPagingAsync(ReqFilterPost reqFilterPost)
        {
            try
            {
                int currentPage = reqFilterPost.CurrentPage;
                int pageSize    = reqFilterPost.PageSize;

                List <Post> result = null;
                result = _uow.GetRepository <Post>().GetAll();
                //var reports = _uow.GetRepository<Post>().GetAll(x =>
                //    x.Include(report => report.Category));

                //List<ObjectMedia> objectMedias = _uow.GetRepository<ObjectMedia>().GetAll();
                //List<Media> medias = _uow.GetRepository<Media>().GetAll();

                //var Privs = (
                //                from rpm in result
                //                 join urm in objectMedias on rpm.Id equals urm.ObjectId
                //                 join um in medias on urm.MediaId equals um.Id
                //                 select rpm.Name
                //             ).Distinct();


                var resultPg = PagingHelper <Post> .GetPagingList(result, currentPage, pageSize);

                await Task.FromResult(resultPg);

                List <ListPostDataVM> listPostDataVMs = new List <ListPostDataVM>();

                if (resultPg.Data != null)
                {
                    foreach (Post post in (List <Post>)resultPg.Data)
                    {
                        //Media media = _uow.GetRepository<ObjectMedia>().GetByFilter(o => o.ObjectId == post.Id)
                        //    .Join(_uow.GetRepository<Media>().GetAll(), o=>o.MediaId, m=>m.Id, (o, p) => new Media { }).FirstOrDefault();

                        Media media = (
                            from ob in _uow.GetRepository <ObjectMedia>().GetByFilter(o => o.ObjectId == post.Id)
                            join m in _uow.GetRepository <Media>().GetAll() on ob.MediaId equals m.Id
                            select new Media {
                            Name = m.Name, Path = m.Path
                        }
                            ).Distinct().FirstOrDefault();
                        ListPostDataVM listPostDataVM = new ListPostDataVM(post);
                        listPostDataVM.Media = media;
                        listPostDataVMs.Add(listPostDataVM);
                    }
                }
                resultPg.Data = listPostDataVMs;
                return(resultPg);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message.ToString());
                throw ex;
            }
        }
예제 #3
0
        // Get all media
        public async Task <PagingResponse> GetAllMedia()
        {
            try
            {
                List <Media>   result   = _uow.GetRepository <Media>().GetAll();
                PagingResponse resultPg = PagingHelper <Media> .GetPagingList(result, 1, 5);

                await Task.FromResult(resultPg);

                return(resultPg);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message.ToString());
                throw ex;
            }
        }
예제 #4
0
        public async Task <PagingResponse> FilterSimCardBy(ReqFilterSimCard reqFilterSimCard)
        {
            try
            {
                Logger.LogInformation("Begin filter simcard");
                string supplier = null;
                if (reqFilterSimCard.Supplier != null)
                {
                    supplier = reqFilterSimCard.Supplier.ToString();
                }
                int           minPrice      = reqFilterSimCard.MinPrice;
                int           maxPrice      = reqFilterSimCard.MaxPrice;
                int           currentPage   = reqFilterSimCard.CurrentPage;
                int           pageSize      = reqFilterSimCard.PageSize;
                string        firstNumbers  = reqFilterSimCard.FirstNumbers;
                string        endNumbers    = reqFilterSimCard.EndNumbers;
                List <string> exceptNumbers = reqFilterSimCard.ExceptNumbers;

                // Default get all supplier
                List <SimCard> result = null;
                if (supplier != null)
                {
                    result = this.GetFilterSimCardBySupplier(supplier);
                }
                else
                {
                    result = this.GetAll();
                }
                var resultPg = PagingHelper <SimCard> .GetPagingList(result, currentPage, pageSize);

                await Task.FromResult(resultPg);

                Logger.LogInformation("End filter simcard");

                return(resultPg);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message.ToString());
                throw ex;
            }
        }
예제 #5
0
        /*
         * Get FilterCategoryWithPagingAsync all category
         */
        public async Task <PagingResponse> FilterCategoryWithPagingAsync(ReqFilterCategory reqFilterCategory)
        {
            try
            {
                int currentPage = reqFilterCategory.CurrentPage;
                int pageSize    = reqFilterCategory.PageSize;

                List <Category> result = null;
                result = _uow.GetRepository <Category>().GetAll();

                var resultPg = PagingHelper <Category> .GetPagingList(result, currentPage, pageSize);

                await Task.FromResult(resultPg);

                return(resultPg);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message.ToString());
                throw ex;
            }
        }