Пример #1
0
        public IActionResult CreateFood(Foodviewmode food)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = Photopathfood(food);

                myfoods newfood = new myfoods
                {
                    myfoodsName  = food.foodName,
                    foodCalories = food.foodCalories,
                    photopath    = uniqueFileName,
                    Price        = food.price,
                    photopath11  = "jjjjj"
                };

                //if (Image != null)
                _Context.Add(newfood);



                _Context.SaveChanges();
                return(RedirectToAction(nameof(FoodList)));
            }

            return(View(food));
        }
Пример #2
0
        public async Task <IActionResult> Putmyfoods(int id, myfoods myfoods)
        {
            if (id != myfoods.myfoodsId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }