public IHttpActionResult AddPhoto(Photo photo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } GalleryStoredProcedureRepository storedGallery = new GalleryStoredProcedureRepository(); storedGallery.AddPhoto(photo); return(CreatedAtRoute("DefaultApi", new { id = photo.GalleryId }, photo)); }
public IHttpActionResult Edit(Gallery gallery) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } GalleryStoredProcedureRepository storedGallery = new GalleryStoredProcedureRepository(); storedGallery.Edit(gallery); return(Ok(gallery)); }
public IHttpActionResult Delete(int id) { Gallery gallery = db.Galleries.Find(id); if (gallery == null) { return(NotFound()); } GalleryStoredProcedureRepository galleryStored = new GalleryStoredProcedureRepository(); Gallery createdGallery = galleryStored.Delete(gallery); return(Ok(createdGallery)); }
public IHttpActionResult GetGalleriesByProfileId(int profileId) { ProfileStoredProcedureRepository profileStored = new ProfileStoredProcedureRepository(); Profile profile = profileStored.Get(profileId); GalleryStoredProcedureRepository galleryStored = new GalleryStoredProcedureRepository(); profile = galleryStored.GetGalleriesByProfileId(profile); if (profile == null) { return(NotFound()); } return(Ok(profile)); }
public IHttpActionResult GetGallery(int id) { Gallery gallery = new Gallery(); GalleryStoredProcedureRepository galleryStored = new GalleryStoredProcedureRepository(); gallery = galleryStored.GetGallery(id); gallery = galleryStored.GetPhotos(gallery); if (gallery == null) { return(NotFound()); } return(Ok(gallery)); }