public async Task <IHttpActionResult> PutPhotoSaveHistory(int id, PhotoSaveHistory photoSaveHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != photoSaveHistory.Id)
            {
                return(BadRequest());
            }

            db.Entry(photoSaveHistory).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PhotoSaveHistoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetPhotoSaveHistory(int id)
        {
            PhotoSaveHistory photoSaveHistory = await db.PhotoSaveHistories.FindAsync(id);

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

            return(Ok(photoSaveHistory));
        }
        public async Task <IHttpActionResult> DeletePhotoSaveHistory(int id)
        {
            PhotoSaveHistory photoSaveHistory = await db.PhotoSaveHistories.FindAsync(id);

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

            db.PhotoSaveHistories.Remove(photoSaveHistory);
            await db.SaveChangesAsync();

            return(Ok(photoSaveHistory));
        }
        public async Task <IHttpActionResult> PostPhotoSaveHistory(PhotoSaveHistoryBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var photoSaveHistory = new PhotoSaveHistory()
            {
                UserId  = model.UserId,
                PhotoId = model.PhotoId,
                Date    = DateTime.Now,
                Deleted = false
            };

            db.PhotoSaveHistories.Add(photoSaveHistory);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = photoSaveHistory.Id }, photoSaveHistory));
        }