Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> GetPromoPhoto(Guid id)
        {
            PromoPhoto promoPhoto = await db.PromoPhotos.FindAsync(id);

            if (promoPhoto == null)
            {
                return(NotFound());
            }

            return(Ok(promoPhoto));
        }
Beispiel #4
0
        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));
        }