示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Seq")] MenuCategory menuCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(menuCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(menuCategory));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Phone,Url,ImageUrl")] Restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(restaurant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(restaurant));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,OrderId,MenuItemId,Qty,PriceName,Price,Note")] OrderItem orderItem)
        {
            if (id != orderItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderItemExists(orderItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MenuItemId"] = new SelectList(_context.MenuItems, "Id", "Name", orderItem.MenuItemId);
            ViewData["OrderId"]    = new SelectList(_context.Order, "Id", "Id", orderItem.OrderId);
            return(View(orderItem));
        }
示例#4
0
        public async Task <IActionResult> Create(Pickup newpickup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(newpickup);
                await _context.SaveChangesAsync();

                if (Request.Form["sendSlack"] == "on")
                {
                    var pickup = _repo.pickups.Get(newpickup.Id);
                    var msg    = string.Concat(pickup.PickupUser.NicknameOrUser, " is heading to ",
                                               pickup.Restaurant.Name, " at ", pickup.PickupTime.ToString("HH:mm tt"), ". Get your orders in!");
                    var success = await PostToSlack(newpickup.Id, "New Pickup", msg);
                }
                return(RedirectToAction(nameof(Details), new { id = newpickup.Id }));
            }
            LoadPickUpUserList(newpickup.PickupUserId);
            return(View(newpickup));
        }