Пример #1
0
        public virtual object AddFavorite(HttpContext context)
        {
            YZRequest      request  = new YZRequest(context);
            YZResourceType resType  = request.GetEnum <YZResourceType>("resType");
            string         resId    = request.GetString("resId");
            string         comments = request.GetString("comments", null);
            string         uid      = YZAuthHelper.LoginUserAccount;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    if (!FavoriteManager.HasFavorited(provider, cn, uid, resType, resId))
                    {
                        Favorite favorite = new Favorite()
                        {
                            uid        = uid,
                            resType    = resType,
                            resId      = resId,
                            comments   = comments,
                            date       = DateTime.Now,
                            orderIndex = FavoriteManager.GetNextOrderIndex(provider, cn, uid, resType)
                        };

                        FavoriteManager.Insert(provider, cn, favorite);
                    }

                    return(true);
                }
            }
        }