private bool rowStat(TblQnr item) { if (item == null || item.StatusId == 3) { return(false); } return(true); }
public async Task <IActionResult> Edit(int id, [Bind("Qnrid,FacilityId,Highlights,Implementer,IpdsamAdmissionsTrend,IpdsamPerformanceTrend,Iycf,Micronutrients,OpdmamAdmissionsTrend,OpdmamPerformanceTrend,OpdsamAdmissionsTrend,OpdsamPerformanceTrend,ReportMonth,ReportYear")] TblQnr item) { var qnr = await _context.TblQnr.SingleOrDefaultAsync(m => m.Qnrid == id); if (rowStat(qnr) == false || qnr.UserName != User.Identity.Name) { return(NotFound()); } if (ModelState.IsValid) { try { qnr.UpdateDate = DateTime.Now; qnr.UserName = User.Identity.Name; qnr.StatusId = 2; qnr.ReportMonth = item.ReportMonth; qnr.ReportYear = item.ReportYear; qnr.Implementer = item.Implementer; qnr.StatusId = 2; qnr.Highlights = item.Highlights; qnr.Implementer = item.Implementer; qnr.IpdsamAdmissionsTrend = item.IpdsamAdmissionsTrend; qnr.IpdsamPerformanceTrend = item.IpdsamPerformanceTrend; qnr.OpdsamAdmissionsTrend = item.OpdsamAdmissionsTrend; qnr.OpdsamPerformanceTrend = item.OpdsamPerformanceTrend; qnr.OpdmamAdmissionsTrend = item.OpdmamAdmissionsTrend; qnr.OpdmamPerformanceTrend = item.OpdmamPerformanceTrend; qnr.Iycf = item.Iycf; qnr.Micronutrients = item.Micronutrients; _context.Update(qnr); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblQnrExists(qnr.Qnrid)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } var items = _context.Provinces.Select(s => new { ProvCode = s.ProvCode, description = string.Format("{0} - {1}", s.ProvCode, s.ProvName) }).ToList(); items.Insert(0, new { ProvCode = "0", description = "select" }); ViewData["province"] = new SelectList(items, "ProvCode", "description"); ViewData["imp"] = new SelectList(_context.Implementers.Where(m => m.ImpAcronym != null), "ImpAcronym", "ImpAcronym"); return(View(qnr)); }
public async Task <IActionResult> Create([Bind("Highlights,Implementer,IpdsamAdmissionsTrend,IpdsamPerformanceTrend,Iycf,Micronutrients,OpdmamAdmissionsTrend,OpdmamPerformanceTrend,OpdsamAdmissionsTrend,OpdsamPerformanceTrend,Province,Month,Year")] qnrViewModel item) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(User.Identity.Name); TblQnr newReport = new TblQnr(); newReport.ReportingDate = DateTime.Now; newReport.UserName = User.Identity.Name; newReport.StatusId = 1; newReport.ReportMonth = item.Month; newReport.ReportYear = item.Year; newReport.UserName = User.Identity.Name; newReport.Highlights = item.Highlights; newReport.Implementer = item.Implementer; newReport.IpdsamAdmissionsTrend = item.IpdsamAdmissionsTrend; newReport.IpdsamPerformanceTrend = item.IpdsamPerformanceTrend; newReport.OpdsamAdmissionsTrend = item.OpdsamAdmissionsTrend; newReport.OpdsamPerformanceTrend = item.OpdsamPerformanceTrend; newReport.OpdmamAdmissionsTrend = item.OpdmamAdmissionsTrend; newReport.OpdmamPerformanceTrend = item.OpdmamPerformanceTrend; newReport.Iycf = item.Iycf; newReport.Micronutrients = item.Micronutrients; newReport.Province = item.Province; newReport.Tenant = user.TenantId; _context.TblQnr.Add(newReport); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } var items = _context.Provinces.Select(s => new { ProvCode = s.ProvCode, description = string.Format("{0} - {1}", s.ProvCode, s.ProvName) }); ViewData["province"] = new SelectList(items, "ProvCode", "description"); ViewData["imp"] = new SelectList(_context.Implementers.Where(m => m.ImpAcronym != null), "ImpCode", "ImpAcronym"); return(View(item)); }