Example #1
0
        public async Task <IActionResult> ApprovePhoto(int photoId)
        {
            var photo = await _repo.GetPhoto(photoId);

            if (photo == null)
            {
                return(NotFound("Photo with id=" + photoId + " does not exist"));
            }

            if (photo.IsApproved)
            {
                return(BadRequest("This photo is already approved."));
            }

            _repo.ApprovePhoto(photoId);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to approve photo"));
        }