public async Task <IActionResult> PutPost(int id, Post post) { if (id != post.Id) { return(BadRequest()); } _context.Entry(post).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPost([FromRoute] Guid id, [FromBody] Post post) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != post.MessageId) { return(BadRequest()); } _context.Entry(post).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutPost(Guid id, Post post) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != post.ID) { return(BadRequest()); } db.Entry(post).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PostExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "AuthorID,FirstName,LastName,AuthorName,Email,CompanyName,CompanyZip,CompanyCity, CompanyState")] Author author) { if (ModelState.IsValid) { var myAuthor = db.Authors.Find(author.AuthorID); db.Entry(myAuthor).State = EntityState.Detached; if (myAuthor.Email != author.Email) { ModelState.AddModelError("Email", "You cannot change the author email address!"); return(View(author)); } author.AuthorName = author.FirstName + " " + author.LastName; db.Entry(author).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(author)); }
public ActionResult Edit([Bind(Include = "ID,PostTitle,PostAuthor,PostTags,PostText,TitlePic,EditDate")] Posts posts) { if (ModelState.IsValid) { db.Entry(posts).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(posts)); }
public ActionResult Edit([Bind(Include = "BlogID,Name")] Blog blog) { if (ModelState.IsValid) { db.Entry(blog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(blog)); }
public ActionResult Edit([Bind(Include = "ID,PostFK,PicTitle,EditDate,PictPict")] Picts picts) { if (ModelState.IsValid) { db.Entry(picts).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(picts)); }
public ActionResult Edit([Bind(Include = "ID,TagName,CreatedAt")] PostTag postTag) { if (ModelState.IsValid) { db.Entry(postTag).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(postTag)); }
public ActionResult Edit(PostCategory postCategory) { if (ModelState.IsValid) { postCategory.UpdatedBy = LoggedUserInfo.GetLoggedUserInfo().ID; db.Entry(postCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(postCategory)); }
public ActionResult Edit([Bind(Include = "PostID,Tag,FeaturedImageURL,Title,AuthorID,BlogID,Content,Date")] Post post) { if (ModelState.IsValid) { db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuthorID = new SelectList(db.Authors, "AuthorID", "FirstName", post.AuthorID); ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Name", post.BlogID); return(View(post)); }
public ActionResult Edit([Bind(Include = "ID,PostTitle,PostAuthor,PostTags,PostText,TitlePic,EditDate")] Posts posts) { if (ModelState.IsValid) { String aDate = DateTime.UtcNow.ToString("yyMMddHHmmss"); posts.EditDate = aDate; db.Entry(posts).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(posts)); }