Exemplo n.º 1
0
        public List <RetrievalItemDTO> ViewRetrievalListById(int retrievalId)
        {
            StationeryRetrievalEF retrieval = rndEFF.FindRetrievalById(retrievalId);
            List <StationeryDisbursementDetailsEF> details = rndEFF.FindDisbursementDetailsByRetrievalId(retrievalId);

            // group by item code
            List <RetrievalItemDTO> retrievalList = new List <RetrievalItemDTO>();
            var items = from d in details
                        group d by d.ItemCode into itemGroup
                        select new
            {
                ItemCode            = itemGroup.Key,
                OutstandingQuantity = itemGroup.Sum(d => d.RequestQuantity),
                RetrievedQty        = itemGroup.Sum(a => a.RetrievedQuantity)
            };

            foreach (var item in items)
            {
                RetrievalItemDTO rItem = new RetrievalItemDTO()
                {
                    ItemCode            = item.ItemCode,
                    ItemDescription     = stockEFF.FindStockByItemCode(item.ItemCode).Description,
                    TotalOutstandingQty = item.OutstandingQuantity,
                    Bin          = stockEFF.FindStockByItemCode(item.ItemCode).Bin,
                    RetrievedQty = item.RetrievedQty
                };
                retrievalList.Add(rItem);
            }
            return(retrievalList);
        }
        // PENDING MODIFICATION TO METHOD
        public RetrievalDTO constructAdHocRetrievalDTO(LoginDTO loginDTO, int requisitionId)
        {
            List <RetrievalPrepItemDTO> retrievalPrepList = new List <RetrievalPrepItemDTO>();
            List <RetrievalItemDTO>     retrievalList     = new List <RetrievalItemDTO>();

            List <RequisitionDetail> preparingRequisitionDetailsFromSelectedRequisition = (List <RequisitionDetail>)requisitionDetailRepo.FindBy(x => x.RequisitionId == requisitionId && x.Status == "PREPARING").ToList();
            List <int> stationeriesInPreparingRequisitionDetails = RetrieveStationeryDetailsByRequisitionDetailsList(preparingRequisitionDetailsFromSelectedRequisition).ToList();

            foreach (int s in stationeriesInPreparingRequisitionDetails)
            {
                RetrievalItemDTO rID = new RetrievalItemDTO();
                rID.StationeryId = s;
                rID.Description  = stationeryRepo.FindOneBy(x => x.Id == s).Description;
                rID.Location     = stationeryRepo.FindOneBy(x => x.Id == s).Bin;

                List <RetrievalPrepItemDTO> tempRPIDTO    = new List <RetrievalPrepItemDTO>();
                List <RequisitionDetail>    reqDetailList = (List <RequisitionDetail>)preparingRequisitionDetailsFromSelectedRequisition.FindAll(x => x.StationeryId == rID.StationeryId).ToList();
                foreach (RequisitionDetail reDList in reqDetailList)
                {
                    RetrievalPrepItemDTO rPID = new RetrievalPrepItemDTO();
                    rPID.ReqStationery = stationeryRepo.FindOneBy(x => x.Id == reDList.StationeryId);
                    rPID.ReqDetail     = reDList;
                    rPID.Req           = requisitionRepo.FindOneBy(x => x.Id == requisitionId);
                    rPID.ReqOwner      = employeeRepo.FindOneBy(x => x.Id == rPID.Req.EmployeeId);
                    int deptId = rPID.ReqOwner.DepartmentId;
                    rPID.ReqDepartmentRep   = employeeRepo.FindOneBy(x => x.RoleId == (int)Enums.Roles.DepartmentRepresentative && x.DepartmentId == deptId);
                    rPID.ReqDepartment      = departmentRepo.FindOneBy(x => x.Id == deptId);
                    rPID.ReqCollectionPoint = collectionPointRepo.FindOneBy(x => x.Id == rPID.ReqDepartment.CollectionPointId);
                    tempRPIDTO.Add(rPID);
                }
                rID.RetrievalPrepItemList = tempRPIDTO;
                int count = 0;

                foreach (RetrievalPrepItemDTO retriPrepItem in tempRPIDTO)
                {
                    RequisitionDetail x = retriPrepItem.ReqDetail;
                    int y = x.QuantityOrdered;
                    count = count + y;
                }
                rID.NeededQuantity = count;
                rID.RetrievedQty   = count;
                retrievalList.Add(rID);
            }

            RetrievalDTO retrieval = new RetrievalDTO();

            retrieval.RetrievalDate = System.DateTime.Now.ToString("yyyy-MM-dd");
            Employee clerk = (Employee)employeeRepo.FindOneBy(x => x.Id == loginDTO.EmployeeId);

            if (clerk.Name == null)
            {
                retrieval.GeneratedBy = null;
            }
            else
            {
                retrieval.GeneratedBy = clerk.Name;
            }
            retrieval.RetrievalItem = retrievalList;
            return(retrieval);
        }
Exemplo n.º 3
0
        // GET: api/MobileRetrieval/5
        public RetrievalDTO Get(int id)
        {
            Models.DTOs.LoginDTO loginDTO = new Models.DTOs.LoginDTO
            {
                EmployeeId = id
            };
            Models.DTOs.RetrievalDTO tempModel = retrievalService.constructRetrievalDTO(loginDTO);
            RetrievalDTO             model     = new RetrievalDTO
            {
                LoginDTO      = loginDTO,
                RetrievalDate = tempModel.RetrievalDate,
                RetrievalItem = new List <RetrievalItemDTO>()
            };

            foreach (Models.DTOs.RetrievalItemDTO ri in tempModel.RetrievalItem)
            {
                RetrievalItemDTO ri2 = new RetrievalItemDTO
                {
                    Description           = ri.Description,
                    Location              = ri.Location,
                    NeededQuantity        = ri.NeededQuantity,
                    RetrievedQty          = ri.RetrievedQty,
                    StationeryId          = ri.StationeryId,
                    RetrievalPrepItemList = new List <RetrievalPrepItemDTO>()
                };

                foreach (Models.DTOs.RetrievalPrepItemDTO rpi in ri.RetrievalPrepItemList)
                {
                    RetrievalPrepItemDTO rpi2 = new RetrievalPrepItemDTO
                    {
                        RequisitionDetail = new RequisitionDetailDTO
                        {
                            Id            = rpi.ReqDetail.Id,
                            RequisitionId = rpi.ReqDetail.RequisitionId
                        }
                    };

                    ri2.RetrievalPrepItemList.Add(rpi2);
                }

                model.RetrievalItem.Add(ri2);
            }

            return(model);
        }
Exemplo n.º 4
0
        /*
         * helper method to consolidate each [approved requisitions for one item] into [one RetrievalItemDTO]
         */
        private static RetrievalListDTO ConsolidateNewRequisitions(List <RequisitionDetail> requisitionDetailList)
        {
            var itemsToRetrieve = new RetrievalListDTO();

            //group RequisitionDetail list by item: e.g.: List<ReqDetail>-for-pen, List<ReqDetail>-for-Paper, and store these lists in List:
            List <List <RequisitionDetail> > groupedReqListByItem = requisitionDetailList
                                                                    .GroupBy(rd => rd.ItemNum).Select(grp => grp.ToList()).ToList();

            //each list merge into ONE RetrievalItemDTO. e.g.: List<ReqDetail>-for-pen to be converted into ONE RetrievalItemDTO.
            foreach (List <RequisitionDetail> reqListForOneItem in groupedReqListByItem)
            {
                var retrievalItem = new RetrievalItemDTO(reqListForOneItem);

                itemsToRetrieve.Add(retrievalItem);
            }

            return(itemsToRetrieve);
        }
Exemplo n.º 5
0
        /*
         * helper method to consolidate each [unfullfilled Disbursements for one item] add to / into [one RetrievalItemDTO]
         */
        private static RetrievalListDTO ConsolidateUnfulfilledDisbursements(
            List <DisbursementDetail> unfullfilledDisDetailList)
        {
            var itemsToRetrieve = new RetrievalListDTO();

            //group DisbursementDetail list by item: e.g.: List<DisDetail>-for-pen, List<DisDetail>-for-Paper, and store these lists in List:
            List <List <DisbursementDetail> > groupedDisListByItem =
                unfullfilledDisDetailList.GroupBy(rd => rd.ItemNum).Select(grp => grp.ToList()).ToList();

            //each list merge into ONE RetrievalItemDTO. e.g.: List<DisDetail>-for-pen to be converted into ONE RetrievalItemDTO.
            foreach (List <DisbursementDetail> disListForOneItem in groupedDisListByItem)
            {
                var retrievalItem = new RetrievalItemDTO(disListForOneItem);

                itemsToRetrieve.Add(retrievalItem);
            }

            return(itemsToRetrieve);
        }
        public IEnumerable <RetrievalItemDTO> GetRetrievalInProcess()
        {
            var itemsToRetrieve = new List <RetrievalItemDTO>();

            //group inprocess disbursement by stationery
            List <List <DisbursementDetail> > inProcessDisDetailsGroupedByItem = GetDisbursementDetailsByStatus(InProcess)
                                                                                 .GroupBy(x => x.ItemNum).Select(grp => grp.ToList()).ToList();

            //list for each stationery forms one RetrievalItemDTO
            foreach (var disDetailForOneItem in inProcessDisDetailsGroupedByItem)
            {
                var stat          = disDetailForOneItem.First().Stationery;
                var retrievalItem = new RetrievalItemDTO(stat);
                foreach (var disbursementDetail in disDetailForOneItem)
                {
                    retrievalItem.RequestedQty += disbursementDetail.RequestedQty;
                }
                itemsToRetrieve.Add(retrievalItem);
            }

            return(itemsToRetrieve);
        }
        public RetrievalDTO constructRetrievalDTO(LoginDTO loginDTO)
        {
            List <RetrievalPrepItemDTO> retrievalPrepList              = new List <RetrievalPrepItemDTO>();
            List <RetrievalItemDTO>     retrievalList                  = new List <RetrievalItemDTO>();
            List <CollectionPoint>      assignedCollectionPoint        = RetrieveAssignedCollectionPoints(loginDTO.EmployeeId);
            List <Department>           assignedDepartment             = RetrieveDepartmentsInCollectionPointList(assignedCollectionPoint);
            List <Employee>             employeesInAssignedDepartments = RetrieveAllEmployeesInAssignedDepartmentList(assignedDepartment);
            List <Requisition>          approvedRequisitionsFromEmployeesInAssignedDepartments = RetrieveAllApprovedRequisitionsByEmployeeList(employeesInAssignedDepartments);
            List <RequisitionDetail>    preparingRequisitionDetailsFromApprovedRequisitions    = RetrieveAllPreparingRequisitionDetailsByRequisitionList(approvedRequisitionsFromEmployeesInAssignedDepartments);
            List <int> stationeriesInPreparingRequisitionDetails = RetrieveStationeryDetailsByRequisitionDetailsList(preparingRequisitionDetailsFromApprovedRequisitions);

            // .GroupBy(x => x.Id).Select(g => g.First()).ToList()
            // create retrievalItemDTO
            foreach (int s in stationeriesInPreparingRequisitionDetails)
            {
                RetrievalItemDTO rID = new RetrievalItemDTO();
                rID.StationeryId = s;
                rID.Description  = stationeryRepo.FindOneBy(x => x.Id == s).Description;
                rID.Location     = stationeryRepo.FindOneBy(x => x.Id == s).Bin;
                List <RetrievalPrepItemDTO> tempRPIDTO    = new List <RetrievalPrepItemDTO>();
                List <RequisitionDetail>    reqDetailList = (List <RequisitionDetail>)preparingRequisitionDetailsFromApprovedRequisitions.FindAll(x => x.StationeryId == rID.StationeryId);
                foreach (RequisitionDetail reDList in reqDetailList)
                {
                    RetrievalPrepItemDTO rPID = new RetrievalPrepItemDTO();
                    rPID.ReqStationery      = stationeryRepo.FindOneBy(x => x.Id == reDList.StationeryId);
                    rPID.ReqDetail          = reDList;
                    rPID.Req                = approvedRequisitionsFromEmployeesInAssignedDepartments.Find(x => x.Id == rPID.ReqDetail.RequisitionId);
                    rPID.ReqOwner           = employeesInAssignedDepartments.Find(x => x.Id == rPID.Req.EmployeeId);
                    rPID.ReqDepartmentRep   = employeesInAssignedDepartments.Find(x => x.RoleId == (int)Enums.Roles.DepartmentRepresentative);
                    rPID.ReqDepartment      = assignedDepartment.Find(x => x.Id == rPID.ReqDepartmentRep.DepartmentId);
                    rPID.ReqCollectionPoint = assignedCollectionPoint.Find(x => x.Id == rPID.ReqDepartment.CollectionPointId);
                    tempRPIDTO.Add(rPID);
                }

                rID.RetrievalPrepItemList = tempRPIDTO;
                int count = 0;

                foreach (RetrievalPrepItemDTO retriPrepItem in tempRPIDTO)
                {
                    RequisitionDetail x = retriPrepItem.ReqDetail;
                    int y = x.QuantityOrdered;
                    count = count + y;
                }

                rID.NeededQuantity = count;
                rID.RetrievedQty   = count;
                retrievalList.Add(rID);
            }

            RetrievalDTO retrieval = new RetrievalDTO();

            retrieval.RetrievalDate = System.DateTime.Now.ToString("yyyy-MM-dd");
            Employee clerk = (Employee)employeeRepo.FindOneBy(x => x.Id == loginDTO.EmployeeId);

            if (clerk.Name == null)
            {
                retrieval.GeneratedBy = null;
            }
            else
            {
                retrieval.GeneratedBy = clerk.Name;
            }

            retrieval.RetrievalItem = retrievalList;
            return(retrieval);
        }