public async Task <ActionResult <Foodprice> > PostFoodprice(Foodprice foodprice)
        {
            _context.Foodprices.Add(foodprice);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFoodprice", new { id = foodprice.FoodId }, foodprice));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("FoodId,FoodName,FPrice,PictureUrl")] Foodprice foodprice)
        {
            if (id != foodprice.FoodId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(foodprice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FoodpriceExists(foodprice.FoodId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(foodprice));
        }
        public async Task <IActionResult> PutFoodprice(int id, Foodprice foodprice)
        {
            if (id != foodprice.FoodId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("FoodId,FoodName,FPrice,PictureUrl")] Foodprice foodprice)
        {
            if (ModelState.IsValid)
            {
                _context.Add(foodprice);
                await _context.SaveChangesAsync();

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