コード例 #1
0
        public Quote Create(Guid id, Guid customerId, string orderNumber, string adviceNumber, Guid currencyId)
        {
            if (!CurrentUser.HasRole(UserRole.Manager))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance);
            }
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the quote");
            }
            var quote = new Quote();

            quote.Id           = id;
            quote.QuoteNumber  = _entityIdProvider.GetIdFor <Quote>();
            quote.Customer     = GetCustomer(customerId);
            quote.CreatedBy    = CurrentUser;
            quote.DateCreated  = AppDateTime.GetUtcNow();
            quote.OrderNumber  = orderNumber;
            quote.AdviceNumber = adviceNumber;
            quote.Currency     = GetCurrency(currencyId);
            quote.IsActive     = true;
            quote.Revision     = 1;
            ValidateAnnotatedObjectThrowOnFailure(quote);
            _quoteRepository.Create(quote);
            return(quote);
        }
コード例 #2
0
ファイル: InvoiceService.cs プロジェクト: mazj/JobSystem
        public Invoice Create(Guid id, Guid currencyId, Guid customerId, Guid bankDetailsId, Guid paymentTermId, Guid taxCodeId, string orderNo)
        {
            if (!CurrentUser.HasRole(UserRole.Manager))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance);
            }
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the invoice.");
            }
            var invoice = new Invoice();

            invoice.Id            = id;
            invoice.InvoiceNumber = _entityIdProvider.GetIdFor <Invoice>();
            invoice.DateCreated   = AppDateTime.GetUtcNow();
            invoice.OrderNo       = orderNo;
            invoice.Currency      = GetCurrency(currencyId);
            invoice.Customer      = GetCustomer(customerId);
            invoice.BankDetails   = GetBankDetails(bankDetailsId);
            invoice.PaymentTerm   = GetPaymentTerm(paymentTermId);
            invoice.TaxCode       = GetTaxCode(taxCodeId);
            ValidateAnnotatedObjectThrowOnFailure(invoice);
            _invoiceRepository.Create(invoice);
            return(invoice);
        }
コード例 #3
0
ファイル: OrderItemService.cs プロジェクト: mazj/JobSystem
        public OrderItem MarkReceived(Guid orderItemId)
        {
            var orderItem = GetById(orderItemId);

            orderItem.DateReceived = AppDateTime.GetUtcNow();
            var jobItem = orderItem.JobItem;

            jobItem.Status = _listItemRepository.GetByType(ListItemType.StatusPartsReceived);
            _orderItemRepository.Update(orderItem);
            _jobItemRepository.EmitItemHistory(
                CurrentUser, jobItem.Id, 0, 0, string.Format("Parts received from order {0}", orderItem.Order.OrderNo), ListItemType.StatusPartsReceived, ListItemType.WorkTypeAdministration);
            _jobItemRepository.Update(jobItem);
            return(orderItem);
        }
コード例 #4
0
        public void TestForItem_NoReduction()
        {
            var item = new ItemBuilder()
                       .WithName("supplement d3")
                       .WithPrice(80)
                       .Build();

            var pairDateTime = new AppDateTime
            {
                Now = new DateTime(2020, 7, 13)
            };

            var discountEngine = new DiscountEngine(new MarketingCampaign(pairDateTime));

            discountEngine.ApplyDiscountFor(item);

            Assert.True(item.Price.Equals(new Money(80) % NoDiscountStrategy.Percentage));
        }
コード例 #5
0
        public void TestForItem_5pReduction()
        {
            var item = new ItemBuilder()
                       .WithName("sauce tomate")
                       .WithPrice(210)
                       .Build();

            var pairDateTime = new AppDateTime
            {
                Now = new DateTime(2020, 7, 9, 3, 57, 32, 12)
            };

            var discountEngine = new DiscountEngine(new MarketingCampaign(pairDateTime));

            discountEngine.ApplyDiscountFor(item);

            Assert.True(item.Price.Equals(new Money(210) % ThirdTierDiscountStrategy.Percentage));
        }
コード例 #6
0
        public void TestForItem_10pReduction()
        {
            var item = new ItemBuilder()
                       .WithName("spaghetti")
                       .WithPrice(1500)
                       .Build();

            var aMonday = new AppDateTime
            {
                Now = new DateTime(2020, 7, 13)
            };

            var discountEngine = new DiscountEngine(new MarketingCampaign(aMonday));

            discountEngine.ApplyDiscountFor(item);

            Assert.True(item.Price.Equals(new Money(1500) % SecondTierDiscountStrategy.Percentage));
        }
コード例 #7
0
        public void TestForItem_15pReduction()
        {
            var item = new ItemBuilder()
                       .WithName("les pattes")
                       .WithPrice(100)
                       .Build();

            var aFriday = new AppDateTime
            {
                Now = new DateTime(2020, 7, 10)
            };

            var discountEngine = new DiscountEngine(new MarketingCampaign(aFriday));

            discountEngine.ApplyDiscountFor(item);

            Assert.True(item.Price.Equals(new Money(100) % FirstTierDiscountStrategy.Percentage));
        }
コード例 #8
0
ファイル: ConsignmentService.cs プロジェクト: mazj/JobSystem
        public Consignment Create(Guid id, Guid supplierId)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the consignment.");
            }
            if (!CurrentUser.HasRole(UserRole.Member))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance);
            }
            var consignment = new Consignment();

            consignment.Id            = id;
            consignment.DateCreated   = AppDateTime.GetUtcNow();
            consignment.Supplier      = GetSupplier(supplierId);
            consignment.CreatedBy     = CurrentUser;
            consignment.ConsignmentNo = _entityIdProvider.GetIdFor <Consignment>();
            _consignmentRepository.Create(consignment);
            return(consignment);
        }
コード例 #9
0
ファイル: JobItemRepository.cs プロジェクト: mazj/JobSystem
        public void EmitItemHistory(UserAccount createdBy, Guid jobItemId, int workTime, int overTime, string report, ListItemType workStatus, ListItemType workType)
        {
            var jobItem      = CurrentSession.Get <JobItem>(jobItemId);
            var status       = CurrentSession.Query <ListItem>().Where(li => li.Type == workStatus).Single();
            var workTypeItem = CurrentSession.Query <ListItem>().Where(li => li.Type == workType).Single();
            var itemHistory  = new ItemHistory
            {
                Id          = Guid.NewGuid(),
                DateCreated = AppDateTime.GetUtcNow(),
                JobItem     = jobItem,
                User        = createdBy,
                WorkTime    = workTime,
                OverTime    = overTime,
                Report      = report,
                Status      = status,
                WorkType    = workTypeItem
            };

            CurrentSession.Save(itemHistory);
        }
コード例 #10
0
ファイル: JobService.cs プロジェクト: mazj/JobSystem
        public Job CreateJob(Guid id, string instructions, string orderNo, string adviceNo, Guid typeId, Guid customerId, string notes, string contact)
        {
            var job = new Job();

            job.Id           = id;
            job.CreatedBy    = CurrentUser;
            job.DateCreated  = AppDateTime.GetUtcNow();
            job.Instructions = instructions;
            job.OrderNo      = orderNo;
            job.AdviceNo     = adviceNo;
            job.Customer     = GetCustomer(customerId);
            job.Type         = GetType(typeId);
            job.JobNo        = _entityIdProvider.GetIdFor <Job>();
            job.Notes        = notes;
            job.Contact      = contact;
            job.IsPending    = true;
            ValidateAnnotatedObjectThrowOnFailure(job);
            _jobRepository.Create(job);
            return(job);
        }
コード例 #11
0
        public Delivery Create(Guid id, Guid customerId, string fao)
        {
            if (!CurrentUser.HasRole(UserRole.Member))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance, "CurrentUser");
            }
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the pending item.");
            }
            var delivery = new Delivery();

            delivery.Id = id;
            delivery.DeliveryNoteNumber = _entityIdProvider.GetIdFor <Delivery>();
            delivery.Customer           = GetCustomer(customerId);
            delivery.CreatedBy          = CurrentUser;
            delivery.DateCreated        = AppDateTime.GetUtcNow();
            delivery.Fao = fao;
            ValidateAnnotatedObjectThrowOnFailure(delivery);
            _deliveryRepository.Create(delivery);
            return(delivery);
        }
コード例 #12
0
ファイル: OrderService.cs プロジェクト: mazj/JobSystem
        public Order Create(Guid id, Guid supplierId, string instructions, Guid currencyId)
        {
            if (!CurrentUser.HasRole(UserRole.Member))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance);
            }
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the order");
            }
            var order = new Order();

            order.Id           = id;
            order.OrderNo      = _entityIdProvider.GetIdFor <Order>();
            order.DateCreated  = AppDateTime.GetUtcNow();
            order.CreatedBy    = CurrentUser;
            order.Supplier     = GetSupplier(supplierId);
            order.Instructions = instructions;
            order.Currency     = GetCurrency(currencyId);
            ValidateAnnotatedObjectThrowOnFailure(order);
            _orderRepository.Create(order);
            return(order);
        }
コード例 #13
0
        public JobItem 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)
        {
            if (jobItemId == Guid.Empty)
            {
                throw new ArgumentException("A valid ID must be supplied for the job item ID");
            }
            var jobItem = new JobItem
            {
                Id                    = jobItemId,
                ItemNo                = _jobRepository.GetJobItemCount(jobId) + 1,
                Created               = AppDateTime.GetUtcNow(),
                CreatedUser           = CurrentUser,
                Instrument            = _instrumentService.GetById(instrumentId),
                SerialNo              = serialNo,
                AssetNo               = assetNo,
                InitialStatus         = _listItemService.GetById(initialStatusId),
                Status                = _listItemService.GetByName("Booked In"),
                Field                 = _listItemService.GetById(fieldId),
                CalPeriod             = ValidateCalPeriod(calPeriod),
                Instructions          = instructions,
                Accessories           = accessories,
                IsReturned            = isReturned,
                ReturnReason          = returnReason,
                Comments              = comments,
                ProjectedDeliveryDate = AppDateTime.GetUtcNow().AddDays(30)
            };

            ValidateAnnotatedObjectThrowOnFailure(jobItem);
            var job = GetJob(jobId);

            jobItem.Job = job;
            _jobItemRepository.Create(jobItem);
            return(jobItem);
        }
コード例 #14
0
ファイル: CertificateService.cs プロジェクト: mazj/JobSystem
        public Certificate Create(Guid id, Guid certificateTypeId, Guid categoryId, Guid jobItemId, string procedureList)
        {
            if (!CurrentUser.HasRole(UserRole.Member))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance, "CurrentUser");
            }
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the certificate");
            }
            var certificate = new Certificate();

            certificate.Id                = id;
            certificate.JobItem           = GetJobItem(jobItemId);
            certificate.DateCreated       = AppDateTime.GetUtcNow();
            certificate.CreatedBy         = CurrentUser;
            certificate.Type              = GetCertificateType(certificateTypeId);
            certificate.Category          = GetCategory(categoryId);
            certificate.ProcedureList     = procedureList;
            certificate.CertificateNumber = GetCertificateNumber(categoryId);
            ValidateAnnotatedObjectThrowOnFailure(certificate);
            _certificateRepository.Create(certificate);
            return(certificate);
        }
コード例 #15
0
 public MarketingCampaign(AppDateTime appDateTime)
 {
     _appDateTime = appDateTime;
 }