Пример #1
0
        public async Task <IActionResult> DeleteImageAsync([FromRoute] int imageId)
        {
            try
            {
                var img = await _imageService.GetPicture(imageId);

                if (!CorrectUserOrAdmin(img.Accommodation.Owner.Id, GetIdOfLoggedInUser(HttpContext), GetUsertypeOfLoggedInUser(HttpContext)))
                {
                    return(BadRequest("Only the accommodation's owner or admin can remove photos from an accommodation!"));
                }

                await _deletionService.DeletePictureAsync(imageId);

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(NotFound(ex.Message));
            }
        }