Exemplo n.º 1
0
        public HttpResponse Add(AddCarViewModel viewModel)
        {
            if (usersService.IsMechanic(User.Id))
            {
                return(Unauthorized());
            }

            var validateErrors = carsService.AddCarValidateErrors(viewModel);

            if (validateErrors.Any())
            {
                return(Error(validateErrors));
            }

            carsService.AddCar(viewModel, User.Id);

            return(Redirect("/Cars/All"));
        }