public void UpdateActualQuantityForDisbursementDetail_Valid()
        {
            // Arrange
            var requisitionRepository = new RequisitionRepository(context);
            var departmentRepository  = new DepartmentRepository(context);

            var requisition = requisitionRepository.Save(new Requisition()
            {
                RequisitionId   = "DSERVICETEST",
                CollectionPoint = departmentRepository.FindById("ENGL").CollectionPoint,
                Department      = departmentRepository.FindById("ENGL"),
                CreatedDateTime = DateTime.Now,
            });
            var retrieval = retrievalRepository.Save(new Retrieval()
            {
                RetrievalId  = "DSERVICETEST",
                Requisitions = new List <Requisition>()
                {
                    requisition
                },
                CreatedDateTime = DateTime.Now,
            });
            var disbursement = disbursementRepository.Save(new Disbursement()
            {
                DisbursementId      = "DSERVICETEST",
                Department          = departmentRepository.FindById("ENGL"),
                DisbursementDetails = new List <DisbursementDetail>()
                {
                    new DisbursementDetail()
                    {
                        DisbursementId = "DSERVICETEST",
                        ItemCode       = "E030",
                        PlanQuantity   = 30,
                        ActualQuantity = 30,
                        Status         = new StatusService(context).FindStatusByStatusId(18),
                    }
                },
                Retrieval       = retrieval,
                Status          = new StatusService(context).FindStatusByStatusId(1),
                CreatedDateTime = DateTime.Now,
            });

            // Act
            new DisbursementService(context).UpdateActualQuantityForDisbursementDetail("DSERVICETEST", "E030", 20, "*****@*****.**");

            // Assert
            Assert.AreEqual(20, new DisbursementDetailRepository(context).FindById("DSERVICETEST", "E030").ActualQuantity);
        }
        public void TestInitialize()
        {
            context = new ApplicationDbContext();

            retrievalService    = new RetrievalService(context);
            itemService         = new ItemService(context);
            disbursementService = new DisbursementService(context);

            retrievalRepository          = new RetrievalRepository(context);
            disbursementRepository       = new DisbursementRepository(context);
            disbursementdetailRepository = new DisbursementDetailRepository(context);
            stockmovementRepository      = new StockMovementRepository(context);
            statusRepository             = new StatusRepository(context);

            Retrieval retrieval = new Retrieval();

            if (retrievalRepository.FindById("TEST") == null)
            {
                //save retrieval object into db

                retrieval.RetrievalId     = "TEST";
                retrieval.CreatedDateTime = DateTime.Now;
                retrievalRepository.Save(retrieval);
                retrieval.Status = statusRepository.FindById(19);
            }
            else
            {
                retrieval = retrievalRepository.FindById("TEST");
            }

            Disbursement disbursement = new Disbursement();

            if (disbursementRepository.FindById("TEST") == null)
            {
                disbursement.DisbursementId  = "TEST";
                disbursement.CreatedDateTime = DateTime.Now;
                disbursement.Retrieval       = retrieval;
            }
            else
            {
                disbursement = disbursementRepository.FindById("TEST");
            }

            disbursementRepository.Save(disbursement);

            //save disbursement detail object into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                Disbursement   = disbursement,
                Item           = context.Item.Where(x => x.ItemCode == "C003").First(),
                PlanQuantity   = 5,
                ActualQuantity = 5
            };

            disbursementdetailRepository.Save(detail);
        }
        public void RetrieveItem_Valid()
        {
            // Arrange
            var requisitionRepository = new RequisitionRepository(context);
            var departmentRepository  = new DepartmentRepository(context);

            var requisition = requisitionRepository.Save(new Requisition()
            {
                RequisitionId   = "RSERVICETEST",
                CollectionPoint = departmentRepository.FindById("ENGL").CollectionPoint,
                Department      = departmentRepository.FindById("ENGL"),
                CreatedDateTime = DateTime.Now,
            });
            var retrieval = retrievalRepository.Save(new Retrieval()
            {
                RetrievalId  = "RSERVICETEST",
                Requisitions = new List <Requisition>()
                {
                    requisition
                },
                CreatedDateTime = DateTime.Now,
            });
            var disbursement = disbursementRepository.Save(new Disbursement()
            {
                DisbursementId      = "RSERVICETEST",
                Department          = departmentRepository.FindById("ENGL"),
                DisbursementDetails = new List <DisbursementDetail>()
                {
                    new DisbursementDetail()
                    {
                        DisbursementId = "RSERVICETEST",
                        Item           = new ItemService(context).FindItemByItemCode("E030"),
                        ItemCode       = "E030",
                        ActualQuantity = 1,
                        Status         = new StatusService(context).FindStatusByStatusId(17),
                    }
                },
                Retrieval       = retrieval,
                Status          = new StatusService(context).FindStatusByStatusId(1),
                CreatedDateTime = DateTime.Now,
            });
            var expected = new StatusService(context).FindStatusByStatusId(18);

            // Act
            new RetrievalService(context).RetrieveItem(retrieval.RetrievalId, "*****@*****.**", "E030");

            // Assert
            Assert.AreEqual(expected.StatusId, new DisbursementDetailRepository(context).FindById(disbursement.DisbursementId, "E030").Status.StatusId);
        }
 public void TestInitialize()
 {
     var requisition = requisitionRepository.Save(new Requisition()
     {
         RequisitionId      = "DAPICONTROLTEST",
         CollectionPoint    = departmentRepository.FindById("ENGL").CollectionPoint,
         Department         = departmentRepository.FindById("ENGL"),
         CreatedDateTime    = DateTime.Now,
         Status             = new StatusRepository(context).FindById(7),
         RequisitionDetails = new List <RequisitionDetail>()
         {
             new RequisitionDetail()
             {
                 RequisitionId = "DAPICONTROLTEST",
                 ItemCode      = "E030",
                 Item          = new ItemService(context).FindItemByItemCode("E030"),
                 Quantity      = 30,
                 Status        = new StatusRepository(context).FindById(7),
             }
         }
     });
     var retrieval = retrievalRepository.Save(new Retrieval()
     {
         RetrievalId  = "DAPICONTROLTEST",
         Requisitions = new List <Requisition>()
         {
             requisition
         },
         CreatedDateTime = DateTime.Now,
     });
     var disbursement = disbursementRepository.Save(new Disbursement()
     {
         DisbursementId      = "DAPICONTROLTEST",
         Department          = departmentRepository.FindById("ENGL"),
         DisbursementDetails = new List <DisbursementDetail>()
         {
             new DisbursementDetail()
             {
                 DisbursementId = "DAPICONTROLTEST",
                 ItemCode       = "E030",
                 ActualQuantity = 1,
             }
         },
         Retrieval       = retrieval,
         Status          = new StatusService(context).FindStatusByStatusId(1),
         CreatedDateTime = DateTime.Now,
     });
 }
        public void FindByIdTestNotNull()
        {
            // Arrange
            retrievalRepository.Save(new Retrieval()
            {
                RetrievalId     = "RTREPOTEST",
                CreatedDateTime = DateTime.Now,
            });

            // Act
            var result = retrievalRepository.FindById("RTREPOTEST");

            // Assert
            Assert.IsInstanceOfType(result, typeof(Retrieval));
        }
Esempio n. 6
0
 public Retrieval Save(Retrieval retrieval)
 {
     //mapped to confirm retrieval, add and edit retrievals (if any)
     return(retrievalRepository.Save(retrieval));
 }
Esempio n. 7
0
        public void UpdateRetrievalFormTest()
        {
            // ARRANGE
            RetrievalAPIController retrievalAPIController = new RetrievalAPIController()
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration(),
                Context       = context,
            };

            string retId    = "RETRIEVAL";
            string deptId   = "COMM";
            string itemCode = "C001";
            string disbId   = "DISBURSEMENT";
            int    actual   = 99;

            Retrieval r = new Retrieval
            {
                RetrievalId     = retId,
                CreatedDateTime = DateTime.Now
            };
            Disbursement d = new Disbursement
            {
                DisbursementId      = disbId,
                Department          = departmentService.FindDepartmentByDepartmentCode(deptId),
                Retrieval           = r,
                CreatedDateTime     = DateTime.Now,
                DisbursementDetails = new List <DisbursementDetail>
                {
                    new DisbursementDetail
                    {
                        Item           = ItemRepository.FindById(itemCode),
                        PlanQuantity   = 99,
                        ActualQuantity = 0
                    }
                }
            };

            retrievalRepository.Save(r);
            disbursementRepository.Save(d);

            try
            {
                SaveJson json = new SaveJson
                {
                    ItemCode = itemCode,
                    RetId    = retId,
                    List     = new List <BreakdownByDepartment>
                    {
                        new BreakdownByDepartment
                        {
                            DeptId = deptId,
                            Actual = actual
                        }
                    }
                };

                // ACT
                retrievalAPIController.UpdateRetrievalForm(json);


                // ASSERT
                int expected = 99;

                DisbursementDetail dd;
                //using (context = new ApplicationDbContext())
                //{
                disbursementRepository = new DisbursementRepository(context);
                dd = disbursementRepository
                     .FindById(disbId)
                     .DisbursementDetails
                     .Where(x => x.ItemCode == itemCode).First();
                //}

                Assert.AreEqual(expected, dd.ActualQuantity);
            }
            finally
            {
                //using (context = new ApplicationDbContext())
                //{
                Disbursement deleteD = context.Disbursement.Where(x => x.DisbursementId == disbId).First();
                context.Disbursement.Remove(deleteD);

                Retrieval deleteR = context.Retrieval.Where(x => x.RetrievalId == retId).First();
                context.Retrieval.Remove(deleteR);
                context.SaveChanges();
                //}
            }
        }
        public void TestInitialize()
        {
            context = new ApplicationDbContext();
            disbursementRepository       = new DisbursementRepository(context);
            disbursementdetailRepository = new DisbursementDetailRepository(context);
            disbursementService          = new DisbursementService(context);
            itemRepository              = new ItemRepository(context);
            retrievalRepository         = new RetrievalRepository(context);
            requisitionRepository       = new RequisitionRepository(context);
            requisitiondetailRepository = new RequisitionDetailRepository(context);
            departmentRepository        = new DepartmentRepository(context);

            Retrieval retrieval = new Retrieval();

            if (retrievalRepository.FindById("TEST") == null)
            {
                //save retrieval object into db

                retrieval.RetrievalId     = "TEST";
                retrieval.CreatedDateTime = DateTime.Now;
                retrievalRepository.Save(retrieval);
            }
            else
            {
                retrieval = retrievalRepository.FindById("TEST");
            }

            //save disbursement object into db

            Disbursement disbursement = new Disbursement();

            if (disbursementRepository.FindById("TEST") == null)
            {
                disbursement.DisbursementId  = "TEST";
                disbursement.CreatedDateTime = DateTime.Now;
                disbursement.Retrieval       = retrieval;
            }
            else
            {
                disbursement = disbursementRepository.FindById("TEST");
            }

            disbursementRepository.Save(disbursement);

            //save disbursement detail object into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                Disbursement   = disbursement,
                Item           = context.Item.First(),
                PlanQuantity   = 20,
                ActualQuantity = 20
            };

            disbursementdetailRepository.Save(detail);

            Requisition requisition = new Requisition()
            {
                RequisitionId   = "TEST",
                Retrieval       = retrieval,
                CreatedDateTime = DateTime.Now,
                Status          = new StatusService(context).FindStatusByStatusId(8)
            };

            requisitionRepository.Save(requisition);
        }