public async Task <ActionResult <FoodSet> > PostFoodSet(FoodSet foodSet) { _context.FoodSet.Add(foodSet); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFoodSet", new { id = foodSet.FoodSetID }, foodSet)); }
public async Task <IActionResult> PutFoodSet(int id, FoodSet foodSet) { if (id != foodSet.FoodSetID) { return(BadRequest()); } _context.Entry(foodSet).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodSetExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { Debug = 0; var check = 0; if (Canteen.Name == null) { check = 1; ModelState.AddModelError("Canteen.Name", "The NameCar field is required."); } if (Canteen.Email == null) { check = 1; ModelState.AddModelError("Canteen.Email", "The Seat field is required."); } if (Canteen.Line == null) { check = 1; ModelState.AddModelError("Canteen.Line", "The Line field is required."); } if (Canteen.Call == null) { check = 1; ModelState.AddModelError("Canteen.Call", "The Call field is required."); } if (check == 1) { Debug = 1; await Lode(); return(Page()); } _context.Canteen.Add(Canteen); await _context.SaveChangesAsync(); var foodset = new FoodSet(); foodset.FoodSetcoManul = "No"; foodset.NameSet = "No"; foodset.Price = 0; foodset.Status = "Open"; foodset.Canteen_CanteenID = Canteen.CanteenID; _context.FoodSet.Add(foodset); await _context.SaveChangesAsync(); return(RedirectToPage("./ManageCanteen")); }
public async Task <IActionResult> OnGetAsync(int?id) { Employee = HttpContext.Session.GetLogin(_context.Employee); if (id == null) { return(NotFound()); } FoodSet = await _context.FoodSet .Include(f => f.Canteen).FirstOrDefaultAsync(m => m.FoodSetID == id); if (FoodSet == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { Employee = HttpContext.Session.GetLogin(_context.Employee); if (id == null) { return(NotFound()); } FoodSet = await _context.FoodSet.FindAsync(id); if (FoodSet != null) { _context.FoodSet.Remove(FoodSet); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }