Example #1
0
        public async Task <IActionResult> Delete(int userId)
        {
            try
            {
                var oldUser = await UnitOfWork.GetUserByIdAsync(userId);

                if (oldUser == null)
                {
                    return(NotFound());
                }

                await UnitOfWork.RemoveUserAsync(userId);

                return(Ok());
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }

            return(BadRequest("Failed to delete the user"));
        }