예제 #1
0
        public async Task <IActionResult> Delete([FromRoute] Guid adId)
        {
            var userOwnsPost = await _adService.UserOwnsPostAsync(adId, HttpContext.GetUserId());

            if (!userOwnsPost.Success)
            {
                return(BadRequest(new { error = "You do not own this ad" }));
            }

            var deleted = await _adService.DeleteAdAsync(adId);

            if (deleted.Success)
            {
                return(NoContent());
            }

            return(NotFound("Such ad does not exists."));
        }