Exemple #1
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");
        }
Exemple #2
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");
        }
Exemple #3
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            ViewBag.PageId = "login";

            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            UserInfo existingInfo = null;

            using (DSLEntities entity = new DSLEntities())
            {
                existingInfo = entity.UserInfo.Where(a => a.Email == model.UserEmail && a.Pwd == model.Password).ToList().FirstOrDefault();
            }

            if (existingInfo != null)
            {
                String role = "admins";

                //1: backend   2: customer
                if (existingInfo.ClientType.Equals("2"))
                {
                    role = "customers";
                }


                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                    1,
                    "sdf",
                    DateTime.Now,
                    DateTime.Now.AddMinutes(30),
                    false,
                    existingInfo.UserId + "," + existingInfo.UserName + "," + role + "," + existingInfo.Balance.ToString()
                    );



                string encryptedTicket           = FormsAuthentication.Encrypt(authTicket);
                System.Web.HttpCookie authCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);



                Response.Redirect("~/DirectLine/DirectLineOrderMgr");

                return(View(model));
            }
            else
            {
                ModelState.AddModelError("", "Invalid Email Addres Or Password.");

                return(View(model));
            }
        }
Exemple #4
0
        private String AddUserInfo(UserInfo userInfo)
        {
            using (DSLEntities entity = new DSLEntities())
            {
                entity.UserInfo.Add(userInfo);
                entity.SaveChanges();
            }


            return("0");
        }
Exemple #5
0
        public JsonResult GetProfileByUserId()
        {
            String          userId = Utils.GetUserInfo().UserId;
            List <UserInfo> result = null;

            using (DSLEntities entity = new DSLEntities())
            {
                result = entity.UserInfo.OrderBy(a => a.UserName).Where(a => a.UserId.ToString().Equals(userId)).ToList();
            }
            Console.WriteLine("OK");



            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
        public JsonResult GetAllUserData()
        {
            UserInfo        order  = new UserInfo();
            List <UserInfo> result = null;


            using (DSLEntities entity = new DSLEntities())
            {
                result = entity.UserInfo.ToList();
                //写回数据库
                entity.SaveChanges();
            }
            Console.WriteLine("OK");



            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #7
0
        public JsonResult GetProductById(int id)
        {
            UserInfo           order  = new UserInfo();
            List <ProductInfo> result = null;


            using (DSLEntities entity = new DSLEntities())
            {
                result = entity.ProductInfo.OrderBy(a => a.ProductName).Where(a => a.ProductId == id).ToList();
                //写回数据库
                entity.SaveChanges();
            }
            Console.WriteLine("OK");



            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #8
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");
        }