// // GET: DelegationCategory/Edit/5 public IActionResult Edit(int id) { try { if (_dbContext.DelegationCategory.Any(d => d.Id == id)) { DelegationCategory delegationCategory = _dbContext.DelegationCategory.Where(d => d.Id == id).First(); return(View(delegationCategory)); } } catch { } return(View("Error")); }
// // GET: DelegationCategory/Delete/5 public IActionResult Delete(int id) { try { if (_dbContext.DelegationCategory.Any(d => d.Id == id)) { DelegationCategory delegationCategory = _dbContext.DelegationCategory.Where(d => d.Id == id).First(); _dbContext.DelegationCategory.Remove(delegationCategory); _dbContext.SaveChanges(); return(RedirectToAction("Index")); } } catch { } return(View("Error")); }
public IActionResult Edit(int id, DelegationCategory model) { try { if (_dbContext.DelegationCategory.Any(d => d.Id == id)) { DelegationCategory delegationCategory = _dbContext.DelegationCategory.Where(d => d.Id == id).First(); delegationCategory.Name = model.Name; _dbContext.DelegationCategory.Update(delegationCategory); _dbContext.SaveChanges(); return(RedirectToAction("Index")); } } catch { } return(View("Error")); }
public IActionResult Create(DelegationCategory model) { if (model == null) { return(View("Error")); } try { _dbContext.DelegationCategory.Add(new DelegationCategory() { Name = model.Name }); _dbContext.SaveChanges(); return(RedirectToAction("Index")); } catch { } return(View("Error")); }