示例#1
0
        public async Task <ActionResult <IList <DisbursementDetail> > > GetDisbursementDetailByDeptId(int id)
        {
            var allDisbursementList = await _clerkService.findAllDisbursementListAsync();

            var allDisbursementDetail = await _clerkService.findAllDisbursementDetailAsync();

            var allDisbursementListUnderDept =
                allDisbursementList.Where(x => x.DepartmentId == id);

            List <DisbursementDetail> allDisbursementDetailUnderDept = new List <DisbursementDetail>();

            foreach (DisbursementDetail disbursementDetail in allDisbursementDetail)
            {
                foreach (DisbursementList disbursementList in allDisbursementListUnderDept)
                {
                    if (disbursementDetail.DisbursementListId == disbursementList.id)
                    {
                        allDisbursementDetailUnderDept.Add(disbursementDetail);
                    }
                }
            }

            if (allDisbursementDetailUnderDept.Any())
            {
                //Docs says that Ok(...) will AUTO TRANSFER result into JSON Type
                return(Ok(allDisbursementDetailUnderDept));
            }
            else
            {
                return(NotFound("No disbursement detail under this department."));
            }
        }
示例#2
0
        public async Task <ActionResult <List <DisbursementDetail> > > GetDisbursementDetail(int id)
        {
            Console.WriteLine("disburmentment fetching");

            var allDD = await _clkService.findAllDisbursementDetailAsync();

            var currDD = allDD.Where(x => x.DisbursementListId == id);
            var allRD  = await _clkService.findAllRequsitionDetailsAsync();

            List <fakeDisbursementDetail> result = new List <fakeDisbursementDetail>();

            foreach (DisbursementDetail dd in currDD)
            {
                foreach (RequisitionDetail rd in allRD)
                {
                    if (dd.RequisitionDetailId == rd.Id)
                    {
                        fakeDisbursementDetail fdd = new fakeDisbursementDetail();
                        var allSt = await _clkService.findStationeryByIdAsync(rd.StationeryId);

                        fdd.RequisitionDetail = allSt.Id.ToString();
                        fdd.DisbursementList  = allSt.desc;
                        fdd.qty = dd.qty;
                        result.Add(fdd);
                    }
                }
            }
            return(Ok(result));
        }