Пример #1
0
        public async Task<String> AddTransaction3(Transaction foo)
        {



            var httpRequest = HttpContext.Current.Request;





            try
            {
                var _db = new ApplicationDbContext();
                //  string currentUserId = User.Identity.GetUserId();
                Transaction aaa = new Transaction();
                aaa.amount = foo.amount;
                aaa.Bank_Code = foo.Bank_Code;
                aaa.Institution_Code = foo.Institution_Code;
                aaa.Payment_Status = "Pending";
                //if (foo.Transaction_Status == "Approved")
                //{
                //    aaa.Payment_Status = "Paid";
                //}

                //else
                //{

                //    aaa.Payment_Status = "error";
                //}
                aaa.Subscription_Code = foo.Subscription_Code;
                //  aaa.Transaction_Code = Generate15UniqueDigits();

                aaa.Transaction_Code = foo.Transaction_Code;
                aaa.payment_type = foo.payment_type;
                aaa.Account_Number = foo.Account_Number;
                aaa.user_id = foo.user_id;
                aaa.Status = "Unused";
                aaa.Order_Id = foo.Order_Id;
                aaa.Transaction_Date = DateTime.Now;
                aaa.Transaction_Status = foo.Transaction_Status;
                aaa.Service = foo.Service;
                _db.Transaction.Add(aaa);

                var kk = _db.SaveChanges();

                //Subscription_Detail2 hh = new Subscription_Detail2();
                //hh.Payment_Date = DateTime.Now;
                //hh.Subscription_Code = foo.Subscription_Code;
                //hh.user_id = foo.user_id;
                //hh.Transaction_Code = foo.Transaction_Code;
                //if (foo.Transaction_Status == "Approved")
                //{

                //    AddSubscription_Detail3(hh);

                //}
                //   _db.SaveChanges();

                var xk = (from c in _db.User_Detail where c.User_Id == foo.user_id && c.Services == foo.Subscription_Code select c).Count();
                if (xk > 0)
                {


                }
                else
                {

                    User_Detail gs = new User_Detail();
                    gs.Fee_amount = 0.0;
                    gs.Services = foo.Service;

                    gs.User_Id = foo.user_id;
                    gs.Fee = false;

                    _db.User_Detail.Add(gs);
                    _db.SaveChanges();
                }
                return aaa.Transaction_Code;

            }
            catch (Exception ee)
            {
                return ee.Message; ;
            }




        }
Пример #2
0
        public async Task<String> AddTransaction2(Transaction foo2)
        {



            var httpRequest = HttpContext.Current.Request;





            try
            {
                var _db = new ApplicationDbContext();
                var foo = (from c in _db.Transaction where c.Order_Id == foo2.Order_Id select c).FirstOrDefault();

                var foo3 = (from c in _db.Users where c.UserName == foo.user_id select c).FirstOrDefault();
                //  string currentUserId = User.Identity.GetUserId();
                //Transaction aaa = new Transaction();
                //foo.amount = foo2.amount;
                //foo.Bank_Code = foo2.Bank_Code;
                //aaa.Institution_Code = foo.Institution_Code;
                if (foo2.Transaction_Status == "Approved")
                {
                    foo.Payment_Status = "Approved";
                }

                else
                {

                    foo.Payment_Status = "Declined";
                }
                //aaa.Subscription_Code = foo.Subscription_Code;
              
                //aaa.Transaction_Code =foo.Transaction_Code;
                //aaa.payment_type = foo.payment_type;
                //aaa.Account_Number = foo.Account_Number;
                //aaa.user_id = foo.user_id;
               foo.Status = "Unused";
                //aaa.Order_Id = foo.Order_Id;
                foo.Transaction_Date = DateTime.Now;
                foo.Transaction_Status = foo2.Transaction_Status;
              
                    foo.Transaction_Code = foo2.Transaction_Code;
              
              //  _db.Transaction.Add(aaa);

                var kk = _db.SaveChanges();

                Subscription_Detail2 hh = new Subscription_Detail2();
                hh.Payment_Date = DateTime.Now;
                hh.Subscription_Code = foo2.Subscription_Code;
                hh.user_id = foo2.user_id;
                hh.Transaction_Code = foo2.Transaction_Code;
                hh.Service = foo2.Service;
                if (foo.Transaction_Status == "Approved") {

                    if (foo3.Institution_Code != null)
                    {
                        var foo4 = (from c in _db.User_Detail where c.User_Id == foo.user_id select c).ToList();

                        foreach (var kd in foo4)
                        {

                            hh.Service = kd.Services;
                            AddSubscription_Detail3(hh);
                        }



                    }

                    else
                    {

                        AddSubscription_Detail3(hh);

                    }

                }
                //   _db.SaveChanges();
                return foo2.Transaction_Code;

            }
            catch (Exception ee)
            {
                return ee.Message; ;
            }




        }