Ejemplo n.º 1
0
 public int AddUser(users user)
 {
     try
     {
         ping_pakistanEntities db = new ping_pakistanEntities();
         db.users.Add(user);
         db.SaveChanges();
         return user.id;
     }
     catch(Exception ex)
     {
         return -1;
     }
 }
Ejemplo n.º 2
0
 public posts AddPost(posts post)
 {
     try
     {
         ping_pakistanEntities db = new ping_pakistanEntities();
         db.posts.Add(post);
         db.SaveChanges();
         return post;
     }
     catch (Exception ex)
     {
         return post;
     }
 }
 public categories AddCategory(categories category)
 {
     try
     {
         ping_pakistanEntities db = new ping_pakistanEntities();
         db.categories.Add(category);
         db.SaveChanges();
         return category;
     }
     catch (Exception ex)
     {
         return category;
     }
 }
Ejemplo n.º 4
0
 public bool DeletePost(int post_id)
 {
     try
     {
         ping_pakistanEntities db = new ping_pakistanEntities();
         var _post = db.posts.FirstOrDefault(p => p.id == post_id);
         if (_post != null)
         {
             _post.is_deleted = true;
         }
         db.SaveChanges();
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }
Ejemplo n.º 5
0
 public bool UpdateApproveStatus(int post_id, bool status)
 {
     try
     {
         ping_pakistanEntities db = new ping_pakistanEntities();
         var _post = db.posts.FirstOrDefault(p => p.id == post_id);
         if(_post != null)
         {
             _post.is_approved = status;
         }
         db.SaveChanges();
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }