public ActionResult Edit(SchoolFeesType model) { string schoolFeeTy = model.SchoolFeesKind; model.SchoolFeesKind = model.SchoolFeesKind.TrimEnd().TrimStart(); List <SchoolFeesType> sct = new List <SchoolFeesType>(); sct = work.SchoolFeesTypeRepository.Get(a => a.SchoolFeesKind.ToLower() == schoolFeeTy.TrimEnd().TrimStart().ToLower()).ToList(); try { if (sct.Count() > 0) { SchoolFeesType scr = sct[0]; if (scr.Amount == model.Amount) { ModelState.AddModelError("", "A School Fee Type with same amount has already been created!"); return(View()); } } if (ModelState.IsValid) { UnitOfWork work2 = new UnitOfWork(); work2.SchoolFeesTypeRepository.Update(model); work2.Save(); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(SchoolFeesType model) { model.SchoolFeesKind = model.SchoolFeesKind.TrimEnd().TrimStart(); List <SchoolFeesType> sct = new List <SchoolFeesType>(); sct = work.SchoolFeesTypeRepository.Get(a => a.SchoolFeesKind.ToLower() == model.SchoolFeesKind.TrimEnd().TrimStart().ToLower()).ToList(); try { if (sct.Count() > 0) { ModelState.AddModelError("", "A School Fee Type has already been created!"); return(View()); } if (TryUpdateModel(model)) { work.SchoolFeesTypeRepository.Insert(model); work.Save(); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
// StudentFeeViewModel feeModel = new StudentFeeViewModel(); // // GET: /StudentFees/ // [DynamicAuthorize] // public ActionResult Index(string name = "NURSERY 1", string term = "1") public ActionResult Index(string theFeeTypes, string term) { //List<Level> theLevels = work.LevelRepository.Get().ToList(); //List<SelectListItem> theItem = new List<SelectListItem>(); List <SchoolFeesType> theFeeType = work.SchoolFeesTypeRepository.Get().ToList(); List <SelectListItem> theItemFeeType = new List <SelectListItem>(); foreach (var t in theFeeType) { theItemFeeType.Add(new SelectListItem() { Text = t.SchoolFeesKind, Value = t.SchoolFeesKind }); } ViewData["theFeeType"] = theFeeType; var fees = work.StudentFeesRepository.Get(); //select s; if (String.IsNullOrEmpty(theFeeTypes) && String.IsNullOrEmpty(term)) { //SchoolFeesType sft = work.SchoolFeesTypeRepository.Get(a => a.SchoolFeesKind == "theFeeTypes").First(); fees = fees.Where(s => s.SchoolFeesTypeID == 0); } if (!String.IsNullOrEmpty(theFeeTypes)) { SchoolFeesType sft = work.SchoolFeesTypeRepository.Get(a => a.SchoolFeesKind == "theFeeTypes").First(); fees = fees.Where(s => s.SchoolFeesTypeID == sft.SchoolFeesTypeID); } if (!String.IsNullOrEmpty(term)) { fees = fees.Where(s => s.Term == term); } var viewModel = new StudentFeeViewModel(); // List<StudentFees> theFees = work.StudentFeesRepository.Get(a=>a.Level.Equals(name)).OrderBy(a=>a.Level).ToList(); //if (name != "") //{ // viewModel.Level = name; viewModel.StudentFees = fees.ToList(); // } //foreach(var fee in theFees) //{ // viewModel. //} return(View(viewModel)); }
public ActionResult Delete(SchoolFeesType model) { try { // TODO: Add delete logic here work.SchoolFeesTypeRepository.Delete(model); work.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(TermRegistrationViewModel model, string level1, string Term2, string Session3) //public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here foreach (TermRegistration m in model.TheTermRegistration) { if (m.Register == true && !string.IsNullOrEmpty(m.SchoolFeesKind)) { string theSchoolFeeKind = m.SchoolFeesKind; SchoolFeesType theFeeCost = work.SchoolFeesTypeRepository.Get(a => a.SchoolFeesKind == theSchoolFeeKind).First(); m.Cost = theFeeCost.Amount; m.Session = Session3; m.Term = Term2; List <TermRegistration> theReg = work2.TermRegistrationRepository.Get(a => a.StudentID == m.StudentID && a.Session == m.Session && a.Term == m.Term).ToList(); if (theReg.Count() > 0) { TermRegistration theRegi = theReg[0]; theRegi.Cost = m.Cost; theRegi.Register = m.Register; theRegi.SchoolFeesKind = m.SchoolFeesKind; // theRegi. work2.TermRegistrationRepository.Update(theRegi); // work2.TermRegistrationRepository.Delete(theRegi); } else { m.DateRegistered = DateTime.Now; work.TermRegistrationRepository.Insert(m); } } } work2.Save(); work.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }
// // GET: /SchoolFeesType/Edit/5 public ActionResult Edit(int id) { SchoolFeesType theType = work.SchoolFeesTypeRepository.GetByID(id); return(View(theType)); }