public async Task <IHttpActionResult> PutPost(int id, Post post) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != post.PostID) { return(BadRequest()); } db.Entry(post).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> Create([Bind(Include = "CategoryItemID,CategoryID,CategoryItemName,CategoryItemPhoto")] CategoryItems categoryItems) { if (ModelState.IsValid) { db.CategoryItems.Add(categoryItems); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", categoryItems.CategoryID); return(View(categoryItems)); }