public HttpResponseMessage updateActPostItemComment(String id, Entities.ActPostItemComment postitemcomment) { try { var actPostItemComment = from d in db.ActPostItemComments where d.Id == Convert.ToInt32(id) select d; if (actPostItemComment.Any()) { var updateActPostItemComment = actPostItemComment.FirstOrDefault(); updateActPostItemComment.Id = postitemcomment.Id; updateActPostItemComment.PostId = postitemcomment.PostId; updateActPostItemComment.Comment = postitemcomment.Comment; updateActPostItemComment.CommentByUserId = postitemcomment.CommentByUserId; updateActPostItemComment.CommentDate = DateTime.Today; updateActPostItemComment.UpdatedDate = DateTime.Today; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage addActPostItemComment(Entities.ActPostItemComment add) { try { Data.ActPostItemComment newActPostItemComment = new Data.ActPostItemComment(); var userId = User.Identity.GetUserId(); newActPostItemComment.PostId = add.PostId; newActPostItemComment.Comment = add.Comment; newActPostItemComment.CommentByUserId = userId; newActPostItemComment.CommentDate = DateTime.Today; newActPostItemComment.UpdatedDate = DateTime.Today; db.ActPostItemComments.InsertOnSubmit(newActPostItemComment); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }