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)); }
public string Post([FromBody] check value) { if (!_context.check.Any(user => user.checkId.Equals(value.checkId))) { check tblUser = new check(); // tblUser.checkId= value.checkId; tblUser.checkName = value.checkName; try { _context.Add(tblUser); _context.SaveChanges(); return(JsonConvert.SerializeObject("register succefully")); } catch (Exception ex) { return(JsonConvert.SerializeObject(ex.Message)); } } else { return(JsonConvert.SerializeObject("User is existing in database")); } }