public GetAllFees GetAllFees()
        {
            string timeFrameType;
            IEnumerable <GetFees> data       = null;
            GetAllFees            getAllFees = new GetAllFees();

            // var yearlyId = _context.YearlyMaintainence.Where(x => x.Years == DateTime.Now.Year && x.IsActive == true && x.IsDeleted == false).FirstOrDefault();
            var yearlyId = _context.YearlyMaintainence.Where(x => x.IsActive == true && x.IsDeleted == false).FirstOrDefault();

            if (yearlyId != null)
            {
                if (DateTime.Now.Date <= yearlyId.PreEntryCutOffDate.Date)
                {
                    timeFrameType = "Pre";
                }
                else
                {
                    timeFrameType = "Post";
                }
            }
            else
            {
                return(getAllFees);
            }

            data = (from yearlyFee in _context.YearlyMaintainenceFee
                    where yearlyFee.IsActive == true && yearlyFee.IsDeleted == false &&
                    yearlyFee.YearlyMaintainenceId == yearlyId.YearlyMaintainenceId &&
                    yearlyFee.FeeType == "GeneralFee"
                    select new GetFees
            {
                FeeTypeId = yearlyFee.YearlyMaintainenceFeeId,
                FeeName = yearlyFee.FeeName,
                TimeFrameType = yearlyFee.TimeFrame,
                Amount = yearlyFee.Amount
            });

            if (data.Count() != 0)
            {
                getAllFees.DefaultTimeFrame = timeFrameType;
                getAllFees.getFees          = data.ToList();
            }

            return(getAllFees);
        }
Example #2
0
        public GetAllFees GetAllFees()
        {
            string timeFrameType;
            IEnumerable <GetFees> data       = null;
            GetAllFees            getAllFees = new GetAllFees();

            var yearlyId = _context.YearlyMaintainence.Where(x => x.Years == DateTime.Now.Year && x.IsActive == true && x.IsDeleted == false).FirstOrDefault();

            if (yearlyId != null)
            {
                if (DateTime.Now.Date <= yearlyId.PreEntryCutOffDate.Date)
                {
                    timeFrameType = "Pre";
                }
                else
                {
                    timeFrameType = "Post";
                }
            }
            else
            {
                return(getAllFees);
            }

            data = (from yFee in _context.YearlyMaintainenceFee
                    where yFee.YearlyMaintainenceId == yearlyId.YearlyMaintainenceId && yFee.IsActive == true && yFee.IsDeleted == false
                    select new GetFees
            {
                FeeTypeId = yFee.FeeTypeId,
                FeeType = _context.GlobalCodes.Where(x => x.GlobalCodeId == yFee.FeeTypeId).Select(x => x.CodeName).FirstOrDefault(),
                TimeFrameType = timeFrameType,
                PreFee = yFee.PreEntryFee,
                PostFee = yFee.PostEntryFee,
                Amount = yFee.Amount,
                RefundPercentage = yFee.RefundPercentage
            });
            getAllFees.getFees = data.ToList();
            return(getAllFees);
        }