示例#1
0
 partial void OnPaymentCodeChanged()
 {
     if (!string.IsNullOrEmpty(_PaymentCode))
     {
         _PaymentCode = PaymentCode.TextEncode();
     }
 }
示例#2
0
        /// <summary>
        /// Generate a payment code by CarPass rules
        /// [1-9][00-99][0000-9999][0-9]
        /// Era  Gen    Random     Mod11
        /// where the random part is garanteed not consecutive for any couple of calls
        /// </summary>
        /// <returns></returns>
        public static string NextPaymentCode(TransactionModelContainer container)
        {
            PaymentCode code = container.PaymentCodes.FirstOrDefault(pc => !pc.IsUsed);

            if (code == null)
            {
                throw new ApplicationException("NO_MORE_PAYMENT_CODE_AVAILABLE");
            }

            code.IsUsed = true;
            return(code.Code);
        }
示例#3
0
        public override int SaveChanges(SaveOptions options)
        {
            foreach (ObjectStateEntry entry in
                     ObjectStateManager.GetObjectStateEntries(
                         EntityState.Added | EntityState.Modified))
            {
                if (entry.Entity is Configuration)
                {
                    ValidateConfigurationAggregate((Configuration)entry.Entity);
                }
                else if (entry.Entity is Payment)
                {
                    ValidatePaymentAggregate((Payment)entry.Entity);

                    if (entry.State == EntityState.Added)
                    {
                        Payment payment = (Payment)entry.Entity;
                        payment.PaymentCode = PaymentCode.NextPaymentCode(this);
                    }
                }
            }

            return(base.SaveChanges(options));
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the PaymentCodes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPaymentCodes(PaymentCode paymentCode)
 {
     base.AddObject("PaymentCodes", paymentCode);
 }
 /// <summary>
 /// Create a new PaymentCode object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="code">Initial value of the Code property.</param>
 /// <param name="isUsed">Initial value of the IsUsed property.</param>
 /// <param name="version">Initial value of the Version property.</param>
 public static PaymentCode CreatePaymentCode(global::System.Int32 id, global::System.String code, global::System.Boolean isUsed, global::System.Byte[] version)
 {
     PaymentCode paymentCode = new PaymentCode();
     paymentCode.Id = id;
     paymentCode.Code = code;
     paymentCode.IsUsed = isUsed;
     paymentCode.Version = version;
     return paymentCode;
 }