Ejemplo n.º 1
0
        public async Task <IActionResult> Delete([FromRoute] Guid contactInfoId)
        {
            var isOwner = await _contactInfoService.CheckUserForOwnership(contactInfoId, HttpContext.GetCurrentUserId());

            if (!isOwner)
            {
                return(BadRequest(new { error = "You are not the owner of this contact info" }));
            }

            var deleted = await _contactInfoService.DeleteAsync(contactInfoId);

            if (deleted)
            {
                await _redisCacheService
                .DeleteCachedResponseAsync(
                    new string[]
                {
                    HttpContext.Request.Path,
                    APIRoutes.ContactInfoControllerRoutes.GetAll
                });

                return(NoContent());
            }

            return(NotFound());
        }