Esempio n. 1
0
 public ActionResult Create(JobItemViewModel viewmodel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var id = Guid.NewGuid();
             _jobItemService.CreateJobItem(
                 viewmodel.JobId,
                 id,
                 viewmodel.InstrumentId,
                 viewmodel.SerialNo,
                 viewmodel.AssetNo,
                 viewmodel.InitialStatusId,
                 viewmodel.FieldId,
                 viewmodel.CalPeriod,
                 viewmodel.Instructions,
                 viewmodel.Accessories,
                 viewmodel.IsReturned,
                 viewmodel.ReturnReason,
                 viewmodel.Comments);
             return(RedirectToAction("Details", "Job", new { id = viewmodel.JobId }));
         }
         catch (DomainValidationException dex)
         {
             ModelState.UpdateFromDomain(dex.Result);
         }
     }
     return(View(viewmodel));
 }
Esempio n. 2
0
 private void CreateJobItem(
     Guid jobId, Guid jobItemId, Guid instrumentId, string serialNo, string assetNo, Guid initialStatusId, Guid fieldId, int calPeriod,
     string instructions, string accessories, bool isReturned, string returnReason, string comments)
 {
     try
     {
         _savedJobItem = _jobItemService.CreateJobItem(
             jobId, jobItemId, instrumentId, serialNo, assetNo, initialStatusId, fieldId, calPeriod, instructions, accessories, isReturned, returnReason, comments);
     }
     catch (DomainValidationException dex)
     {
         _domainValidationException = dex;
     }
 }
        public static void CreateContext(Guid testStandardId, Guid jobItemId)
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var companyDetailsRepository = new CompanyDetailsRepository();
            var quoteRepository          = new QuoteRepository();
            var quoteItemRepository      = new QuoteItemRepository();
            var customerRepository       = new CustomerRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();

            var instrumentId      = Guid.NewGuid();
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);

            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Description", 15);

            var customerId      = Guid.NewGuid();
            var customerService = new CustomerService(userContext, customerRepository, dispatcher);

            customerService.Create(customerId, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());

            var listItemService = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobService      = new JobService(userContext, null, jobRepository, listItemRepository, customerRepository, entityIdProvider, dispatcher);
            var jobItemService  = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);

            var jobId = Guid.NewGuid();

            jobService.CreateJob(jobId, "Some instructions", "PO1000", "AD1000", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "some notes", "job contact");
            jobItemService.CreateJobItem(
                jobId, jobItemId, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
        }
Esempio n. 4
0
        public static void CreateContextForPendingItemTests(
            Guid customerId1, Guid customerId2,
            Guid job1Id, Guid job2Id, Guid job3Id,
            Guid jobItem1Id, Guid jobItem2Id, Guid jobItem3Id,
            Guid jobItem4Id, Guid jobItem5Id, Guid jobItem6Id, Guid jobItem7Id, Guid jobItem8Id, Guid jobItem9Id)
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var companyDetailsRepository = new CompanyDetailsRepository();
            var quoteRepository          = new QuoteRepository();
            var quoteItemRepository      = new QuoteItemRepository();
            var customerRepository       = new CustomerRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var currencyRepository       = new CurrencyRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();

            var instrumentId      = Guid.NewGuid();
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);

            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Description", 0);

            var customerService = new CustomerService(userContext, customerRepository, dispatcher);

            customerService.Create(customerId1, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());
            customerService.Create(customerId2, "EMIS (UK) Ltd", String.Empty, new Address(), new ContactInfo(), "EMIS (UK) Ltd", new Address(), new ContactInfo(), "EMIS (UK) Ltd", new Address(), new ContactInfo());

            var listItemService = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobService      = new JobService(userContext, null, jobRepository, listItemRepository, customerRepository, entityIdProvider, dispatcher);

            jobService.CreateJob(job1Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId1, "notes", "contact");
            jobService.CreateJob(job2Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId1, "notes", "contact");
            jobService.CreateJob(job3Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId2, "notes", "contact");

            var jobItemService = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);

            #region Job 1

            jobItemService.CreateJobItem(
                job1Id, jobItem1Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem2Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem3Id, instrumentId, "123457", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem4Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job1Id);

            #endregion
            #region Job2

            jobItemService.CreateJobItem(
                job2Id, jobItem5Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem6Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem7Id, instrumentId, "123457", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job2Id);

            #endregion
            #region Job 3

            jobItemService.CreateJobItem(
                job3Id, jobItem8Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job3Id, jobItem9Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job3Id);

            #endregion

            var quoteItemService = new QuoteItemService(userContext, quoteRepository, quoteItemRepository, jobItemRepository, listItemRepository, customerRepository, dispatcher);
            var quoteService     = new QuoteService(userContext, quoteRepository, customerRepository, entityIdProvider, currencyRepository, quoteItemService, companyDetailsRepository, dispatcher);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem1Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem3Id, 45, 65, 35, 22, 87, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem2Id, 45, 60, 30, 26, 56, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem4Id, 45, 65, 35, 22, 87, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem5Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem6Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem7Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId2, jobItem8Id, 25, 35, 45, 25, 56, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId2, jobItem9Id, 25, 35, 45, 25, 56, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteService.CreateQuotesFromPendingItems();

            foreach (var quote in quoteService.GetQuotes())
            {
                foreach (var quoteItem in quoteItemService.GetQuoteItems(quote.Id))
                {
                    quoteItemService.Accept(quoteItem.Id);
                }
            }
        }
        public static void CreateContextForPendingItemTests(
            Guid job1Id, Guid job2Id, Guid job3Id, Guid supplier1Id, Guid supplier2Id, Guid supplier3Id,
            Guid jobItem1Id, Guid jobItem2Id, Guid jobItem3Id, Guid jobItem4Id, Guid jobItem5Id, Guid jobItem6Id, Guid jobItem7Id)
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var consignmentRepository     = new ConsignmentRepository();
            var consignmentItemRepository = new ConsignmentItemRepository();
            var supplierRepository        = new SupplierRepository();
            var jobRepository             = new JobRepository();
            var jobItemRepository         = new JobItemRepository();
            var listItemRepository        = new ListItemRepository();
            var customerRepository        = new CustomerRepository();
            var entityIdProvider          = new DirectEntityIdProvider();
            var instrumentRepository      = new InstrumentRepository();

            var instrumentId      = Guid.NewGuid();
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);

            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Description", 15);

            var customerId      = Guid.NewGuid();
            var customerService = new CustomerService(userContext, customerRepository, dispatcher);

            customerService.Create(customerId, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());

            var supplierService = new SupplierService(userContext, supplierRepository, dispatcher);

            supplierService.Create(supplier1Id, "Supplier 1", new Address(), new ContactInfo(), new Address(), new ContactInfo());
            supplierService.Create(supplier2Id, "Supplier 2", new Address(), new ContactInfo(), new Address(), new ContactInfo());
            supplierService.Create(supplier3Id, "Supplier 3", new Address(), new ContactInfo(), new Address(), new ContactInfo());

            var listItemService = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobService      = new JobService(userContext, null, jobRepository, listItemRepository, customerRepository, entityIdProvider, dispatcher);

            jobService.CreateJob(job1Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "notes", "contact");
            jobService.CreateJob(job2Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "notes", "contact");
            jobService.CreateJob(job3Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "notes", "contact");

            var jobItemService = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);

            jobItemService.CreateJobItem(
                job1Id, jobItem1Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem2Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem3Id, instrumentId, "123457", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem4Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem5Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem6Id, instrumentId, "1234567", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job3Id, jobItem7Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job1Id);
            jobService.ApproveJob(job2Id);
            jobService.ApproveJob(job3Id);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            CreateDatabase();
            InitialiseNHibernateSessions();

            var queueDispatcher       = new NullQueueDispatcher();
            var initialUserContext    = new TestUserContext(TestUserContext.CreateAdminUser());
            var userManagementService = new UserManagementService(initialUserContext, new UserAccountRepository(), new CryptographicService(), queueDispatcher);
            var adminUser             = userManagementService.GetUsers().Where(u => u.EmailAddress == "*****@*****.**").Single();

            var testUserContext = new TestUserContext(adminUser);
            var currentUser     = testUserContext.GetCurrentUser();
            var listItemService = new ListItemService(testUserContext, new ListItemRepository(), queueDispatcher);
            var customerService = new CustomerService(testUserContext, new CustomerRepository(), queueDispatcher);
            var jobService      = new JobService(
                testUserContext, new FileSystemAttachmentStorage(), new JobRepository(), new ListItemRepository(), new CustomerRepository(), new EntityIdProvider(), queueDispatcher);
            var jobItemService = new JobItemService(
                testUserContext, new JobRepository(), new JobItemRepository(),
                new ListItemService(testUserContext, new ListItemRepository(), queueDispatcher),
                new InstrumentService(testUserContext, new InstrumentRepository(), queueDispatcher),
                queueDispatcher);
            var instrumentService         = new InstrumentService(testUserContext, new InstrumentRepository(), queueDispatcher);
            var supplierService           = new SupplierService(testUserContext, new SupplierRepository(), queueDispatcher);
            var consignmentItemRepository = new ConsignmentItemService(
                testUserContext,
                new ConsignmentRepository(),
                new ConsignmentItemRepository(),
                new JobItemRepository(),
                new ListItemRepository(),
                new SupplierRepository(),
                queueDispatcher);
            var directEntityIdProvider = new DirectEntityIdProvider();
            var certificateService     = new CertificateService(
                testUserContext, new JobItemRepository(), new CertificateRepository(), new ListItemRepository(), directEntityIdProvider, queueDispatcher);
            var jobId        = Guid.NewGuid();
            var jobItemId    = Guid.NewGuid();
            var customerId   = Guid.NewGuid();
            var supplierId   = Guid.NewGuid();
            var instrumentId = Guid.NewGuid();

            NHibernateSession.Current.BeginTransaction();
            supplierService.Create(supplierId, "Gael Ltd", new Address(), new ContactInfo(), new Address(), new ContactInfo());
            customerService.Create(customerId, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());
            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Digital Pressure Indicator", 0);
            jobService.CreateJob(jobId, "job instructions", "ORDER12345", "ADVICE12345", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "job notes", "job contact");
            jobItemService.CreateJobItem(
                jobId, jobItemId, instrumentId, "12345", "AST12345", listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id, 12,
                "job instructions", "accessories", false, String.Empty, "comments");
            jobService.ApproveJob(jobId);

            NHibernateSession.Current.Transaction.Commit();
            NHibernateSession.Current.BeginTransaction();
            certificateService.Create(
                Guid.NewGuid(),
                listItemService.GetByType(ListItemType.CertificateTypeHouse).Id,
                listItemService.GetByType(ListItemType.CategoryDensity).Id,
                jobItemId,
                "001");
            NHibernateSession.Current.Transaction.Commit();
        }