Пример #1
0
        public GetGroupFinacialsTotals getTotals(List <GetGroupFinacials> list)
        {
            GetGroupFinacialsTotals getGroupFinacialsTotals = new GetGroupFinacialsTotals();

            if (list.Count() > 0)
            {
                var codes = (from gcc in _context.GlobalCodeCategories
                             join gc in _context.GlobalCodes on gcc.GlobalCodeCategoryId equals gc.CategoryId
                             where gcc.CategoryName == "TimeFrameType" && gc.IsDeleted == false && gc.IsActive == true
                             select new
                {
                    gc.GlobalCodeId,
                    gc.CodeName
                }).ToList();
                var Preid  = (from code in codes where code.CodeName == "Pre" select code.GlobalCodeId).FirstOrDefault();
                var Postid = (from code in codes where code.CodeName == "Post" select code.GlobalCodeId).FirstOrDefault();

                getGroupFinacialsTotals.PreTotal     = list.Where(x => x.TimeFrameId == Preid).Select(x => x.Amount).Sum();
                getGroupFinacialsTotals.PostTotal    = list.Where(x => x.TimeFrameId == Postid).Select(x => x.Amount).Sum();
                getGroupFinacialsTotals.PrePostTotal = getGroupFinacialsTotals.PreTotal + getGroupFinacialsTotals.PostTotal;
                //getGroupFinacialsTotals.PrePostTotal = list.Select(x => x.Amount).Sum();
            }

            return(getGroupFinacialsTotals);
        }
Пример #2
0
        public GetAllGroupsFinacialsModule GetModuleGroupsFinancials(int groupId)
        {
            GetAllGroupsFinacialsModule    response = new GetAllGroupsFinacialsModule();
            List <GetGroupFinacialsTotals> getGetGroupFinacialsTotalsList = new List <GetGroupFinacialsTotals>();

            var allGroups = (from groups in _context.Groups where groups.GroupId == groupId && groups.IsActive == true select groups).ToList();

            foreach (var item in allGroups)
            {
                List <GetGroupFinacials> list = new List <GetGroupFinacials>();
                list = (from financial in _context.GroupFinancials
                        join feetype in _context.YearlyMaintainenceFee on financial.FeeTypeId equals feetype.YearlyMaintainenceFeeId
                        join timeframe in _context.GlobalCodes on financial.TimeFrameId equals timeframe.GlobalCodeId
                        where financial.GroupId == item.GroupId &&
                        financial.IsActive == true &&
                        financial.IsDeleted == false &&
                        feetype.IsActive == true &&
                        feetype.IsDeleted == false &&
                        timeframe.IsActive == true &&
                        timeframe.IsDeleted == false
                        select new GetGroupFinacials
                {
                    GroupFinancialId = financial.GroupFinancialId,
                    Date = financial.Date,
                    FeeTypeId = financial.FeeTypeId,
                    FeeTypeName = feetype.FeeName,
                    FeeTimeFrame = feetype.TimeFrame,
                    TimeFrameId = financial.TimeFrameId,
                    TimeFrameName = timeframe.CodeName,
                    Amount = financial.Amount
                }).ToList();

                GetGroupFinacialsTotals getGetGroupFinacialsTotals = new GetGroupFinacialsTotals();

                getGetGroupFinacialsTotals           = getTotals(list);
                getGetGroupFinacialsTotals.GroupName = item.GroupName;
                getGetGroupFinacialsTotals.GroupId   = item.GroupId;
                getGetGroupFinacialsTotalsList.Add(getGetGroupFinacialsTotals);
            }

            response.getGroupFinacialsTotalsList = getGetGroupFinacialsTotalsList;

            return(response);
        }