Exemplo n.º 1
0
        public static bool UpdatePost_UpdateDate(Post_Model P_Model)
        {
            SqlCommand CMD = new SqlCommand();

            CMD.CommandText = @"Update [dbo].[Post] set update_date =getdate() where id=@id";
            CMD.Parameters.AddWithValue("@id", P_Model.ID);


            int Res = new DB().int_ExecuteNonQuery_Odbc(CMD);

            return(Res > 0 ? true : false);
        }
Exemplo n.º 2
0
        public static int InsertPost(Post_Model P_Model)
        {
            SqlCommand CMD = new SqlCommand();

            CMD.CommandText = @"DECLARE @vocno [int]; INSERT INTO [dbo].[Post] ( [Category_Id], [User_Id], [Title], [Description],  [Update_Date])  
                            VALUES ( @Category_Id ,  @User_Id ,  @Title ,  @Description ,   getdate() ) ; SELECT @vocno  = SCOPE_IDENTITY();
                INSERT INTO [dbo].[Post_Details] ([Post_Id], [User_id], [Post_TXT], [Post_TypeID] ) VALUES 
             (@vocno,@User_id,@Post_TXT,@Post_TypeID);SELECT @vocno ";
            CMD.Parameters.AddWithValue("@Category_Id", P_Model.Category_Id);
            CMD.Parameters.AddWithValue("@User_Id", P_Model.User_Id);
            CMD.Parameters.AddWithValue("@Title", P_Model.Title);
            CMD.Parameters.AddWithValue("@Description", P_Model.Description);

            CMD.Parameters.AddWithValue("@Post_TXT", P_Model.Details_lst[0].Post_TXT);
            CMD.Parameters.AddWithValue("@Post_TypeID", (int)Post_Type.Post);

            int Res = 0;

            Res = new DB().int_ExecuteScalar(CMD);

            return(Res);
        }
Exemplo n.º 3
0
        public static bool   InsertPostDetails(Post_Details_Model PD_Model)
        {
            SqlCommand CMD = new SqlCommand();

            CMD.CommandText = @"INSERT INTO [dbo].[Post_Details] ([Post_Id], [User_id], [Post_TXT], [Post_TypeID] ) VALUES 
             (@Post_Id,@User_id,@Post_TXT,@Post_TypeID)";
            CMD.Parameters.AddWithValue("@Post_Id", PD_Model.Post_Id);
            CMD.Parameters.AddWithValue("@User_id", PD_Model.User_Id);
            CMD.Parameters.AddWithValue("@Post_TXT", PD_Model.Post_TXT);
            CMD.Parameters.AddWithValue("@Post_TypeID", (int)PD_Model.Post_TypeID);


            int Res = new DB().int_ExecuteNonQuery_Odbc(CMD);

            if (Res > 0)
            {
                Post_Model P_ModelOBJ = new Post_Model();
                P_ModelOBJ.ID = PD_Model.Post_Id;
                bool Done = UpdatePost_UpdateDate(P_ModelOBJ);
            }

            return(Res > 0 ? true : false);
        }
Exemplo n.º 4
0
        private static List <Post_Model> ConvertToPostList(DataTable table)
        {
            var postList = new List <Post_Model>();

            foreach (DataRow row in table.Rows)
            {
                var post = new Post_Model()
                {
                    ID           = (int)row[0],
                    Category_Id  = (int)row[1],
                    User_Id      = (int)row[2],
                    Title        = (string)(row[3] ?? ""),
                    Description  = (string)(row[4] == DBNull.Value ? "" : row[4]),
                    Status       = (bool)row[5],
                    Date_Created = (DateTime)row[6],
                    Update_Date  = row[7] == DBNull.Value ? (DateTime?)null : (DateTime)row[7],
                    Details_lst  = GetPostOfDetails((int)row[0])
                };

                postList.Add(post);
            }
            return(postList);
        }