Example #1
0
        public Supplier Create(
            Guid id, string name, Address tradingAddressDetails, ContactInfo tradingContactInfo, Address salesAddressDetails, ContactInfo salesContactInfo)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the supplier.");
            }
            var supplier = new Supplier();

            supplier.Id   = id;
            supplier.Name = name;
            PopulateTradingAddressInfo(supplier, tradingAddressDetails);
            PopulateTradingContactInfo(supplier, tradingContactInfo);
            PopulateSalesAddressInfo(supplier, salesAddressDetails);
            PopulateSalesContactInfo(supplier, salesContactInfo);
            ValidateAnnotatedObjectThrowOnFailure(supplier);
            _supplierValidator.ValidateThrowOnFailure(supplier);
            _supplierRepository.Create(supplier);
            return(supplier);
        }