Beispiel #1
0
        public GetAllYearlyMaintenance GetAllYearlyMaintenance(GetAllYearlyMaintenanceRequest getAllYearlyMaintenanceRequest, GlobalCodeMainResponse feeType)
        {
            IEnumerable <GetYearlyMaintenance> data;
            GetAllYearlyMaintenance            getAllYearlyMaintenance = new GetAllYearlyMaintenance();
            List <GetYearlyMaintenance>        getYearlyMaintenances   = new List <GetYearlyMaintenance>();
            var allYears = _ObjContext.YearlyMaintainence.Where(x => x.IsActive == true && x.IsDeleted == false).ToList();

            if (allYears.Count() != 0)
            {
                for (int i = 0; i <= allYears.Count() - 1; i++)
                {
                    GetYearlyMaintenance getYearlyMaintenance = new GetYearlyMaintenance();

                    var yearlyFee = _ObjContext.YearlyMaintainenceFee.Where(x => x.YearlyMaintainenceId == allYears[i].YearlyMaintainenceId &&
                                                                            x.FeeType == "GeneralFee" &&
                                                                            x.FeeName == "Administration" && x.IsActive == true && x.IsDeleted == false).ToList();

                    decimal yearlyPreFee  = yearlyFee.Where(x => x.TimeFrame == "Pre").Select(x => x.Amount).FirstOrDefault();
                    decimal yearlyPostFee = yearlyFee.Where(x => x.TimeFrame == "Post").Select(x => x.Amount).FirstOrDefault();

                    getYearlyMaintenance.YearlyMaintenanceId = allYears[i].YearlyMaintainenceId;
                    getYearlyMaintenance.Year = allYears[i].Years;
                    getYearlyMaintenance.PreEntryCutOffDate = allYears[i].PreEntryCutOffDate;
                    getYearlyMaintenance.PreEntryFee        = yearlyPreFee;
                    getYearlyMaintenance.PostEntryFee       = yearlyPostFee;
                    getYearlyMaintenance.DateCreated        = allYears[i].Date;

                    getYearlyMaintenances.Add(getYearlyMaintenance);
                }
            }
            data = getYearlyMaintenances.ToList();
            if (data.Count() != 0)
            {
                if (getAllYearlyMaintenanceRequest.SearchTerm != null && getAllYearlyMaintenanceRequest.SearchTerm != "")
                {
                    data = data.Where(x => Convert.ToString(x.Year).Contains(getAllYearlyMaintenanceRequest.SearchTerm) || Convert.ToString(x.PreEntryCutOffDate.Date).Contains(getAllYearlyMaintenanceRequest.SearchTerm) ||
                                      Convert.ToString(x.PreEntryFee).Contains(getAllYearlyMaintenanceRequest.SearchTerm) || Convert.ToString(x.PostEntryFee).Contains(getAllYearlyMaintenanceRequest.SearchTerm) ||
                                      Convert.ToString(x.DateCreated.Date).Contains(getAllYearlyMaintenanceRequest.SearchTerm));
                }
                if (getAllYearlyMaintenanceRequest.OrderByDescending == true)
                {
                    data = data.OrderByDescending(x => x.GetType().GetProperty(getAllYearlyMaintenanceRequest.OrderBy).GetValue(x));
                }
                else
                {
                    data = data.OrderBy(x => x.GetType().GetProperty(getAllYearlyMaintenanceRequest.OrderBy).GetValue(x));
                }
                getAllYearlyMaintenance.TotalRecords = data.Count();
                if (getAllYearlyMaintenanceRequest.AllRecords)
                {
                    getAllYearlyMaintenance.getYearlyMaintenances = data.ToList();
                }
                else
                {
                    getAllYearlyMaintenance.getYearlyMaintenances = data.Skip((getAllYearlyMaintenanceRequest.Page - 1) * getAllYearlyMaintenanceRequest.Limit).Take(getAllYearlyMaintenanceRequest.Limit).ToList();
                }
            }
            return(getAllYearlyMaintenance);
        }
 public ActionResult GetAllYearlyMaintenance(GetAllYearlyMaintenanceRequest getAllYearlyMaintenanceRequest)
 {
     _mainResponse = _yearlyMaintenanceService.GetAllYearlyMaintenance(getAllYearlyMaintenanceRequest);
     _jsonString   = Mapper.Convert <GetAllYearlyMaintenance>(_mainResponse);
     return(new OkObjectResult(_jsonString));
 }