예제 #1
0
        public async Task <List <Catalog> > GetCatatolgListByUserId(WarehouseCatalogFiltrationByType catalogFiltrator)
        {
            var basket = await DB.Baskets.FirstOrDefaultAsync(x => x.UserId == catalogFiltrator.UserId);

            // Getting catalog list with a specifick warehouse id
            var catalogs = await DB.CatalogDB.Include(x => x.Name).Where(x => x.BasketId == basket.Id && x.Name.CatalogTypeId == catalogFiltrator.CatalogTypeId).ToListAsync();

            // Checking if it's not null
            if (catalogs == null)
            {
                // If it's null, then we will throw new exception
                throw new Exception("Not found");
            }
            // If object was found, then we return it
            else
            {
                return(catalogs);
            }
        }
예제 #2
0
        public async Task <List <Catalog> > GetCatatolgListByWarehouseId(WarehouseCatalogFiltrationByType catalogFiltrater)
        {
            // Getting catalog list with a specifick warehouse id
            var catalog = await DB.CatalogDB
                          .Include(x => x.Name)
                          .Where(x => x.WarehouseId == catalogFiltrater.WarehouseId && x.Name.CatalogTypeId == catalogFiltrater.CatalogTypeId)
                          .ToListAsync();

            // Checking if it's not null
            if (catalog == null)
            {
                // If it's null, then we will throw new exception
                throw new Exception("Not found");
            }
            // If object was found, then we return it
            else
            {
                return(catalog);
            }
        }
예제 #3
0
        public async Task <ActionResult> GetCatalogByWarehouseId([FromBody] WarehouseCatalogFiltrationByType catalogFiltrater)
        {
            // Getting Catalog by id
            var catalogsList = await CatalogService.GetCatatolgListByWarehouseId(catalogFiltrater);

            List <CatalogVM> catalogListVM = new List <CatalogVM>();

            catalogsList.ForEach(x => {
                var catalogVM = new CatalogVM
                {
                    Id            = x.Id,
                    ProductPrice  = x.ProductPrice,
                    CurrentAmount = x.CurrentAmount,
                    MaximumAmount = x.MaximumAmount,
                    MinimumAmount = x.MinimumAmount,
                    WarehouseId   = x.WarehouseId,
                    Name          = x.Name.Name,
                };

                catalogListVM.Add(catalogVM);
            });
            // Returning Catalog
            return(Ok(catalogListVM));
        }