Esempio n. 1
0
        public MethodResult Create(int userId, int offendingUserId, int messageId, string description, int commentTypeId)
        {
            try
            {
                TbComment comment = new TbComment();
                String SetDecription = "این کاربر تخلف کرده است. لطفا بررسی شود";

                comment.UserId = userId;
                comment.Description = description;
                comment.CommentTypeId = commentTypeId;
                if (commentTypeId.Equals(2))
                {
                    comment.OffendingUserId = offendingUserId;
                    comment.Description = SetDecription;
 
                }
                else
                {
                    comment.MessageId = messageId;
                }

                Business.Comment.Create(comment);
                return new MethodResult(false, " نظر ارسالی با موفقیت ثبت شد ", null);
            }
            catch (HabbeException e)
            {
                return new MethodResult(true, e.Message, null);
            }
        }
Esempio n. 2
0
 public static void Create(TbComment comment)
 {
     using (DataAccess.Comment db = new DataAccess.Comment())
     {
         comment.RegisterDate = DateTime.Now;
         db.Create(comment);
     }
 }
Esempio n. 3
0
        public void Create(TbComment comment)
        {

            SqlCommand cmd = con.CreateCommand();
            cmd.CommandText = "Insert Into TbComment (CommentTypeId,UserId,OffendingUserId,MessageId,Description,RegisterDate) values (@CommentTypeId,@UserId,@OffendingUserId,@MessageId,@Description,@RegisterDate)";
            cmd.Parameters.AddWithValue("@MessageId", comment.MessageId.Equals(0) ? (object)DBNull.Value : comment.MessageId);
            cmd.Parameters.AddWithValue("@UserId", comment.UserId);
            cmd.Parameters.AddWithValue("@OffendingUserId", comment.OffendingUserId.Equals(0) ? (object)DBNull.Value : comment.OffendingUserId);
            cmd.Parameters.AddWithValue("@CommentTypeId", comment.CommentTypeId);
            cmd.Parameters.AddWithValue("@Description", comment.Description);
            cmd.Parameters.AddWithValue("@RegisterDate", comment.RegisterDate);
            cmd.ExecuteNonQuery();
        }
Esempio n. 4
0
        public static TbComment ToEntity(System.Data.IDataReader reader)
        {
            TbComment comment = null;
            comment = new TbComment();
            comment.Id = Convert.ToInt32(reader["Id"]);
            if (reader["MessageId"] != DBNull.Value)
            comment.MessageId = Convert.ToInt32(reader["MessageId"]);
            comment.CommentTypeId = Convert.ToInt32(reader["CommentTypeId"]);
            comment.UserId = Convert.ToInt32(reader["UserId"]);
            if (reader["OffendingUserId"] != DBNull.Value)
            comment.OffendingUserId = Convert.ToInt32(reader["OffendingUserId"]);
            comment.Description = Convert.ToString(reader["Description"]);
            comment.RegisterDate = Convert.ToDateTime(reader["RegisterDate"]);

            return comment;
        }