public ActionResult CreateNewsSourceComment(int newssourceid) { var comment = new NewsSourceComment() { NewsSourceId = newssourceid }; return(PartialView("_CreateOrEditNewsSourceComment", comment)); }
public ActionResult EditNewsSourceComment(NewsSourceComment NewsSourcecomment) { if (ModelState.IsValid) { _commentRepo.InsertOrUpdateNewsSourceComments(NewsSourcecomment); _commentRepo.Save(); return(new HttpStatusCodeResult(HttpStatusCode.OK)); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public void InsertOrUpdateNewsSourceComments(NewsSourceComment newssourcecomment) { if (newssourcecomment.Id == default(int)) { // New entity context.NewsSourceComments.Add(newssourcecomment); } else { // Existing entity context.Entry(newssourcecomment).State = EntityState.Modified; } }