public bool DeleveComment(CommentModel cmodel) { try { var employer = new DAL.Comments { id = cmodel.id }; db.Entry(employer).State = EntityState.Deleted; db.SaveChanges(); } catch (Exception ex) { throw ex; // return false; } return(true); }
public static long CreateCommentDB(CommentDTO comment) { using (var ctx = new DAL.instDBEntities()) { var dbCom = new DAL.Comments { Id = comment.Id, UserId = comment.UserId, PostId = comment.PostId, Date = comment.Date, ContentText = comment.ContentText }; ctx.Comments.Add(dbCom); ctx.SaveChanges(); return(dbCom.Id); } }
public bool SaveComment(CommentModel cmodel) { try { var insertComment = new DAL.Comments { userId = cmodel.userId, boatId = cmodel.boatId, commentDate = DateTime.Now, comments1 = cmodel.comment }; db.Comments.Add(insertComment); db.SaveChanges(); }catch (Exception ex) { throw ex; // return false; } return(true); }