Esempio n. 1
0
        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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        private string GetCertificateNumber(Guid categoryId)
        {
            var certificateNumber = _entityIdProvider.GetIdFor <Certificate>();
            var number            = new string(certificateNumber.Where(Char.IsDigit).ToArray());
            var category          = _listItemRepository.GetById(categoryId);

            return(string.Format("{0}{1}", category.Name[0], number));
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        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);
        }