/// <summary>
        /// AddArtistRequest
        /// </summary>
        /// <returns></returns>
        public RespContainer <ApiResult <ItemResponse> > GetExamples()
        {
            List <ItemResponse> itemList = new List <ItemResponse>
            {
                new ItemResponse
                {
                    Id          = Guid.NewGuid(),
                    Name        = "DAMN.",
                    Description = "DAMN. by Kendrick Lamar",
                    LabelName   = "TDE, Top Dawg Entertainment",
                    Price       = new PriceResponse
                    {
                        Amount   = Convert.ToDecimal(34.5),
                        Currency = "EUR"
                    },
                    PictureUri     = "https://mycdn.com/pictures/45345345",
                    ReleaseDate    = DateTime.Parse("2016-01-01T00:00:00+00:00"),
                    Format         = "Vinyl 33g",
                    AvailableStock = 5,
                    GenreId        = Guid.Parse("673cc719-6443-4d06-f21e-08d806d69e5d"),
                    ArtistId       = Guid.Parse("95982efe-e0ff-4560-fc53-08d806d6ac61"),
                }
            };
            Task <ApiResult <ItemResponse> > pagedItemsTask = Task.Run(() => ApiResult <ItemResponse> .CreateAsync(itemList.AsQueryable(), 20, 10, "Name", "ASC"));

            return(RespContainer.Ok(pagedItemsTask.Result, string.Format(@"{0} Items found", itemList.Count())));
        }
 public async Task <ActionResult <ApiResult <StaffModel> > > GetAllAsync(int pageIndex       = 0,
                                                                         int pageSize        = 10,
                                                                         string sortColumn   = null,
                                                                         string sortOrder    = null,
                                                                         string filterColumn = null,
                                                                         string filterQuery  = null)
 {
     return(await ApiResult <StaffModel> .CreateAsync(
                _s.GetAll().Select(l =>
                                   new StaffModel
     {
         Id = l.Id,
         LastName = l.LastName,
         FirstName = l.FirstName,
         Mobile = l.Mobile,
         Email = l.Email,
         Active = l.Active,
         Title = l.Title,
         CanBook = l.CanBook,
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));;;
 }
 public async Task <ActionResult <ApiResult <AppointmentDto> > > GetAppointments(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <AppointmentDto> .CreateAsync(
                _context.Appointments
                .Select(a => new AppointmentDto()
     {
         AppointmentId = a.AppointmentId,
         Active = a.Active,
         Client = a.Client.FirstName + ' ' + a.Client.LastName,
         ClientPhone = a.Client.Phone,
         Location = a.Location.Name,
         Worker = a.Worker.FirstName + ' ' + a.Worker.LastName,
         Treatment = a.Treatment.Name,
         Date = a.Date,
         Hour = a.Hour,
         IsPaid = a.IsPaid
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
Example #4
0
        public async Task <ActionResult <ApiResult <Product> > > GetProducts(
            int pageIndex     = 0,
            int pageSize      = 10,
            string sortColumn = null,
            string sortOrder  = null,
            int categoryId    = 0)
        {
            try
            {
                IQueryable <Product> products = _context.Products;

                //제품 분류에 대한 검색이라면
                if (categoryId != 0)
                {
                    products = _context.Products
                               .FromSqlInterpolated(
                        $@"SELECT * FROM Products WHERE id IN 
    (SELECT ProductId FROM ProductCategories AS pc 
     INNER JOIN Categories AS c ON pc.CategoryId = c.Id WHERE c.Id = {categoryId})");
                }

                return(await ApiResult <Product> .CreateAsync(
                           GetProducts(products),
                           pageIndex,
                           pageSize,
                           sortColumn,
                           sortOrder,
                           null,
                           null));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
        public async Task <ApiResult <HateoasResponse <ItemResponse> > > Handle(GetAllItemsHateoasQuery request, CancellationToken cancellationToken)
        {
            IEnumerable <ItemResponse> itemList = await _itemService.GetItemsQuery().ToListAsync();

            List <HateoasResponse <ItemResponse> > hateoasResults = new List <HateoasResponse <ItemResponse> >();

            foreach (ItemResponse itemResponse in itemList)
            {
                HateoasResponse <ItemResponse> hateoasResult = new HateoasResponse <ItemResponse>
                {
                    Data = itemResponse
                };
                await _linksService.AddLinksAsync(hateoasResult);

                hateoasResults.Add(hateoasResult);
            }

            IQueryable <HateoasResponse <ItemResponse> > test = hateoasResults.AsQueryable();

            ApiResult <HateoasResponse <ItemResponse> > pagedItems = await ApiResult <HateoasResponse <ItemResponse> > .CreateAsync(
                test,
                request.Data.PageIndex,
                request.Data.PageSize,
                request.Data.SortColumn,
                request.Data.SortOrder,
                request.Data.FilterColumn,
                request.Data.FilterQuery);


            return(pagedItems);
        }
        public async Task <ActionResult <ApiResult <City> > > GetCities(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            //var cities = _context.Cities;

            //if(!String.IsNullOrEmpty(filterColumn)
            //    && !String.IsNullOrEmpty(filterQuery))
            //{
            //    cities = cities.Where(c => c.Name.Contains(filter))
            //}

            return(await ApiResult <City> .CreateAsync(
                       _context.Cities,
                       pageIndex,
                       pageSize,
                       sortColumn,
                       sortOrder,
                       filterColumn,
                       filterQuery));

            //return await _context.Cities
            //             .Skip(pageIndex * pageSize)
            //             .Take(pageSize)
            //             .ToListAsync();
        }
Example #7
0
 public async Task <ActionResult <ApiResult <LocationDto> > > GetCountries(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <LocationDto> .CreateAsync(
                _context.Locations
                .Select(l => new LocationDto()
     {
         LocationId = l.LocationId,
         Name = l.Name,
         Address = l.Address,
         City = l.City,
         CityCode = l.CityCode,
         ClientsCount = l.Clients.Count
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
 public async Task <ActionResult <ApiResult <ProductQuantityChangeDto> > > GetProductQuantityChange(int productId,
                                                                                                    int pageIndex       = 0,
                                                                                                    int pageSize        = 10,
                                                                                                    string sortColumn   = null,
                                                                                                    string sortOrder    = null,
                                                                                                    string filterColumn = null,
                                                                                                    string filterQuery  = null)
 {
     return(await ApiResult <ProductQuantityChangeDto> .CreateAsync(
                _context.ProductQuantityChanges
                .Where(x => x.Active && x.ProductId == productId)
                .Select(p => new ProductQuantityChangeDto()
     {
         ProductQuantityChangeId = p.ProductQuantityChangeId,
         Active = p.Active,
         IsPurchase = p.IsPurchase,
         QuantityChange = p.QuantityChange,
         Date = p.Date
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
Example #9
0
 public async Task <ActionResult <ApiResult <LocationListModel> > > GetLocations(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <LocationListModel> .CreateAsync(
                _s.GetAll().Select(l =>
                                   new LocationListModel
     {
         Id = l.Id,
         City = l.City,
         ContactName = l.ContactName,
         Description = l.Description,
         Phone = l.Phone,
         TotalAppt = l.Appointments.Count(),
         TotalClosed = l.ClosedDates.Count(),
         TotalMsgs = l.NotificationMessages.Count()
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
        public async Task <ActionResult <ApiResult <UserDto> > > Get(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            IQueryable <UserDto> users = _context.Users
                                         .Select(u => new UserDto
            {
                Id                   = u.Id,
                UserName             = u.UserName,
                Email                = u.Email,
                EmailConfirmed       = u.EmailConfirmed,
                PhoneNumber          = u.PhoneNumber,
                PhoneNumberConfirmed = u.PhoneNumberConfirmed,
                TwoFactorEnabled     = u.TwoFactorEnabled,
                LockoutEnd           = u.LockoutEnd,
                LockoutEnabled       = u.LockoutEnabled,
                AccessFailedCount    = u.AccessFailedCount
            });

            return(await ApiResult <UserDto>
                   .CreateAsync(
                       users,
                       pageIndex,
                       pageSize,
                       sortColumn,
                       sortOrder,
                       filterColumn,
                       filterQuery));
        }
Example #11
0
 public async Task <ActionResult <ApiResult <Product> > > GetProducts(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <Product> .CreateAsync(
                _context.Products
                .AsNoTracking()//읽기 전용으로 데이터 조회
                .Select(p => new Product
     {
         Id = p.Id,
         Name = p.Name,
         MakerName = p.Maker.Name,
         Tags = p.Tags,
         Price = p.Price,
         Discount = p.Discount,
         StockCount = p.StockCount,
         IsVisible = p.IsVisible,
         Categories =
             p.ProductCategories.Select(pc => pc.Category).ToList(),
         PhotoUrls =
             p.ProductImages.Select(pi => pi.PhotoUrl).ToList(),
         CreatedDate = p.CreatedDate,
         ModifiedDate = p.ModifiedDate
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
Example #12
0
        public async Task <IActionResult> GetCategoryProductsForCustomer(
            string storeId      = "b4d32aca-665d-4253-83a5-6f6a8b7acade",
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            var result = await ApiResult <CategoryProductDTO> .CreateAsync(
                _context.CategoryProducts
                .Where(c => c.StoreId == storeId)
                .Select(c => new CategoryProductDTO
            {
                CategoryName = c.CategoryName,
                Code         = c.Code,
                Slug         = c.Slug
            }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery

                );

            return(Ok(result));
        }
        public async Task <ActionResult <ApiResult <RoleDto> > > Get(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            IQueryable <RoleDto> Roles = _context.Roles
                                         .Select(r => new RoleDto
            {
                Id   = r.Id,
                Name = r.Name
            });

            return(await ApiResult <RoleDto>
                   .CreateAsync(
                       Roles,
                       pageIndex,
                       pageSize,
                       sortColumn,
                       sortOrder,
                       filterColumn,
                       filterQuery));
        }
Example #14
0
        public async Task <ActionResult <ApiResult <CityDTO> > > GetCities(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            var result = await ApiResult <CityDTO> .CreateAsync(
                _context.Cities
                .Select(c => new CityDTO()
            {
                Id          = c.Id,
                Name        = c.Name,
                Lat         = c.Lat,
                Lon         = c.Lon,
                CountryId   = c.CountryId,
                CountryName = c.Country.Name
            }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery);

            return(result);
        }
Example #15
0
 public async Task <ActionResult <ApiResult <EmployeeDTO> > > GetEmployees(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <EmployeeDTO> .CreateAsync(
                _context.Employees
                .Select(c => new EmployeeDTO()
     {
         Id = c.Id,
         EmpName = c.EmpName,
         Email = c.Email,
         Address = c.Address,
         DOB = c.DOB,
         CountryId = c.Country.Id,
         CountryName = c.Country.Name,
         DepartmentId = c.Department.Id,
         DepartmentName = c.Department.Name
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
Example #16
0
 public async Task <ActionResult <ApiResult <ClientDto> > > GetClients(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <ClientDto> .CreateAsync(
                _context.Clients
                .Select(c => new ClientDto()
     {
         ClientId = c.ClientId,
         Active = c.Active,
         Email = c.Email,
         FirstName = c.FirstName,
         LastName = c.LastName,
         Phone = c.Phone,
         DateOfBirth = c.DateOfBirth,
         AssignDate = c.AssignDate,
         Location = c.Location.Name,
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
Example #17
0
 public async Task <ActionResult <ApiResult <LessonDTO> > > GetLessons(int pageIndex       = 0,
                                                                       int pageSize        = 10,
                                                                       string sortColumn   = null,
                                                                       string sortOrder    = null,
                                                                       string filterColumn = null,
                                                                       string filterQuery  = null)
 {
     return(await ApiResult <LessonDTO> .CreateAsync(
                _context.Lessons.Select(lesson => new LessonDTO
     {
         Id = lesson.Id,
         Name = lesson.Name,
         AuditoryId = lesson.Auditory.Id,
         Auditory = lesson.Auditory.Name,
         TimetableId = lesson.Timetable.Id,
         StartTime = lesson.Timetable.StartTime,
         EndTime = lesson.Timetable.EndTime,
         WeeksTypeId = lesson.WeeksType.Id,
         WeeksType = lesson.WeeksType.Type,
         WeeksColor = lesson.WeeksType.Color,
         DaysWeekId = lesson.DaysWeek.Id,
         DaysWeek = lesson.DaysWeek.Day,
         LessonTypeId = lesson.LessonType.Id,
         LessonType = lesson.LessonType.Type
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
 public async Task <ActionResult <ApiResult <CityDTO> > > GetCities(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <CityDTO> .CreateAsync(
                _context.Cities.Select(e => new CityDTO
     {
         Id = e.Id,
         Name = e.Name,
         Name_ASCII = e.Name_ASCII,
         Lat = e.Lat,
         Lon = e.Lon,
         CountryId = e.Country.Id,
         CountryName = e.Country.Name
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
        public async Task <ActionResult <ApiResult <Case> > > GetCases(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null,
            int?pricemax        = null,
            int?pricemin        = null,
            int?gpuLengthMax    = null,
            int?gpuLengthMin    = null,
            int?volumeMin       = null,
            int?volumeMax       = null
            )
        {
            return(await ApiResult <Case> .CreateAsync(
                       context.Cases,
                       pageIndex,
                       pageSize,

                       pricemax,
                       pricemin,
                       gpuLengthMax,
                       gpuLengthMin,
                       volumeMin,
                       volumeMax,

                       sortColumn,
                       sortOrder,
                       filterColumn,
                       filterQuery
                       ));
        }
 public async Task <ActionResult <ApiResult <CountryDTO> > > GetCountries(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <CountryDTO> .CreateAsync(
                _context.Countries
                .Select(c => new CountryDTO()
     {
         Id = c.Id,
         Name = c.Name,
         ISO2 = c.ISO2,
         ISO3 = c.ISO3,
         TotCities = c.Cities.Count
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
        public async Task <ActionResult <ApiResult <ProductDto> > > GetProducts(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            var products = await _context.Products
                           .Select(p => new ProductDto()
            {
                ProductId = p.ProductId,
                Active    = p.Active,
                Name      = p.Name,
                //Quantity = _productQuantityChangeService.GetProductQuantity(p.ProductId, _context)
                Price = p.Price
            }).ToListAsync();

            foreach (var product in products)
            {
                var quantity = await _productQuantityChangeService.GetProductQuantity(product.ProductId, _context);

                product.Quantity = quantity;
            }
            return(await ApiResult <ProductDto> .CreateAsync(products.AsQueryable()
                                                             ,
                                                             pageIndex,
                                                             pageSize,
                                                             sortColumn,
                                                             sortOrder,
                                                             filterColumn,
                                                             filterQuery));
        }
Example #22
0
        public async Task <IActionResult> GetListProductsOfStoreWithCategoryForCustomer(
            string storeId          = "b4d32aca-665d-4253-83a5-6f6a8b7acade",
            string categoryIdOrCode = "ea76e2a8-873f-48bf-8ace-1415ee3758e8",
            int pageIndex           = 0,
            int pageSize            = 10,
            string sortColumn       = null,
            string sortOrder        = null,
            string filterColumn     = null,
            string filterQuery      = null)
        {
            var cat = await _context.CategoryProducts.FirstOrDefaultAsync(c => c.Id == categoryIdOrCode || c.Code == categoryIdOrCode);

            if (cat == null)
            {
                throw new ApiException("Category not found", (int)HttpStatusCode.BadRequest);
            }
            var query = _context.ProductSKUs
                        .Where(p => p.Product.StoreId == storeId && p.Product.CategoryId == cat.Id)
                        .Include(p => p.ProductSKUValues)
                        .ThenInclude(p => p.ProductOptionValue)
                        .ThenInclude(p => p.ProductOption)
                        .ThenInclude(p => p.Product)
                        .ThenInclude(p => p.ProductDetail)
                        .Select(p => new ProductItemDTO
            {
                ProductId            = p.ProductId,
                Price                = p.Price,
                ProductName          = p.Product.ProductName,
                Weight               = p.Product.Weight,
                Depth                = p.Product.Depth,
                Height               = p.Product.Height,
                UniversalProductCode = p.Product.UniversalProductCode,
                ImageHeightThumb     = p.Product.ProductDetail.ImageHeightThumb,
                ImageOrigin          = p.Product.ProductDetail.ImageOrigin,
                ImageThumb           = p.Product.ProductDetail.ImageThumb,
                ImageWidthThumb      = p.Product.ProductDetail.ImageWidthThumb,
                LongDescription      = p.Product.ProductDetail.LongDescription,
                NetWeight            = p.Product.NetWeight,
                Sku              = p.Sku,
                SkuId            = p.SkuId,
                ShortDescription = p.Product.ProductDetail.ShortDescription,
                OptionId         = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).OptionId,
                OptionName       = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).ProductOption.OptionName,
                ValueId          = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).ProductOptionValue.ValueId,
                ValueName        = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).ProductOptionValue.ValueName,
            });

            var result = await ApiResult <ProductItemDTO> .CreateAsync(
                query,
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery
                );


            return(Ok(result));
        }
 public async Task <ActionResult <ApiResult <TreatmentDto> > > GetTreatments(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <TreatmentDto> .CreateAsync(
                _context.Treatments
                .Select(c => new TreatmentDto()
     {
         TreatmentId = c.TreatmentId,
         Active = c.Active,
         Name = c.Name,
         ActiveFrom = c.ActiveFrom,
         ActiveTo = c.ActiveTo,
         Price = c.Price,
         Duration = c.Duration,
         ShortDescription = c.ShortDescription,
         Details = c.Details
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
Example #24
0
        public async Task <IActionResult> GetListStores(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            // check user logout
            await CheckIsSignoutedAsync();

            var result = await ApiResult <StoreItemDTO> .CreateAsync(
                _context.Stores
                .Where(c => c.StatusStore == (int)TypeStatusStore.Open)
                .Select(c => new StoreItemDTO()
            {
                Id           = c.Id,
                lat          = c.lat,
                lon          = c.lon,
                StatusStore  = c.StatusStore,
                StoreAddress = c.StoreAddress,
                StoreName    = c.StoreName,
                UpdatedAt    = c.UpdatedAt,
                CreatedAt    = c.CreatedAt
            }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery);

            return(Ok(result));
        }
Example #25
0
        public async Task <IActionResult> GetListCategoryStore(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            _logger.LogInformation("get category");

            var result = await ApiResult <CategoryStoreDTO> .CreateAsync(
                _context.CategoryStores.Select(c => new CategoryStoreDTO
            {
                Id   = c.Id,
                Name = c.Name
            }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery
                );

            return(Ok(result));
        }
Example #26
0
 public async Task <ActionResult <ApiResult <PlayerDTO> > > NewAll(
     int pageIndex       = 0,
     int pageSize        = 10,
     string sortColumn   = null,
     string sortOrder    = null,
     string filterColumn = null,
     string filterQuery  = null)
 {
     return(await ApiResult <PlayerDTO> .CreateAsync(
                DbContext.Players
                .Select(x => new PlayerDTO()
     {
         Id = x.Id,
         ImageUrl = x.ImageUrl,
         Name = x.Name,
         IsActive = x.IsActive,
         ShowUpCount = x.GameDetails.GroupBy(a => a.GameId).Count(),
         FirstGameDate = x.GameDetails.OrderBy(a => a.Game.CreatedDate).FirstOrDefault().Game.CreatedDate,
         LastGameDate = x.GameDetails.OrderByDescending(a => a.Game.CreatedDate).FirstOrDefault().Game.CreatedDate
     }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery));
 }
Example #27
0
 public async Task <ActionResult <ApiResult <City> > > GetCities(
     int pageIndex     = 0,
     int pageSize      = 10,
     string sortColumn = null,
     string sortOrder  = null)
 {
     return(await ApiResult <City> .CreateAsync(_context.Cities, pageIndex, pageSize, sortColumn, sortOrder));
 }
Example #28
0
        public async Task <IActionResult> GetProducts(
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            string messager = string.Empty;
            // get stores of user admin
            User user = await _context.Users.FindAsync(this.CurrentUserId);

            if (user == null)
            {
                messager = "Không tìm thấy user.";
                _logger.Log(LogLevel.Information, messager);
                throw new ApiException(messager, (int)HttpStatusCode.BadRequest);
            }
            Store store = await _context.Stores.FindAsync(user.StoreId);

            if (store == null)
            {
                messager = "Không tìm thấy store.";
                _logger.Log(LogLevel.Information, messager);
                throw new ApiException(messager, (int)HttpStatusCode.BadRequest);
            }

            var result = await ApiResult <ProductAdminDTO> .CreateAsync(
                _context.Products
                .Where(p => p.StoreId == store.Id)
                .Select(p => new ProductAdminDTO
            {
                Id                   = p.Id,
                CategoryId           = p.CategoryId,
                CreateByUserId       = p.CreateByUserId,
                CreateOn             = p.CreateOn,
                UpdateOn             = p.UpdateOn,
                DeleteOn             = p.DeleteOn,
                Depth                = p.Depth,
                Height               = p.Height,
                NetWeight            = p.NetWeight,
                Weight               = p.Weight,
                UniversalProductCode = p.UniversalProductCode,
                ProductName          = p.ProductName,
            }),
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery
                );

            return(Ok(result));
        }
Example #29
0
        public async Task <IActionResult> GetListProductsOfStoreForCustomer(
            string storeId      = "b4d32aca-665d-4253-83a5-6f6a8b7acade",
            int pageIndex       = 0,
            int pageSize        = 10,
            string sortColumn   = null,
            string sortOrder    = null,
            string filterColumn = null,
            string filterQuery  = null)
        {
            var query = _context.ProductSKUs
                        .Where(p => p.Product.StoreId == storeId)
                        .Include(p => p.ProductSKUValues)
                        .ThenInclude(p => p.ProductOptionValue)
                        .ThenInclude(p => p.ProductOption)
                        .ThenInclude(p => p.Product)
                        .ThenInclude(p => p.ProductDetail)
                        .Select(p => new ProductItemDTO
            {
                ProductId            = p.ProductId,
                Price                = p.Price,
                ProductName          = p.Product.ProductName,
                Weight               = p.Product.Weight,
                Depth                = p.Product.Depth,
                Height               = p.Product.Height,
                UniversalProductCode = p.Product.UniversalProductCode,
                ImageHeightThumb     = p.Product.ProductDetail.ImageHeightThumb,
                ImageOrigin          = p.Product.ProductDetail.ImageOrigin,
                ImageThumb           = p.Product.ProductDetail.ImageThumb,
                ImageWidthThumb      = p.Product.ProductDetail.ImageWidthThumb,
                LongDescription      = p.Product.ProductDetail.LongDescription,
                NetWeight            = p.Product.NetWeight,
                Sku              = p.Sku,
                SkuId            = p.SkuId,
                ShortDescription = p.Product.ProductDetail.ShortDescription,
                OptionId         = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).OptionId,
                OptionName       = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).ProductOption.OptionName,
                ValueId          = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).ProductOptionValue.ValueId,
                ValueName        = p.ProductSKUValues.FirstOrDefault(x => x.SkuId == p.SkuId).ProductOptionValue.ValueName,
            });

            var result = await ApiResult <ProductItemDTO> .CreateAsync(
                query,
                pageIndex,
                pageSize,
                sortColumn,
                sortOrder,
                filterColumn,
                filterQuery
                );


            return(Ok(result));
        }
Example #30
0
        public async Task <ActionResult <ApiResult <City> > > GetCities(int pageIndex = 0, int pageSize = 10, string sortColumn = null, string sortOrder = null, string filterColumn = null, string filterQuery = null)
        {
            // first we perform filtering
            IQueryable <City> cities = _context.Cities;

            if (!string.IsNullOrEmpty(filterColumn) && !string.IsNullOrEmpty(filterQuery))
            {
                cities = cities.Where(c => c.Name.Contains(filterQuery));
            }

            return(await ApiResult <City> .CreateAsync(cities, pageIndex, pageSize, sortColumn, sortOrder));
        }