Example #1
0
        public Guid CreateOrderFromConsignment(Guid consignmentId)
        {
            var orderId     = Guid.NewGuid();
            var consignment = _consignmentRepository.GetById(consignmentId);
            var items       = _consignmentRepository.GetConsignmentItems(consignmentId);

            Create(orderId, consignment.Supplier.Id, String.Empty, GetDefaultCurrencyId());
            foreach (var item in items)
            {
                var instrument  = item.JobItem.Instrument;
                var description = String.Format("{0}, {1}, {2}", instrument.Manufacturer, instrument.ModelNo, instrument.Description);
                _orderItemService.CreateFromConsignment(
                    Guid.NewGuid(), orderId, description, 1, String.Empty, item.Instructions ?? String.Empty, 30, item.JobItem.Id, 0);
            }
            consignment.IsOrdered = true;
            _consignmentRepository.Update(consignment);
            return(orderId);
        }
Example #2
0
        public Consignment Edit(Guid consignmentId, Guid supplierId)
        {
            if (!CurrentUser.HasRole(UserRole.Admin | UserRole.Manager))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance);
            }
            var consignment = GetById(consignmentId);

            if (consignment == null)
            {
                throw new ArgumentException("A valid consignment ID must be supplied");
            }
            if (consignment.IsOrdered)
            {
                throw new DomainValidationException(Messages.ConsignmentIsOrdered);
            }
            consignment.Supplier = GetSupplier(supplierId);
            _consignmentRepository.Update(consignment);
            return(consignment);
        }