Esempio n. 1
0
        public ActionResult AddFavoriteShop(int shopId)
        {
            if(!User.Identity.IsAuthenticated)
                return Json(new { type = 2 }, JsonRequestBehavior.AllowGet);

            try
            {
                ShopModel shopModel = new ShopModel();
                UserModel userModel = new UserModel();
                UserInfo userInfo = userModel.GetUserInfo(User.Identity.Name);

                if(userModel.GetUserFavoriteShop(shopId, userInfo.Id) != null)
                    return Json(new { type = 1 }, JsonRequestBehavior.AllowGet);

                UserFavoriteShop favShop = new UserFavoriteShop();
                favShop.UserId = userInfo.Id;
                favShop.ShopId = shopId;
                favShop.CreateTime = DateTime.Now;
                userModel.Add(favShop);
            }
            catch(Exception ex)
            {
                return Json(new { type = 0, data = ex.Message }, JsonRequestBehavior.AllowGet);
            }

            return Json(new { type = 1 }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
 /// <summary>
 /// 用于向 UserFavoriteShop EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToUserFavoriteShop(UserFavoriteShop userFavoriteShop)
 {
     base.AddObject("UserFavoriteShop", userFavoriteShop);
 }
Esempio n. 3
0
 public void Delete(UserFavoriteShop data)
 {
     db.UserFavoriteShop.DeleteObject(data);
     Save();
 }
Esempio n. 4
0
 /// <summary>
 /// 创建新的 UserFavoriteShop 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="userId">UserId 属性的初始值。</param>
 /// <param name="shopId">ShopId 属性的初始值。</param>
 /// <param name="createTime">CreateTime 属性的初始值。</param>
 public static UserFavoriteShop CreateUserFavoriteShop(global::System.Int32 id, global::System.Int32 userId, global::System.Int32 shopId, global::System.DateTime createTime)
 {
     UserFavoriteShop userFavoriteShop = new UserFavoriteShop();
     userFavoriteShop.Id = id;
     userFavoriteShop.UserId = userId;
     userFavoriteShop.ShopId = shopId;
     userFavoriteShop.CreateTime = createTime;
     return userFavoriteShop;
 }
Esempio n. 5
0
 public void Add(UserFavoriteShop data)
 {
     db.UserFavoriteShop.AddObject(data);
     Save();
 }