public void ExistsByIdTestIsTrue()
        {
            // Arrange
            retrievalRepository.Save(new Retrieval()
            {
                RetrievalId     = "RTREPOTEST",
                CreatedDateTime = DateTime.Now,
            });

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

            // Assert
            Assert.IsTrue(result);
        }
        public void TestCleanup()
        {
            Retrieval retrieval = context.Retrieval.Where(x => x.RetrievalId == "TEST").First();

            List <StockMovement> smlist = context.StockMovement.Where(x => x.DisbursementId == "TEST").ToList();

            foreach (StockMovement sm in smlist)
            {
                stockmovementRepository.Delete(sm);
            }


            List <Disbursement> list = disbursementService.FindDisbursementsByRetrievalId(retrieval.RetrievalId);

            foreach (Disbursement d in list)
            {
                //Delete dummy disbursement test objects
                disbursementRepository.Delete(d);
            }

            //delete retrieval objects
            retrievalRepository.Delete(retrieval);

            var requisitionRepository = new RequisitionRepository(context);

            if (disbursementRepository.ExistsById("RSERVICETEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RSERVICETEST"));
            }
            if (disbursementRepository.ExistsById("RSERVICETEST1"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RSERVICETEST1"));
            }
            if (disbursementRepository.ExistsById("RSERVICETEST2"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RSERVICETEST2"));
            }
            if (requisitionRepository.ExistsById("RSERVICETEST"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RSERVICETEST"));
            }
            if (requisitionRepository.ExistsById("RSERVICETEST1"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RSERVICETEST1"));
            }
            if (requisitionRepository.ExistsById("RSERVICETEST2"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RSERVICETEST2"));
            }
            if (retrievalRepository.ExistsById("RSERVICETEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("RSERVICETEST"));
            }
            if (requisitionRepository.FindAll().Where(r => r.EmployeeRemarks.Contains("RSERVICETEST")).Count() > 0)
            {
                requisitionRepository.Delete(requisitionRepository.FindAll().Where(r => r.EmployeeRemarks.Contains("RSERVICETEST")).FirstOrDefault());
            }
        }
Ejemplo n.º 3
0
        public void RetrieveItem(string retrievalId, string email, string itemCode)
        {
            if (!retrievalRepository.ExistsById(retrievalId))
            {
                throw new ArgumentException("Retrieval does not exist");
            }

            var retrieval = retrievalRepository.FindById(retrievalId);

            if (retrievalRepository.FindById(retrievalId).Disbursements.SelectMany(d => d.DisbursementDetails.Where(dd => dd.ItemCode == itemCode)).Any(dd => dd.Status.StatusId == 18))
            {
                throw new ArgumentException("Item already retrieved");
            }

            retrieval.Disbursements.SelectMany(d => d.DisbursementDetails.Where(dd => dd.ItemCode == itemCode)).ToList().ForEach(disbursementDetail =>
            {
                disbursementDetail.Status = new StatusService(context).FindStatusByStatusId(18);
                stockmovementService.CreateStockMovement(disbursementDetail);
            });

            retrievalRepository.Save(retrieval);
        }
        public void TestCleanup()
        {
            Retrieval retrieval = context.Retrieval.Where(x => x.RetrievalId == "TEST").First();

            List <Disbursement> list = disbursementService.FindDisbursementsByRetrievalId(retrieval.RetrievalId);

            foreach (Disbursement d in list)
            {
                //Delete dummy disbursement test objects
                disbursementRepository.Delete(d);
            }

            //have to delete requisitions before retrievals
            List <Requisition> requisitionlist = context.Requisition.Where(x => x.RequisitionId == "TEST").ToList();

            foreach (Requisition r in requisitionlist)
            {
                //delete dummy requisition test objects
                requisitionRepository.Delete(r);
            }

            List <Requisition> requisitionlist2 = context.Requisition.Where(x => x.RequisitionId == "TEST2").ToList();

            foreach (Requisition r in requisitionlist2)
            {
                //delete dummy requisition test objects
                requisitionRepository.Delete(r);
            }

            //delete retrieval objects
            retrievalRepository.Delete(retrieval);
            //}

            if (disbursementRepository.ExistsById("COLLECTIONTEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("COLLECTIONTEST"));
            }
            if (disbursementRepository.ExistsById("DSERVICETEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("DSERVICETEST"));
            }
            if (requisitionRepository.ExistsById("DSERVICETEST"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("DSERVICETEST"));
            }
            if (retrievalRepository.ExistsById("DSERVICETEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("DSERVICETEST"));
            }
        }
 public void TestCleanup()
 {
     if (disbursementRepository.ExistsById("DAPICONTROLTEST"))
     {
         disbursementRepository.Delete(disbursementRepository.FindById("DAPICONTROLTEST"));
     }
     if (requisitionRepository.ExistsById("DAPICONTROLTEST"))
     {
         requisitionRepository.Delete(requisitionRepository.FindById("DAPICONTROLTEST"));
     }
     if (retrievalRepository.ExistsById("DAPICONTROLTEST"))
     {
         retrievalRepository.Delete(retrievalRepository.FindById("DAPICONTROLTEST"));
     }
 }
Ejemplo n.º 6
0
        public void TestCleanup()
        {
            var disbursementRepository = new DisbursementRepository(context);
            var retrievalRepository    = new RetrievalRepository(context);
            var requisitionRepository  = new RequisitionRepository(context);

            if (requisitionRepository.ExistsById("RETCONTROLTEST"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RETCONTROLTEST"));
            }
            if (disbursementRepository.ExistsById("RETCONTROLTEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RETCONTROLTEST"));
            }
            if (retrievalRepository.ExistsById("RETCONTROLTEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("RETCONTROLTEST"));
            }
        }
        public void TestCleanup()
        {
            var usedNotificationId = IdService.GetNewNotificationId(context) - 1;

            if (notificationRepository.ExistsById(usedNotificationId))
            {
                notificationRepository.Delete(notificationRepository.FindById(usedNotificationId));
            }


            //delete test object from Disbursements
            List <Disbursement> ddlist = context.Disbursement.Where(x => x.DisbursementId == "TEST").ToList();

            foreach (Disbursement dd in ddlist)
            {
                disbursementRepository.Delete(dd);
            }

            //delete test object from Requisitions
            List <Requisition> rlist = context.Requisition.Where(x => x.RequisitionId == "TEST").ToList();

            foreach (Requisition r in rlist)
            {
                requisitionRepository.Delete(r);
            }

            //delete test object from StockAdjustments
            List <StockAdjustment> salist = context.StockAdjustment.Where(x => x.StockAdjustmentId == "TEST").ToList();

            foreach (StockAdjustment SA in salist)
            {
                saRepository.Delete(SA);
            }

            var retrievalRepository = new RetrievalRepository(context);

            if (retrievalRepository.ExistsById("NOTIFICATIONTEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("NOTIFICATIONTEST"));
            }
        }