public async Task <IActionResult> Create([Bind("Id,Name,EmailAddress,Mobile")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Description,Price")] LunchPack lunchPack)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lunchPack);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(lunchPack));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Mobile")] DeliveryAgent deliveryAgent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(deliveryAgent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(deliveryAgent));
        }
        public async Task <IActionResult> Create([Bind("Id,DeliveryAgentId,LunchPackId,CustomerId,NumberOfPacks,Address")] OnlineDelivery onlineDelivery)
        {
            if (ModelState.IsValid)
            {
                _context.Add(onlineDelivery);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"]      = new SelectList(_context.Customer, "Id", "Id", onlineDelivery.CustomerId);
            ViewData["DeliveryAgentId"] = new SelectList(_context.DeliveryAgent, "Id", "Id", onlineDelivery.DeliveryAgentId);
            ViewData["LunchPackId"]     = new SelectList(_context.LunchPack, "Id", "Id", onlineDelivery.LunchPackId);
            return(View(onlineDelivery));
        }