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; } }
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; } }
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; } }
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; } }