// // GET: /SysAdmin/Division/Edit/5 public ActionResult Edit(int id) { FeeClassDivisionVM viewModel = new FeeClassDivisionVM(); FeeClassDivisionBAL balObject = new FeeClassDivisionBAL(); IQueryable <Entities.FeeClassDivision> entites = balObject.FindBy(a => a.FeeClassDivisionId == id); if (entites != null && entites.Count() > 0) { Entities.FeeClassDivision entity = entites.FirstOrDefault(); viewModel.FeeClassDivisionId = entity.FeeClassDivisionId; viewModel.FeeHeadId = entity.FeeHeadId; viewModel.FeeHeadName = entity.FeeHeadName; viewModel.ClassDivisionId = entity.ClassDivisionId; viewModel.ClassId = entity.ClassId; viewModel.DivisionId = entity.DivisionId; viewModel.ClassName = entity.ClassName; viewModel.DivisionName = entity.DivisionName; viewModel.PeriodInMonthly = entity.PeriodInMonthly; viewModel.AmountInMonthly = entity.AmountInMonthly; viewModel.AmountInYearly = entity.AmountInYearly; viewModel.Status = entity.Status; viewModel.Remark = entity.Remark; } return(View(viewModel)); }
public ActionResult Edit(FeeClassDivisionVM viewModel) { try { //Set default value viewModel.PeriodInMonthly = 12; viewModel.AmountInMonthly = viewModel.AmountInYearly; // TODO: Add update logic here if (ModelState.IsValid) { Entities.FeeClassDivision entity = new Entities.FeeClassDivision(); entity.FeeClassDivisionId = viewModel.FeeClassDivisionId; entity.FeeHeadId = viewModel.FeeHeadId; entity.ClassDivisionId = viewModel.ClassDivisionId; entity.PeriodInMonthly = viewModel.PeriodInMonthly; entity.AmountInMonthly = viewModel.AmountInMonthly; entity.AmountInYearly = viewModel.AmountInYearly; entity.Status = viewModel.Status; entity.Remark = viewModel.Remark; FeeClassDivisionBAL balObject = new FeeClassDivisionBAL(); balObject.Edit(entity); return(RedirectToAction("Index")); } else { return(View(viewModel)); } } catch { return(View()); } }
public ActionResult Create(FeeClassDivisionVM viewModel) { try { //Set default value viewModel.PeriodInMonthly = 12; viewModel.AmountInMonthly = viewModel.AmountInYearly; // TODO: Add insert logic here if (ModelState.IsValid) { Entities.FeeClassDivision entity = new Entities.FeeClassDivision(); entity.FeeClassDivisionId = viewModel.FeeClassDivisionId; entity.FeeHeadId = viewModel.FeeHeadId; ClassDivisionBAL classDivisionBAL = new ClassDivisionBAL(); entity.ClassDivisionId = classDivisionBAL.FindBy(cd => cd.ClassId == viewModel.ClassId && cd.DivisionId == viewModel.DivisionId).FirstOrDefault().ClassDivisionId; entity.PeriodInMonthly = viewModel.PeriodInMonthly; entity.AmountInMonthly = viewModel.AmountInMonthly; entity.AmountInYearly = viewModel.AmountInYearly; entity.Status = viewModel.Status; entity.Remark = viewModel.Remark; FeeClassDivisionBAL balObject = new FeeClassDivisionBAL(); balObject.Add(entity); return(RedirectToAction("Index")); } else { ClassBAL classBAL = new ClassBAL(); viewModel.Classes = from obj in classBAL.GetAll().Where(c => c.Status == true) select new SelectListItem() { Text = obj.ClassName, Value = obj.ClassId.ToString() }; FeeHeadBAL balObject = new FeeHeadBAL(); viewModel.Fees = from obj in balObject.GetAll() select new SelectListItem() { Text = obj.FeeHeadName, Value = obj.FeeHeadId.ToString() }; return(View(viewModel)); } } catch { ClassBAL classBAL = new ClassBAL(); viewModel.Classes = from obj in classBAL.GetAll().Where(c => c.Status == true) select new SelectListItem() { Text = obj.ClassName, Value = obj.ClassId.ToString() }; FeeHeadBAL balObject = new FeeHeadBAL(); viewModel.Fees = from obj in balObject.GetAll() select new SelectListItem() { Text = obj.FeeHeadName, Value = obj.FeeHeadId.ToString() }; return(View(viewModel)); } }