コード例 #1
0
 public CustomerAgreement Find(Customer customer)
 {
    var result = Session.CreateCriteria(typeof (CustomerAgreement))
       .Add(Restrictions.Eq("Subject", customer))
       .UniqueResult<CustomerAgreement>();         
    return result ?? CustomerAgreement.CreateEmpty(customer);
 }
コード例 #2
0
ファイル: Cargo.cs プロジェクト: ssajous/DDDSample.Net
 /// <summary>
 /// Creates new <see cref="Cargo"/> object with provided tracking id and route specification.
 /// </summary>
 /// <param name="trackingId">Tracking id of this cargo.</param>
 /// <param name="routeSpecification">Route specification.</param>
 /// <param name="orderingCustomer">Customer who ordered this cargo.</param>
 public Cargo(TrackingId trackingId, RouteSpecification routeSpecification, Customer orderingCustomer)
 {
    if (trackingId == null)
    {
       throw new ArgumentNullException("trackingId");
    }
    if (routeSpecification == null)
    {
       throw new ArgumentNullException("routeSpecification");
    }
    OrderingCustomer = orderingCustomer;
    TrackingId = trackingId;
    RouteSpecification = routeSpecification;
    Delivery = Delivery.DerivedFrom(RouteSpecification, Itinerary, null);
 }
コード例 #3
0
 /// <summary>
 /// Creates new customer agreement.
 /// </summary>
 /// <param name="subject"></param>
 /// <param name="routingPolicy"></param>
 public CustomerAgreement(Customer subject, IRoutingPolicy routingPolicy)
 {
    Subject = subject;
    RoutingPolicy = routingPolicy;
 }
コード例 #4
0
 /// <summary>
 /// Creates an empty customer agreement (with null policies)
 /// for use with customers who didn't signed an agreement.
 /// </summary>
 /// <param name="subject">Customer without agreement.</param>
 /// <returns></returns>
 public static CustomerAgreement CreateEmpty(Customer subject)
 {
    return new CustomerAgreement(subject, new NullRoutingPolicy());
 }