Example #1
0
        public void AddNewCustomer(BalloonParty.Core.Models.Customer customer)
        {
            var newCustomer = Mapper.MapSQLCustomer(customer);

            _context.Add(newCustomer);
            Save();
        }
        public async Task <IActionResult> Create([Bind("CustomerEmail,OrderDate,FullProductCount,TotalPrice,CustomerOrderId,ProductName")] BalloonParty.DataAccess.SQLData.CustomerOrders customerOrders)
        {
            var prodPrices = _context.Products.ToList();

            if (ModelState.IsValid)
            {
                var cso = new BalloonParty.Core.Models.CustomerOrders
                {
                    CustomerEmail    = customerOrders.CustomerEmail,
                    OrderDate        = DateTime.Now,
                    FullProductCount = customerOrders.FullProductCount,
                    TotalPrice       = customerOrders.FullProductCount * prodPrices.SingleOrDefault(p => p.ProductName == customerOrders.ProductName).ProductPrice,
                    CustomerOrderId  = customerOrders.CustomerOrderId,
                    ProductName      = customerOrders.ProductName,
                };

                customerOrders = BalloonParty.DataAccess.Mapper.MapCustomerOrderCORE(cso);
                _context.Add(customerOrders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerEmail"] = new SelectList(_context.Customer, "EmailAddress", "EmailAddress", customerOrders.CustomerEmail);
            ViewData["ProductName"]   = new SelectList(_context.Products, "ProductName", "ProductName", customerOrders.ProductName);
            return(View(customerOrders));
        }
        public async Task <IActionResult> Create([Bind("ProductId,ProductName,ProductPrice")] Products products)
        {
            if (ModelState.IsValid)
            {
                _context.Add(products);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }
        public async Task <IActionResult> Create([Bind("StoreId,ProductId,ProductName,ProductCount,SinventoryId")] StoreInventory storeInventory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(storeInventory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductId", storeInventory.ProductId);
            ViewData["StoreId"]   = new SelectList(_context.Store, "StoreId", "StoreId", storeInventory.StoreId);
            return(View(storeInventory));
        }