public async Task <ActionResult <InventoryDetails> > PostInventoryDetails(InventoryDetails inventoryDetails)
        {
            _context.Inventory_Details.Add(inventoryDetails);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetInventoryDetails", new { id = inventoryDetails.ID }, inventoryDetails));
        }
        public async Task <IActionResult> Index()
        {
            ProductsViewModel vm = new ProductsViewModel();

            vm.Products = new List <InventoryDetails>();

            var products = await _context.Products.Distinct().OrderByDescending(d => d.DateAdded).Take(4).ToListAsync();

            if (products != null)
            {
                foreach (var product in products)
                {
                    var category =
                        await _context.Categories.FirstOrDefaultAsync(c => c.CategoryID == product.CategoryID);

                    var details = new InventoryDetails
                    {
                        Product  = product,
                        Category = category
                    };
                    vm.Products.Add(details);
                }

                return(View(vm));
            }

            return(View());
        }
Example #3
0
        static string BuildInventoryUpdateFeed()
        {
            var details = new InventoryDetails();

            details.sellingParty = new InventoryModel.SellingParty()
            {
                partyId = "your_vendor_id"
            };
            details.isFullUpdate = false;

            var update = new InventoryUpdate();

            update.inventory = details;

            var list = new List <InventoryItem>();
            var item = new InventoryItem();

            item.buyerProductIdentifier  = "buyer_item";
            item.vendorProductIdentifier = "vendor_item";
            item.isObsolete = false;

            var available = new Available();

            available.amount        = 345;
            available.unitOfMeasure = "Each";

            item.availableQuantity = available;

            list.Add(item);

            details.items = list;

            return(JsonConvert.SerializeObject(update, Formatting.Indented));
        }
        public async Task <IActionResult> PutInventoryDetails(int id, InventoryDetails inventoryDetails)
        {
            if (id != inventoryDetails.ID)
            {
                return(BadRequest());
            }

            _context.Entry(inventoryDetails).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InventoryDetailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Index(string productName, string categoryFilter)
        {
            ProductsViewModel vm = new ProductsViewModel();

            vm.Products = new List <InventoryDetails>();
            var products   = _context.Products.Where(pd => pd.IsArchived == false);
            var categories = await _context.Categories.ToListAsync();

            vm.Categories = new List <Category>();
            vm.Categories = categories;

            var productList = await _context.Products.Where(pd => pd.IsArchived == false).ToListAsync();

            if (productList != null)
            {
                foreach (var p in productList)
                {
                    var category = await _context.Categories.FirstOrDefaultAsync(c => c.CategoryID == p.CategoryID);

                    var details = new InventoryDetails
                    {
                        Category = category,
                        Product  = p
                    };
                    vm.Products.Add(details);
                }

                return(View(vm));
            }

            return(NotFound());
        }
Example #6
0
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            InventoryDetails = await _context.InventoryDetails
                               .Include(i => i.MerchantDetails).FirstOrDefaultAsync(m => m.ItemId == id);

            if (InventoryDetails == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #7
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            InventoryDetails = await _context.InventoryDetails.FindAsync(id);

            if (InventoryDetails != null)
            {
                _context.InventoryDetails.Remove(InventoryDetails);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            InventoryDetails = await _context.InventoryDetails
                               .Include(i => i.MerchantDetails).FirstOrDefaultAsync(m => m.ItemId == id);

            if (InventoryDetails == null)
            {
                return(NotFound());
            }
            ViewData["Merchants"] = new SelectList(_context.MerchantDetails, "MerchantId", "MerchantName");
            return(Page());
        }
Example #9
0
 private void addTable(InventoryDetails inv, int quantity = 1, decimal discount = 0)
 {
     cart.Rows.Add(
         inv.Id,
         false,
         inv.Barcode,
         inv.Serial,
         inv.Name,
         inv.Supplier,
         quantity,
         inv.Price,
         // string.Format("₱ {0:n}", inv.Product.Item.SellingPrice),
         discount,
         // string.Format("₱ {0:n}", 0),
         quantity * (inv.Price - discount)
         //string.Format("₱ {0:n}", inv.Product.Item.SellingPrice)
         );
 }
Example #10
0
        // GET: Inventories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Inventory           inventory = db.Inventories.Include(m => m.Files).First(m => m.Id == id);
            IEnumerable <Files> files     = inventory.Files;

            InventoryDetails invDetails = new InventoryDetails {
                Inventory = inventory, Files = files.ToList()
            };

            if (inventory == null)
            {
                return(HttpNotFound());
            }
            return(View(invDetails));
        }
        public async Task <IActionResult> Index(ProductsViewModel model)
        {
            ProductsViewModel vm = new ProductsViewModel();

            vm.Products = new List <InventoryDetails>();
            var products   = _context.Products.Where(pd => pd.IsArchived == false);
            var categories = await _context.Categories.ToListAsync();

            vm.Categories       = new List <Category>();
            vm.Categories       = categories;
            vm.SearchQuery      = model.SearchQuery;
            vm.SelectedCategory = model.SelectedCategory;
            if (!String.IsNullOrEmpty(model.SearchQuery) && !String.IsNullOrEmpty(model.SelectedCategory))
            {
                var selectedCategory = await _context.Categories.FirstOrDefaultAsync(c => c.CategoryName == model.SelectedCategory);

                products = products.Where(p =>
                                          p.ProductName.Contains(model.SearchQuery) && p.CategoryID == selectedCategory.CategoryID);
                ViewData["SearchResult"] = "Showing " + await products.CountAsync() + " results for \"" +
                                           model.SearchQuery + "\" under " + selectedCategory.CategoryName;

                foreach (var pd in products)
                {
                    var category = await _context.Categories.FirstOrDefaultAsync(c => c.CategoryID == pd.CategoryID);

                    var details = new InventoryDetails
                    {
                        Category = category,
                        Product  = pd
                    };
                    vm.Products.Add(details);
                }


                return(View(vm));
            }
            if (!String.IsNullOrEmpty(model.SearchQuery))
            {
                products = products.Where(p => p.ProductName.Contains(model.SearchQuery));
                ViewData["SearchResult"] = "Showing " + await products.CountAsync() + " results for \"" +
                                           model.SearchQuery + "\"";

                foreach (var pd in products)
                {
                    var category = await _context.Categories.FirstOrDefaultAsync(c => c.CategoryID == pd.CategoryID);

                    var details = new InventoryDetails
                    {
                        Category = category,
                        Product  = pd
                    };
                    vm.Products.Add(details);
                }


                return(View(vm));
            }


            if (!String.IsNullOrEmpty(model.SelectedCategory))
            {
                var selectedCategory = await _context.Categories.FirstOrDefaultAsync(c => c.CategoryName == model.SelectedCategory);

                products = products.Where(p => p.CategoryID == selectedCategory.CategoryID);

                foreach (var p in products)
                {
                    var category = await _context.Categories.FirstOrDefaultAsync(c => c.CategoryID == p.CategoryID);

                    var details = new InventoryDetails
                    {
                        Category = category,
                        Product  = p
                    };
                    vm.Products.Add(details);
                }

                vm.SelectedCategory = selectedCategory.CategoryName;

                return(View(vm));
            }

            return(RedirectToAction(nameof(Index)));
        }