Exemplo n.º 1
0
 public void Delete(TbLike like)
 {
     SqlCommand cmd = con.CreateCommand();
     cmd.CommandText = "delete from TbLike where UserId=@UserId and MessageId=@MessageId";
     cmd.Parameters.AddWithValue("@MessageId", like.MessageId);
     cmd.Parameters.AddWithValue("@UserId", like.UserId);
     cmd.ExecuteNonQuery();
 }
Exemplo n.º 2
0
 public void Create(TbLike like)
 {
     SqlCommand cmd = con.CreateCommand();
     cmd.CommandText = "Insert Into TbLike (UserId,MessageId,Rank) values (@UserId,@MessageId,@Rank)";
     cmd.Parameters.AddWithValue("@MessageId", like.MessageId);
     cmd.Parameters.AddWithValue("@UserId", like.UserId);
     cmd.Parameters.AddWithValue("@Rank", like.Rank);
     cmd.ExecuteNonQuery();
 }
Exemplo n.º 3
0
 public static TbLike ToEntity(System.Data.IDataReader reader)
 {
     TbLike lik = null;
     lik = new TbLike();
     lik.Id = Convert.ToInt32(reader["Id"]);
     lik.UserId = Convert.ToInt32(reader["UserId"]);
     lik.MessageId = Convert.ToInt32(reader["MessageId"]);
     lik.Rank = Convert.ToInt32(reader["Rank"]);
     return lik;
 }
Exemplo n.º 4
0
        public MethodResult LikeMessage(int userId, int messageId)
        {
            try
            {
                TbLike like = new TbLike();
                like.UserId = userId;
                like.MessageId = messageId;
                like.Rank = 1;

                bool data = Business.Like.Create(like);
                return new MethodResult(false, null, data);
            }
            catch (HabbeException e)
            {
                return new MethodResult(true, e.Message, null);
            }
        }
Exemplo n.º 5
0
 public static bool Create(TbLike like)
 {
     using (DataAccess.Like db = new DataAccess.Like())
     {
         TbLike duplike = db.Retrieve(like.MessageId, like.UserId);
         if (duplike == null)
         {
             db.Create(like);
             return true;
         }
         else
         {
             db.Delete(like);
             return false;
         }
     }
 }