Exemple #1
0
        public string SetFavorite(string pRequest)
        {
            var rd     = new APIResponse <SetFavoriteRD>();
            var rdData = new SetFavoriteRD();

            rdData.IsSuccess = true;
            rd.Data          = rdData;
            rd.ResultCode    = 0;
            return(rd.ToJSON());
        }
Exemple #2
0
        public string SetFavorite(string pRequest)
        {
            var rd     = new APIResponse <SetFavoriteRD>();
            var rdData = new SetFavoriteRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <SetFavoriteRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                ItemKeepBLL    itemBll = new ItemKeepBLL(loggingSessionInfo);
                ItemKeepEntity entity  = itemBll.GetItemKeepByUser(rp.Parameters.OnlineCourseID, rp.UserID);
                //加入收藏
                if (rp.Parameters.IsFavorite.Equals("1"))
                {
                    if (entity == null)
                    {
                        entity = new ItemKeepEntity()
                        {
                            ItemKeepId = Guid.NewGuid().ToString().Replace("-", ""),
                            ItemId     = rp.Parameters.OnlineCourseID,
                            VipId      = rp.UserID,
                            KeepStatus = 1,
                            ItemType   = 1//默认1,保留字段
                        };
                        itemBll.Create(entity);
                    }
                    else
                    {
                        if (entity.KeepStatus != 1)
                        {
                            entity.KeepStatus = 1;
                            itemBll.Update(entity);
                        }
                    }
                }
                else //取消收藏
                {
                    if (entity != null)
                    {
                        entity.KeepStatus = 0;
                        itemBll.Update(entity);
                    }
                }
                rd.ResultCode    = 0;
                rdData.IsSuccess = true;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }