public async Task <ActionResult> Edit([Bind(Include = "Id,Created,LocalPathToImage,BlobPathToImage,BlobPathToPreviewImage,Md5Hash,PhotoEventId,ImageWidth,ImageHeight,IsDeleted")] Photo photo) { if (ModelState.IsValid) { string blobPathToImage = photo.BlobPathToImage; if (!blobPathToImage.Contains(photo.PhotoEventId.ToString())) { string originalGuid = blobPathToImage.Substring(40, 36); Guid oldEventId; if (Guid.TryParse(originalGuid, out oldEventId)) { photo.OriginalPhotoEventId = new Guid(originalGuid); } } else { photo.OriginalPhotoEventId = Guid.Empty; } db.Entry(photo).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.PhotoEventId = new SelectList(db.PhotoEvents, "Id", "Name", photo.PhotoEventId); return(View(photo)); }
public async Task <IHttpActionResult> PostPrintQueue(PrintQueue printQueue) { if (printQueue.Id == Guid.Empty) { printQueue.Id = Guid.NewGuid(); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PrintQueue.Add(printQueue); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PrintQueueExists(printQueue.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = printQueue.Id }, printQueue)); }