Пример #1
0
        public async Task <IActionResult> Delete(int id)
        {
            if (await _repository.GetByIdAsync(id) == null)
            {
                return(NotFound());
            }

            if (await _repository.DeleteByIdAsync(id))
            {
                return(Ok());
            }
            else
            {
                return(StatusCode(500));
            }
        }
Пример #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var userId = _userManager.GetUserId(User);

            if (userId == null)
            {
                return(StatusCode(401));
            }

            if (await _repository.GetByIdAsync(id, userId) == null)
            {
                return(NotFound());
            }

            if (await _repository.DeleteByIdAsync(id))
            {
                return(Ok());
            }
            else
            {
                return(StatusCode(500));
            }
        }