Esempio n. 1
0
        public String SubmitProductInfo(string userInfo)
        {
            ProductInfo us = (ProductInfo)JsonConvert.DeserializeObject(userInfo, typeof(ProductInfo));

            ProductInfo proInfo = new ProductInfo();


            ProductInfo existingData = new ProductInfo();


            using (DSLEntities entity = new DSLEntities())
            {
                existingData = entity.ProductInfo.Where(a => a.ProductId == us.ProductId).ToList().FirstOrDefault();
            }

            if (existingData != null)
            {
                using (DSLEntities entity = new DSLEntities())
                {
                    existingData = us;

                    entity.Entry(existingData).State = System.Data.Entity.EntityState.Modified;
                    entity.SaveChanges();
                }
            }


            return("0");
        }
Esempio n. 2
0
        public String SubmitUserInfo(string userInfo)
        {
            UserInfo us = (UserInfo)JsonConvert.DeserializeObject(userInfo, typeof(UserInfo));

            if (us.UserId == 0)
            {
                return(AddUserInfo(us));
            }

            UserInfo order = new UserInfo();


            UserInfo existingInfo = null;


            using (DSLEntities entity = new DSLEntities())
            {
                existingInfo = entity.UserInfo.Where(a => a.UserId == us.UserId).ToList().FirstOrDefault();
            }

            if (existingInfo != null)
            {
                using (DSLEntities entity = new DSLEntities())
                {
                    existingInfo = us;

                    entity.Entry(existingInfo).State = System.Data.Entity.EntityState.Modified;
                    entity.SaveChanges();
                }
            }


            return("0");
        }
Esempio n. 3
0
        public String SubmitRechargeInfo(String paymentId, String amount, String paymentTime)
        {
            OAuthTokenCredential oa = new OAuthTokenCredential("AQmW6s0chChHeblhmaIYQda6Bn1gmfSSUnvUCHNCLZM_7BiLOb5BMrINuIxUswdG8Prb8K3ktHQpZuho", "ENQKqkutUnKuTGBWiNDvJ_sA131lwCU4c1eaJwFcn58M88LtjHJd9TLgvjT4nuXkruuSkD0OF0u_XP_W");


            PayPal.Api.APIContext apiContext = new PayPal.Api.APIContext(oa.GetAccessToken());

            try
            {
                Payment payment = PayPal.Api.Payment.Get(apiContext, paymentId);

                if (payment == null || String.IsNullOrEmpty(payment.id))
                {
                    return("11");
                }
            }
            catch (Exception ex)
            {
                return("11");
            }

            LoginViewModel user = Utils.GetUserInfo();

            PaymentInfo pInfo = null;

            using (DSLEntities entity = new DSLEntities())
            {
                pInfo = entity.PaymentInfo.Where(a => a.UserId.ToString() == user.UserId && a.PaymentId == paymentId).ToList().FirstOrDefault();
            }

            if (pInfo != null)
            {
                return("1");
            }



            UserInfo existingData = null;


            using (DSLEntities entity = new DSLEntities())
            {
                existingData = entity.UserInfo.Where(a => a.UserId.ToString() == user.UserId).ToList().FirstOrDefault();
            }

            if (existingData != null)
            {
                using (DSLEntities entity = new DSLEntities())
                {
                    existingData.Balance            += decimal.Parse(amount);
                    entity.Entry(existingData).State = System.Data.Entity.EntityState.Modified;
                    entity.SaveChanges();
                }
            }

            PaymentInfo addPayInfo = new PaymentInfo();

            addPayInfo.Amount       = Decimal.Parse(amount);
            addPayInfo.PaymentId    = paymentId;
            addPayInfo.PaymentState = "Approval";
            addPayInfo.PaymentType  = "PayPal";
            addPayInfo.UserId       = int.Parse(user.UserId);
            addPayInfo.PaymentTime  = DateTime.Parse(paymentTime);



            using (DSLEntities entity = new DSLEntities())
            {
                entity.PaymentInfo.Add(addPayInfo);
                entity.SaveChanges();
            }


            return("0");
        }