public CustomerAgreement Find(Customer customer)
 {
    var result = Session.CreateCriteria(typeof (CustomerAgreement))
       .Add(Restrictions.Eq("Subject", customer))
       .UniqueResult<CustomerAgreement>();         
    return result ?? CustomerAgreement.CreateEmpty(customer);
 }
Esempio n. 2
0
 /// <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);
 }
Esempio n. 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;
 }
Esempio n. 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());
 }