public SearchFeeStructures SearchFeeStructures(SearchFeeStructures obj) { var model = (dynamic)null; try { Int64 SearchClassId = Convert.ToInt64(obj.SearchClassId); var FeeStructuresList = _FeeStructuresRepo.GetAll().ToList(); var FeeTypesList = _FeeTypesRepo.GetAll().ToList(); var classList = _classesRepo.GetAll().ToList(); var query = (from _FeeStructure in FeeStructuresList join _FeeType in FeeTypesList on _FeeStructure?.FeeTypeId equals _FeeType?.Id join _class in classList on _FeeStructure?.ClassId equals _class?.Id where _FeeStructure.ClassId == SearchClassId select new { _FeeStructure, _FeeType, _class }).ToList(); var getAmount = (from p in FeeStructuresList where p.ClassId == SearchClassId select p.Amount); var allGetAmount = getAmount.Sum(); var SearchClassName = (from c in classList where c.Id == SearchClassId select c).SingleOrDefault(); var list = new List <SearchFeeStructures_FeeStructures>(); foreach (var item in query) { var temp = new SearchFeeStructures_FeeStructures() { Id = item._FeeStructure.Id, ClassId = item._FeeStructure.ClassId, Class = item._class.Name, FeeTypeId = item._FeeStructure.FeeTypeId, FeeType = item._FeeType.Name, FeeTypeMood = item._FeeStructure.YearlyTermNo, Amount = item._FeeStructure.Amount, StartingYear = item._FeeStructure.StartingYear, EndingYear = item._FeeStructure.EndingYear, IsActive = item._FeeStructure.IsActive }; list.Add(temp); } ; model = new SearchFeeStructures() { _FeeStructures = list, DateRangeAmount = allGetAmount, SearchClassName = SearchClassName.Name }; } catch (Exception) { } return(model); }
public async Task <IActionResult> SearchFeeStructures(string SearchClassId, int pg = 1) { try { if (String.IsNullOrEmpty(SearchClassId)) { var model = new IndexFeeStructuresListVM() { _FeeStructures = null, SearchClassId = null }; return(View("FeeStructuresList", model)); } else { var result = new SearchFeeStructures() { SearchClassId = SearchClassId }; var SearchFeeStructures = await Task.Run(() => _FeeStructuresServ.SearchFeeStructures(result)); ViewBag.ddlClass = _classesServ.dropdown_Class(); var list = new List <Vm_FeeStructures>(); foreach (var item in SearchFeeStructures._FeeStructures.ToList()) { var temp = new Vm_FeeStructures() { Id = item.Id, ClassId = item.ClassId, Class = item.Class, FeeTypeId = item.FeeTypeId, FeeType = item.FeeType, FeeTypeMood = item.FeeTypeMood, Amount = item.Amount, StartingYear = item.StartingYear, EndingYear = item.EndingYear, IsActive = item.IsActive }; list.Add(temp); } ; #region "Paging" const int pageSize = 5; if (pg < 1) { pg = 1; } int recsCount = list.Count(); var pager = new Pager(recsCount, pg, pageSize); int recSkip = (pg - 1) * pageSize; var data = list.Skip(recSkip).Take(pager.PageSize).ToList(); this.ViewBag.Pager = pager; var model = new IndexFeeStructuresListVM() { _FeeStructures = data, SearchClassId = SearchClassId, ammount = SearchFeeStructures.DateRangeAmount, SearchClassName = SearchFeeStructures.SearchClassName }; #endregion "Paging" return(View("FeeStructuresList", model)); } } catch { return(BadRequest()); } }