Ejemplo n.º 1
0
        public async Task AddCriticismForSingerAsync(string singerName, Criticism criticism)
        {
            var singer = await GetSingerAsync(singerName, false);

            singer.Criticisms.Add(criticism);
            // criticism.SingerId = singer.Id;
            // await _context.Criticisms.AddAsync(criticism);
        }
Ejemplo n.º 2
0
 public async Task AddCriticismForSingerAsync(int singerId, Criticism criticism)
 {
     // // method1: to add subelement into the picked out object
     // var singer = await GetSingerAsync(singerId, false);
     // singer.Criticisms.Add(criticism);
     // // method2: to directly add subelement into dbset of context with a foreign key set
     criticism.SingerId = singerId;
     await _context.Criticisms.AddAsync(criticism);
 }
Ejemplo n.º 3
0
 protected void btnSelect_Click(object sender, EventArgs e)
 {
     if (ddlKey.SelectedValue == "所有")
     {
         Bind();
         return;
     }
     if (ddlKey.SelectedValue == "主题")
     {
         Theme theme = new Model.Theme()
         {
             ThemeId = txtKey.Text.Trim()
         };
         if (theme.IsError)
         {
             Msg = "参数格式错误";
             SomeMethod.PrintMsgToClient(this.ClientScript, Msg);
             return;
         }
         Bind(CriticismManagement.SelectByThemeId(theme.ThemeId));
         return;
     }
     if (ddlKey.SelectedValue == "会员")
     {
         Member member = new Member()
         {
             MemberId = txtKey.Text.Trim()
         };
         if (member.IsError)
         {
             Msg = "参数格式错误";
             SomeMethod.PrintMsgToClient(this.ClientScript, Msg);
             return;
         }
         Bind(CriticismManagement.SeleteByMemberId(member.MemberId));
         return;
     }
     if (ddlKey.SelectedValue == "编号")
     {
         Criticism criticism = new Criticism()
         {
             CriticismId = txtKey.Text.Trim()
         };
         if (criticism.IsError)
         {
             Msg = "参数格式错误";
             SomeMethod.PrintMsgToClient(this.ClientScript, Msg);
             return;
         }
         Bind(CriticismManagement.SelectByCriticismId(criticism.CriticismId));
         return;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 插入评论(connected_criticism为空)
        /// </summary>
        /// <param name="criticism">Criticism实体类</param>
        /// <returns></returns>
        public int Insert(Criticism criticism)
        {
            string sql = "insert into Criticism(criticism_id,criticism_text,publish_time,member_id,theme_id) values(@criticism_id,@criticism_text,@publish_time,@member_id,@theme_id)";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@criticism_id", criticism.CriticismId),
                new SqlParameter("@criticism_text", criticism.CriticismText),
                new SqlParameter("@publish_time", criticism.PublishTime),
                new SqlParameter("@member_id", criticism.MemberId),
                new SqlParameter("@theme_id", criticism.ThemeId)
            };
            return(SqlHelper.ExecuteNonQuery(sql, parameters));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 回复评论
 /// </summary>
 /// <param name="criticism"></param>
 /// <returns></returns>
 public static string ReplyCriticism(Criticism criticism)
 {
     if (criticism.IsError)
     {
         return(criticism.GetErrorMsg());
     }
     if (isExist(criticism.CriticismId))
     {
         return("评论编号已存在,请重试");
     }
     if (ICS.InsertReply(criticism) == 1)
     {
         return("评论成功");
     }
     else
     {
         return("评论失败");
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 删除评论
        /// </summary>
        /// <param name="criticismId">评论编号</param>
        /// <returns></returns>
        public static string Delete(string criticismId)
        {
            Criticism cri = new Criticism()
            {
                CriticismId = criticismId
            };

            if (cri.IsError)
            {
                return(cri.GetErrorMsg());
            }
            if (ICS.Delete(criticismId) == 0)
            {
                return("删除失败");
            }
            else
            {
                return("删除成功");
            }
        }
Ejemplo n.º 7
0
        protected void btnPubCriticism_Click(object sender, EventArgs e)//评论
        {
            //判断是否登录
            SomeMethod.IfLogin(this);
            Criticism criticism = new Criticism()
            {
                CriticismId   = CriticismManagement.CreateCriticismId(),
                MemberId      = Session["memberId"].ToString().Trim(),
                ThemeId       = Request["themeId"].ToString(),
                CriticismText = Server.UrlDecode(hidContent.Value.Trim()),
                PublishTime   = DateTime.Now
            };

            if (connectCriticism.Value.Trim() == "Theme")
            {
                if (criticism.IsError)
                {
                    Msg = "参数格式错误";
                    printMsgToClient();
                    return;
                }
                Msg = CriticismManagement.PublishCriticism(criticism);
            }
            else
            {
                criticism.ConnectedCriticism = connectCriticism.Value.Trim();
                if (criticism.IsError)
                {
                    Msg = "参数格式错误";
                    printMsgToClient();
                    return;
                }
                Msg = CriticismManagement.ReplyCriticism(criticism);
            }
            printMsgToClient();
            Bind();
        }
Ejemplo n.º 8
0
 public async Task DeleteCriticismAsync(Criticism criticism)
 {
     //var songWithRelations = song.
     await Task.FromResult(_context.Remove(criticism));
 }