public async Task <IActionResult> Edit(int id, [Bind("Id,BussinessName,BussinessAddress,BussinessPhoneNumber")] MGA mGA) { if (id != mGA.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mGA); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MGAExists(mGA.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(mGA)); }
public ActionResult Edit([Bind(Include = "Id,BusinessName,BusinessAddress,BusinessPhone")] MGA mGA) { if (ModelState.IsValid) { db.Entry(mGA).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mGA)); }
public async Task <IActionResult> Create([Bind("Id,BussinessName,BussinessAddress,BussinessPhoneNumber")] MGA mGA) { if (ModelState.IsValid) { _context.Add(mGA); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(mGA)); }
public ActionResult DeleteConfirmed(int id) { List <Contract> lstContract = db.Contract.Where(c => c.MGAId == id).ToList <Contract>(); db.Contract.RemoveRange(lstContract); MGA mGA = db.MGAs.Find(id); db.MGAs.Remove(mGA); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Mgas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MGA mGA = db.MGAs.Find(id); if (mGA == null) { return(HttpNotFound()); } return(View(mGA)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } MGA = await _context.MGA.FirstOrDefaultAsync(m => m.Id == id); if (MGA == null) { return(NotFound()); } return(Page()); }
public ActionResult Create([Bind(Include = "Id,BusinessName,BusinessAddress,BusinessPhone")] MGA mGA) { if (ModelState.IsValid) { int mgaId = (from m in db.MGAs orderby m.Id descending select m.Id).First(); mGA.Id = mgaId + 1; db.MGAs.Add(mGA); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mGA)); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } MGA = await _context.MGA.FindAsync(id); if (MGA != null) { _context.MGA.Remove(MGA); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }