public IActionResult Put(int id, [FromBody] ACLPermission value) { // This method should be idempotent if (value == null || value.ID != id) { return(BadRequest()); } if (ModelState.IsValid) { _context.Update(value); _context.SaveChanges(); return(new NoContentResult()); } else { return(BadRequest()); } }
public ActionResult Create(Item item, HttpPostedFileBase photo) { item.CreatedDate = DateTime.Today; if (ModelState.IsValid) { //Reading the photo item.ImageMimeType = photo.ContentType; item.ItemPhoto = new byte [photo.ContentLength]; photo.InputStream.Read(item.ItemPhoto, 0, photo.ContentLength); context.Items.Add(item); context.SaveChanges(); return(RedirectToAction("Create")); } return(View("Create", item)); }