Example #1
0
        public async Task <IActionResult> Create([Bind("BrandId,BrandName")] Brands brands)
        {
            if (ModelState.IsValid)
            {
                _context.Brands.Add(brands);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brands));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("CategoryId,CategoryName")] Categories categories)
        {
            if (ModelState.IsValid)
            {
                _context.Categories.Add(categories);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categories));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("CurrencyId,CurrencyUnit,CreatedDate")] Currency currency)
        {
            if (ModelState.IsValid)
            {
                _context.Currencies.Add(currency);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(currency));
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("StoreId,ProductId,Quantity")] Stocks stocks)
        {
            if (ModelState.IsValid)
            {
                _context.Stocks.Add(stocks);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", stocks.ProductId);
            ViewData["StoreId"]   = new SelectList(_context.Stores, "StoreId", "StoreName", stocks.StoreId);
            return(View(stocks));
        }
Example #5
0
        public async Task <IActionResult> Create(ProductCreationalViewModel products)
        {
            if (ModelState.IsValid)
            {
                //Create new price for new product
                products.Price.CreatedDate = DateTime.Today;
                products.Price.Description = $"New Price From Product: {products.Product.ProductName}";
                _context.Prices.Add(products.Price);
                await _context.SaveChangesAsync();

                //Add new product
                products.Product.PriceId = products.Price.PriceId;
                _context.Products.Add(products.Product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"]    = new SelectList(_context.Brands, "BrandId", "BrandName", products.Product.BrandId);
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryName", products.Product.CategoryId);
            ViewData["Currencies"] = new SelectList(_context.Currencies, "CurrencyId", "CurrencyUnit", products.Price.CurrencyId);
            return(View(products));
        }