Ejemplo n.º 1
0
        public void Update(TransactionBdo transactionBdo)
        {
            try
            {
                using (var db = new GiftServiceEntities())
                {
                    var t = db.transactions.First(x => x.id == transactionBdo.Id);

                    t.is_payment_processed   = transactionBdo.IsPaymentProcessed;
                    t.is_test_payment        = transactionBdo.IsTestPayment;
                    t.paid_amount            = transactionBdo.PaidAmount;
                    t.paid_currency_code     = transactionBdo.PaidCurrencyCode;
                    t.paid_through           = transactionBdo.PaidThrough;
                    t.payment_status_id      = (int)transactionBdo.PaymentStatus;
                    t.pay_system_id          = (int)transactionBdo.PaymentSystem;
                    t.pay_system_response_at = transactionBdo.PaySystemResponseAt;
                    t.pay_system_uid         = transactionBdo.PaySystemUid;
                    t.pos_id                  = transactionBdo.PosId;
                    t.pos_user_uid            = transactionBdo.PosUserUid;
                    t.product_id              = transactionBdo.ProductId;
                    t.product_uid             = transactionBdo.ProductUid;
                    t.project_id              = transactionBdo.ProjectId.ToString();
                    t.p_email                 = transactionBdo.PayerEmail;
                    t.p_lastname              = transactionBdo.PayerLastName;
                    t.p_name                  = transactionBdo.PayerName;
                    t.p_phone                 = transactionBdo.PayerPhone;
                    t.remarks                 = transactionBdo.Remarks;
                    t.requested_amount        = transactionBdo.RequestedAmount;
                    t.requested_currency_code = transactionBdo.RequestedCurrencyCode;
                    t.response_from_payment   = transactionBdo.ResponseFromPaymentSystem;

                    db.SaveChanges();
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbvex)
            {
                Logger.Error("Validation error updating transaction", dbvex);
                foreach (var e in dbvex.EntityValidationErrors)
                {
                    foreach (var sub in e.ValidationErrors)
                    {
                        Logger.ErrorFormat("  {0,-16}: {1}", sub.PropertyName, sub.ErrorMessage);
                    }
                }
                throw;
            }
        }
Ejemplo n.º 2
0
        public void MakeProductGift(ProductBdo product, string friendEmail, string text)
        {
            using (var db = new GiftServiceEntities())
            {
                var p = db.products.First(x => x.product_uid == product.ProductUid);
                if (String.IsNullOrEmpty(p.gift_email) == false)
                {
                    // Throw exception if product was sent to other e-mail
                    if (p.gift_email.Equals(friendEmail, StringComparison.OrdinalIgnoreCase) == false)
                    {
                        throw new Models.Exceptions.InvalidProductException(String.Concat("Product was sent to other e-mail: ", p.gift_email), Models.Exceptions.InvalidProductException.Reasons.ProductIsGiftAlready);
                    }
                }

                p.gift_email = friendEmail;
                p.gift_text  = text;

                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void StartTransaction(TransactionBdo t)
        {
            //Mapper.CreateMap<TransactionBdo, transaction>()
            //    .ForMember(dest => dest.payment_status_id,
            //        orig => orig.MapFrom(x => (int)x.PaymentStatus));
            //AutoMapperConfigDal.SetMappingTypeFromBdoToDao();
            //var transaction = Mapper.Map<transaction>(t);
            try
            {
                var transaction = new transaction();
                transaction.is_test_payment         = t.IsTestPayment;
                transaction.payment_status_id       = (int)t.PaymentStatus;
                transaction.is_payment_processed    = t.IsPaymentProcessed;
                transaction.pos_user_uid            = t.PosUserUid;
                transaction.pay_system_uid          = t.PaySystemUid;
                transaction.order_nr                = t.OrderNr;
                transaction.requested_amount        = t.RequestedAmount;
                transaction.requested_currency_code = t.RequestedCurrencyCode;
                transaction.paid_amount             = t.PaidAmount;
                transaction.paid_currency_code      = t.PaidCurrencyCode;
                transaction.paid_through            = t.PaidThrough;
                transaction.p_name      = t.PayerName;
                transaction.p_lastname  = t.PayerLastName;
                transaction.p_email     = t.PayerEmail;
                transaction.p_phone     = t.PayerPhone;
                transaction.remarks     = t.Remarks;
                transaction.pos_id      = t.PosId;
                transaction.product_id  = t.ProductId;
                transaction.product_uid = t.ProductUid;
                transaction.project_id  = t.ProjectId.ToString();
                transaction.created_at  = DateTime.UtcNow;

                Logger.Info("Saving transaction in DB:");
                Logger.DebugFormat("  setting is_test_payment:              `{0}`", transaction.is_test_payment);
                Logger.DebugFormat("  setting payment_status_id:            `{0}`", transaction.payment_status_id);
                Logger.DebugFormat("  setting is_payment_processed:         `{0}`", transaction.is_payment_processed);
                Logger.DebugFormat("  setting pos_user_uid:                 `{0}`", transaction.pos_user_uid);
                Logger.DebugFormat("  setting pay_system_uid:               `{0}`", transaction.pay_system_uid);
                Logger.DebugFormat("  setting order_nr:                     `{0}`", transaction.order_nr);

                Logger.DebugFormat("  setting requested_amount:             `{0}`", transaction.requested_amount);
                Logger.DebugFormat("  setting requested_currency_code:      `{0}`", transaction.requested_currency_code);
                Logger.DebugFormat("  setting paid_amount:                  `{0}`", transaction.paid_amount);
                Logger.DebugFormat("  setting paid_currency_code:           `{0}`", transaction.paid_currency_code);
                Logger.DebugFormat("  setting paid_through:                 `{0}`", transaction.paid_through);

                Logger.DebugFormat("  setting p_name:                       `{0}`", transaction.p_name);
                Logger.DebugFormat("  setting p_lastname:                   `{0}`", transaction.p_lastname);
                Logger.DebugFormat("  setting p_email:                      `{0}`", transaction.p_email);
                Logger.DebugFormat("  setting p_phone:                      `{0}`", transaction.p_phone);
                Logger.DebugFormat("  setting remarks:                      `{0}`", transaction.remarks);

                Logger.DebugFormat("  setting pos_id:                       `{0}`", transaction.pos_id);
                Logger.DebugFormat("  setting product_id:                   `{0}`", transaction.product_id);
                Logger.DebugFormat("  setting product_uid:                  `{0}`", transaction.product_uid);

                Logger.DebugFormat("  setting response_from_payment:        `{0}`", transaction.response_from_payment);
                Logger.DebugFormat("  setting pay_system_response_at:       `{0}`", transaction.pay_system_response_at);
                Logger.DebugFormat("  setting created_at:                   `{0}`", transaction.created_at);

                using (var db = new GiftServiceEntities())
                {
                    db.transactions.Add(transaction);
                    db.SaveChanges();
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbvex)
            {
                Logger.Error("Validation error saving transaction", dbvex);
                foreach (var e in dbvex.EntityValidationErrors)
                {
                    foreach (var sub in e.ValidationErrors)
                    {
                        Logger.ErrorFormat("  {0,-16}: {1}", sub.PropertyName, sub.ErrorMessage);
                    }
                }
                throw;
            }
        }
Ejemplo n.º 4
0
        public ProductBdo SaveProductInformationFromPos(ProductBdo product, PosBdo pos)
        {
            var p = new product();

            try
            {
                //AutoMapperConfigDal.SetMappingTypeFromBdoToDao();
                //p = Mapper.Map<product>(product);

                p.pos_user_uid   = product.PosUserUid;
                p.pay_system_uid = product.PaySystemUid;

                p.product_uid         = product.ProductUid;
                p.product_name        = product.ProductName;
                p.product_description = product.ProductDescription;
                p.product_duration    = product.ProductDuration;
                Logger.DebugFormat("  setting product_duration to: `{0}`", p.product_duration);
                p.product_price = product.ProductPrice;
                p.currency_code = product.CurrencyCode;

                p.customer_name  = product.CustomerName;
                p.customer_phone = product.CustomerPhone;
                p.customer_email = product.CustomerEmail;
                p.remarks        = product.Remarks;

                p.email_reservation = product.EmailForReservation;
                p.phone_reservation = product.PhoneForReservation;

                p.pos_id      = product.PosId;
                p.pos_name    = product.PosName;
                p.pos_address = product.PosAddress;
                p.pos_city    = product.PosCity;

                p.valid_from = product.ValidFrom;
                p.valid_till = product.ValidTill;

                Logger.Info("Saving product:");
                Logger.DebugFormat("  pos_user_uid:          `{0}`", p.pos_user_uid);
                Logger.DebugFormat("  pay_system_uid:        `{0}`", p.pay_system_uid);

                Logger.DebugFormat("  product_uid:           `{0}`", p.product_uid);
                Logger.DebugFormat("  product_name:          `{0}`", p.product_name);
                Logger.DebugFormat("  product_description:   `{0}`", p.product_description);
                Logger.DebugFormat("  product_duration:      `{0}`", p.product_duration);
                Logger.DebugFormat("  product_price:         `{0}`", p.product_price);
                Logger.DebugFormat("  currency_code:         `{0}`", p.currency_code);

                Logger.DebugFormat("  customer_name:         `{0}`", p.customer_name);
                Logger.DebugFormat("  customer_phone:        `{0}`", p.customer_phone);
                Logger.DebugFormat("  customer_email:        `{0}`", p.customer_email);
                Logger.DebugFormat("  remarks:               `{0}`", p.remarks);

                Logger.DebugFormat("  email_reservation:     `{0}`", p.email_reservation);
                Logger.DebugFormat("  phone_reservation:     `{0}`", p.phone_reservation);

                Logger.DebugFormat("  pos_id:                `{0}`", p.pos_id);
                Logger.DebugFormat("  pos_name:              `{0}`", p.pos_name);
                Logger.DebugFormat("  pos_city:              `{0}`", p.pos_city);
                Logger.DebugFormat("  pos_address:           `{0}`", p.pos_address);
                Logger.DebugFormat("  valid_from:            `{0}`", p.valid_from);
                Logger.DebugFormat("  valid_till:            `{0}`", p.valid_till);
                //Logger.DebugFormat("  PaymentSystem:        `{0}`", p.Pay);
                using (var db = new GiftServiceEntities())
                {
                    db.products.Add(p);
                    db.SaveChanges();
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbvex)
            {
                Logger.Error("Validation error saving product", dbvex);
                foreach (var e in dbvex.EntityValidationErrors)
                {
                    foreach (var sub in e.ValidationErrors)
                    {
                        Logger.ErrorFormat("  {0,-16}: {1}", sub.PropertyName, sub.ErrorMessage);
                    }
                }
                throw;
            }

            return(product);
        }