Пример #1
0
        /*
         * helper method step 1
         */
        private List <Disbursement> GenerateDisbursementsWithApprovedRequisitions(
            List <Disbursement> targetDisbursementsList, DateTime collectionDate)
        {
            List <List <Requisition> > reqGroupByDept = _disbursementRepo.GetApprovedRequisitions()
                                                        .GroupBy(r => r.RequisitionEmployee.DeptCode)
                                                        .Select(grp => grp.ToList()).ToList();

            // and create disbursement list based on it
            foreach (var requisitionsForOneDept in reqGroupByDept)
            {
                //Get all approved requisition details in one department
                var deptCode = requisitionsForOneDept.First().DeptCode;
                var requisitionDetailsForOneDept = _disbursementRepo.GetApprovedRequisitionDetailsByDeptCode(deptCode);

                //construct disbursment based on the requisition list
                var disbursement = new Disbursement(requisitionDetailsForOneDept, collectionDate);

                targetDisbursementsList.Add(disbursement);

                //as respective disbursement is created, update the requisition status
                foreach (var requisition in requisitionsForOneDept)
                {
                    requisition.Status = Processed;
                    _disbursementRepo.UpdateRequisition(requisition);
                }
            }

            return(targetDisbursementsList);
        }