//extra fe list public IActionResult ExtraFeeList(int?page) { Int64 Count = 1; var pagenumber = page ?? 1; var v1 = _context.ExtraFee.ToList(); var v2 = _context.Class.ToList(); var q = from vef in v1 join vc in v2 on vef.ClassId equals vc.ClassId select new { pk = vef.ExtraFeeId, clsname = vc.ClassName, exft = vef.ExtraFeeTitle, exfa = vef.ExtraFeeAmount }; var efvmlist = new List <ExtraFeeViewModel>(); foreach (var item in q) { ExtraFeeViewModel efvm = new ExtraFeeViewModel(); efvm.serialnoVM = Count; Count++; efvm.PrimaryKey = item.pk; efvm.extrafeetitleVM = item.exft; efvm.extrafeeamountVM = item.exfa; efvm.classnameVM = item.clsname; efvmlist.Add(efvm); } var pg = efvmlist.ToPagedList(pagenumber, 3); return(View(pg)); }
public IActionResult SetExtraFee(ExtraFeeViewModel efvm) { var vexf = _context.Class.ToList(); vexf.Insert(0, new Class { ClassId = 0, ClassName = "Select Class" }); ViewBag.vwvexf = vexf; if (efvm.classidVM == 0) { ViewBag.msg1 = "Please choose a class"; return(View()); } ExtraFee ef = new ExtraFee(); ef.ExtraFeeId = 0; ef.ExtraFeeTitle = efvm.extrafeetitleVM; ef.ExtraFeeAmount = efvm.extrafeeamountVM; ef.ClassId = efvm.classidVM; var v = _context.ExtraFee.Where(q => q.ClassId == efvm.classidVM && q.ExtraFeeTitle == efvm.extrafeetitleVM).FirstOrDefault(); if (v != null) { ViewBag.msg2 = "Extra Fee is already set for this class!"; return(View()); } _context.ExtraFee.Add(ef); _context.SaveChanges(); ModelState.Clear(); return(View()); }
//update extra fee list public IActionResult UpdateExtraFeeList(Int64 uefl) { //var vexf = _context.Class.ToList(); //vexf.Insert(0, new Class { ClassId = 0, ClassName = "Select Class" }); //ViewBag.vwvexf = vexf; var v = _context.ExtraFee.Where(q => q.ExtraFeeId == uefl).FirstOrDefault(); ExtraFeeViewModel efvm = new ExtraFeeViewModel(); efvm.classidVM = v.ClassId; efvm.extrafeetitleVM = v.ExtraFeeTitle; efvm.extrafeeamountVM = v.ExtraFeeAmount; efvm.PrimaryKey = v.ExtraFeeId; return(View(efvm)); }
public IActionResult UpdateExtraFeeList(ExtraFeeViewModel updt) { //var vexf = _context.Class.ToList(); //vexf.Insert(0, new Class { ClassId = 0, ClassName = "Select Class" }); //ViewBag.vwvexf = vexf; //if (updt.classidVM == 0) //{ // ViewBag.msg = "Please Select a Class"; // return View(); //} ExtraFee ef = new ExtraFee(); ef.ExtraFeeId = updt.PrimaryKey; ef.ClassId = updt.classidVM; ef.ExtraFeeTitle = updt.extrafeetitleVM; ef.ExtraFeeAmount = updt.extrafeeamountVM; _context.ExtraFee.Update(ef); _context.SaveChanges(); ModelState.Clear(); return(RedirectToAction("ExtraFeeList")); }