public async Task <IHttpActionResult> PostPromoPhoto(PromoPhoto promoPhoto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PromoPhotos.Add(promoPhoto); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PromoPhotoExists(promoPhoto.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = promoPhoto.id }, promoPhoto)); }
public async Task <IHttpActionResult> PutPromoPhoto(Guid id, PromoPhoto promoPhoto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != promoPhoto.id) { return(BadRequest()); } db.Entry(promoPhoto).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PromoPhotoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetPromoPhoto(Guid id) { PromoPhoto promoPhoto = await db.PromoPhotos.FindAsync(id); if (promoPhoto == null) { return(NotFound()); } return(Ok(promoPhoto)); }
public async Task <IHttpActionResult> DeletePromoPhoto(Guid id) { PromoPhoto promoPhoto = await db.PromoPhotos.FindAsync(id); if (promoPhoto == null) { return(NotFound()); } db.PromoPhotos.Remove(promoPhoto); await db.SaveChangesAsync(); return(Ok(promoPhoto)); }