Example #1
0
        public ActionResult DeleteUser(string id)
        {
            var modelFromRepo = _repository.GetUserById(id);

            if (modelFromRepo == null)
            {
                _logger.LogInformation("DELETE USER failed. No user with {id}", id);
                return(NotFound());
            }
            try
            {
                _repository.DeleteUser(modelFromRepo);
                _repository.SaveChanges();
                _logger.LogError("DELETE USER with {UserId} succesfull.", id);
            }
            catch (Exception ex)
            {
                _logger.LogError("DELETE USER with ID:{UserId} failed. Exception: {exException}", id, ex.Message);
            }


            return(NoContent());
        }