public async Task <IActionResult> Edit(int id, [Bind("id,fooderNameNep,fooderNameEng,address,municipility,district,state,shortNote,cultivation,seedingMethod,seedHarvestingStorage,grassProduct,dm,cp,tdn,ndf,c,p,df,adl,tanni,nitrateScore,remarks,price")] feedFooder feedFooder) { if (id != feedFooder.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(feedFooder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!feedFooderExists(feedFooder.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(feedFooder)); }
public ActionResult AddEditStudent(int?id, feedFooder model) { try { if (ModelState.IsValid) { bool isNew = !id.HasValue; feedFooder feed = isNew ? new feedFooder { } : _repo.GetById(id.Value); feed = model; if (isNew) { _repo.Insert(feed); _repo.Save(); } else { _repo.Update(model); } } } catch (Exception ex) { throw ex; } return(RedirectToAction("Index")); }
public IActionResult DeleteFeed(int id) { feedFooder feed = _repo.GetById(id); _repo.Delete(id); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("id,fooderNameNep,fooderNameEng,address,municipility,district,state,shortNote,cultivation,seedingMethod,seedHarvestingStorage,grassProduct,dm,cp,tdn,ndf,c,p,df,adl,tanni,nitrateScore,remarks,price")] feedFooder feedFooder) { if (ModelState.IsValid) { _context.Add(feedFooder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(feedFooder)); }
public IActionResult AddEditStudent(int?id) { feedFooder model = new feedFooder(); if (id.HasValue) { feedFooder feed = _repo.GetById(id.Value); if (feed != null) { model = feed; } } return(View(model)); }