public async Task <IActionResult> Create([Bind("NoonMealRecNo,InstitutionsName,TotalCenter,Completed,Pending,CreatedBy,CreatedDate,FinancialYear,PeriodCategory,Period")] NoonMealPdlForm2 noonMealPdlForm2) { using (var _context = new auditinternalContext()) { ViewBag.ListOfFinancialYear = _context.TblMasterFinancialyear.ToList(); ViewBag.ListOfPeriodCategory = _context.TblMasterPeriodCategory.ToList(); ViewBag.ListOfInstitutions = _context.TblMasterInstitutions.ToList(); } if (ModelState.IsValid) { _context.Add(noonMealPdlForm2); var result = await _context.SaveChangesAsync(); if (result == 1) { Result = "Saved"; ViewData["Msg"] = new MessageDTO { Message = "Dear User,<br/>Details Successfully Saved!!.", Status = "S", BackPageAction = "Index", BackPageController = "NoonMealForm2" }; } else { ViewData["Msg"] = new MessageDTO { Message = "Dear User,<br/><b>Some Error Ocurred Please try Later. if the problem persists contact your system administrator..", Status = "E", BackPageAction = "Index", BackPageController = "NoonMealForm2" }; } } return(View(noonMealPdlForm2)); }
public async Task <IActionResult> Edit(int id, [Bind("NoonMealRecNo,InstitutionsName,TotalCenter,Completed,Pending,CreatedBy,CreatedDate,FinancialYear,PeriodCategory,Period")] NoonMealPdlForm2 noonMealPdlForm2) { using (var _context = new auditinternalContext()) { ViewBag.ListOfFinancialYear = _context.TblMasterFinancialyear.ToList(); ViewBag.ListOfPeriodCategory = _context.TblMasterPeriodCategory.ToList(); ViewBag.ListOfInstitutions = _context.TblMasterInstitutions.ToList(); } if (id != noonMealPdlForm2.NoonMealRecNo) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(noonMealPdlForm2); var result = await _context.SaveChangesAsync(); if (result == 1) { Result = "Updated"; ViewData["Msg"] = new MessageDTO { Message = "Dear User,<br/>Details Successfully Updated!!.", Status = "S", BackPageAction = "Index", BackPageController = "NoonMealForm2" }; } else { ViewData["Msg"] = new MessageDTO { Message = "Dear User,<br/><b>Some Error Ocurred Please try Later. if the problem persists contact your system administrator..", Status = "E", BackPageAction = "Details", BackPageController = "NoonMealPdlForm1" }; } } catch (DbUpdateConcurrencyException) { if (!NoonMealPdlForm2Exists(noonMealPdlForm2.NoonMealRecNo)) { return(NotFound()); } else { throw; } } // return RedirectToAction(nameof(Index)); } return(View(noonMealPdlForm2)); }