Beispiel #1
0
        public ActionResult GetUsersByJason()
        {
            UsersInfoDal    dal      = new UsersInfoDal();
            List <UserInfo> objUSers = dal.usersInfo.ToList <UserInfo>();

            return(Json(objUSers, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult SellingPets(User user, String id)
        {
            PetsDal         dal   = new PetsDal();
            UsersInfoDal    ufDal = new UsersInfoDal();
            ShoppingCartDal scDal = new ShoppingCartDal();
            ShoppingCart    sc    = new ShoppingCart();

            if (user.UserName == null)
            {
                TempData["PetsError"] = "Sorry, You must login to buy pets!";
                return(View("BuyPet", user));
            }

            if (id == "")
            {
                TempData["PetsError"] = "Sorry, You must enter value!";
                return(View("BuyPet", user));
            }

            if (dal.pets.Find(id) != null)
            {
                if (dal.pets.Find(id).Availability == 1)
                {
                    //Initializing the shopping cart object
                    sc.petType  = dal.pets.Find(id).petType;
                    sc.petName  = dal.pets.Find(id).petName;
                    sc.petID    = dal.pets.Find(id).petID;
                    sc.customer = user.UserName;

                    //Add the object to the shopping cart sql table
                    scDal.shoppingCart.Add(sc);
                    scDal.SaveChanges();

                    dal.pets.Find(id).Availability = 0;
                    dal.pets.Remove(dal.pets.Find(id));
                    dal.SaveChanges();
                    ufDal.usersInfo.Find(user.UserName).PurchasedPet++;
                    ufDal.SaveChanges();
                    return(View("~/Views/Home/Index.cshtml", user));
                }
                else
                {
                    TempData["PetsError"] = "Sorry, this Pets is not Availabile! Try else pets.";
                    return(View("BuyPet", user));
                }
            }
            else
            {
                TempData["PetsError"] = "The entered ID is not exist!";
                return(View("BuyPet", user));
            }
        }
Beispiel #3
0
        public ActionResult Submit()
        {
            UserInfo uf = new UserInfo()
            {
                UserName  = Request.Form["userInfo.UserName"].ToString(),
                Password  = Request.Form["userInfo.Password"].ToString(),
                FirstName = Request.Form["userInfo.FirstName"].ToString(),
                LastName  = Request.Form["userInfo.LastName"].ToString(),
                LovedPet  = Request.Form["userInfo.LovedPet"].ToString()
            };

            //
            User objUser = new User()
            {
                UserName = uf.UserName,
                Password = uf.Password
            };

            UsersInfoDal UIDal = new UsersInfoDal();
            UserDal      dal   = new UserDal();

            if (ModelState.IsValid)
            {
                if (dal.Users.Find(objUser.UserName) != null)
                {
                    TempData["Eror"] = "there is already user with this name";
                    return(View("Register", uf));
                }
                else
                {
                    dal.Users.Add(objUser);
                    dal.SaveChanges();
                    UIDal.usersInfo.Add(uf);
                    UIDal.SaveChanges();
                    return(View("~/Views/Home/Index.cshtml", objUser));
                }
            }
            else
            {
                TempData["Eror"] = "there value is not valid";
                return(View("Register", uf));
            }
        }
Beispiel #4
0
 /// <summary>
 /// 查询用户信息和业务号
 /// </summary>
 /// <param name="context"></param>
 public void QueryUserInfoAndYwh(HttpContext context)
 {
     var userInfoDal = new UsersInfoDal();
     var groupid = context.Request.Params["groupid"];
     //获取分页数据
     var total = 0;
     var page = int.Parse(context.Request["page"] ?? "1");
     var rows = int.Parse(context.Request["rows"] ?? "10");
     try
     {
         var data = userInfoDal.QueryUserInfoAndYwh2(groupid, page, rows, ref total);
         var list = from da in data.AsEnumerable()
                    select new
                        {
                            wxid = da.Field<string>("wxid"),
                            nickname = da.Field<string>("nickname"),
                            sjh = da.Field<string>("phonenumber"),
                           // qy = da.Field<string>("qy"),
                            zw = da.Field<int?>("zw")
                        };
         hashtable["rows"] = list.ToList();
         hashtable["total"] = total;
         var json = _jss.Serialize(hashtable);
         context.Response.Write(json);
     }
     catch (Exception e)
     {
         Log.Debug("出错信息:" + e.Message);
     }
 }