コード例 #1
0
ファイル: JobOrder.cs プロジェクト: zszqwe/Merp
            public static JobOrder RegisterNew(IJobOrderNumberGenerator jobOrderNumberGenerator, Guid customerId, string customerName, Guid?contactPersonId, Guid managerId, decimal?price, string currency, DateTime dateOfStart, DateTime dueDate, bool isTimeAndMaterial, string name, string purchaseOrderNumber, string description, Guid userId)
            {
                if (jobOrderNumberGenerator == null)
                {
                    throw new ArgumentNullException(nameof(jobOrderNumberGenerator));
                }
                if (price < 0)
                {
                    throw new ArgumentException("The price must be zero or higher", nameof(price));
                }
                if (string.IsNullOrWhiteSpace(currency))
                {
                    throw new ArgumentException("The currency must me specified", nameof(currency));
                }
                if (dueDate < dateOfStart)
                {
                    throw new ArgumentException("The due date cannot precede the starting date", nameof(dueDate));
                }
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentException("The job order must have a name", nameof(name));
                }

                var @event = new JobOrderRegisteredEvent(
                    Guid.NewGuid(),
                    customerId,
                    customerName,
                    contactPersonId,
                    managerId,
                    price,
                    currency,
                    DateTime.Now,
                    dateOfStart,
                    dueDate,
                    isTimeAndMaterial,
                    name,
                    jobOrderNumberGenerator.Generate(),
                    purchaseOrderNumber,
                    description,
                    userId
                    );
                var jobOrder = new JobOrder();

                jobOrder.RaiseEvent(@event);
                return(jobOrder);
            }
コード例 #2
0
ファイル: JobOrder.cs プロジェクト: zszqwe/Merp
            public static JobOrder Import(Guid jobOrderId, string jobOrderNumber, Guid customerId, string customerName, Guid?contactPersonId, Guid managerId, decimal?price, string currency, DateTime dateOfRegistration, DateTime dateOfStart, DateTime dueDate, bool isTimeAndMaterial, string name, string purchaseOrderNumber, string description)
            {
                if (string.IsNullOrWhiteSpace(jobOrderNumber))
                {
                    throw new ArgumentNullException(nameof(jobOrderNumber), "A job order number must be provided");
                }
                if (price < 0 && price != -1)
                {
                    throw new ArgumentException("The price must be zero or higher", nameof(price));
                }
                if (string.IsNullOrWhiteSpace(currency))
                {
                    throw new ArgumentException("The currency must me specified", nameof(currency));
                }
                if (dueDate < dateOfStart)
                {
                    throw new ArgumentException("The due date cannot precede the starting date", nameof(dueDate));
                }
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentException("The job order must have a name", nameof(name));
                }

                var @event = new JobOrderRegisteredEvent(
                    jobOrderId,
                    customerId,
                    customerName,
                    contactPersonId,
                    managerId,
                    price,
                    currency,
                    dateOfRegistration,
                    dateOfStart,
                    dueDate,
                    isTimeAndMaterial,
                    name,
                    jobOrderNumber,
                    purchaseOrderNumber,
                    description,
                    Guid.Empty);
                var jobOrder = new JobOrder();

                jobOrder.RaiseEvent(@event);
                return(jobOrder);
            }