예제 #1
0
        public Task <CarCreateResponseDto> Create(CarCreateRequestDto carDto)
        {
            var car    = _mapper.Map <CarCreateRequestDto, CarEntity>(carDto);
            var result = _carsRepository.Create(car);

            return(Task.FromResult(_mapper.Map <CarEntity, CarCreateResponseDto>(result)));
        }
예제 #2
0
        public async Task <bool> Create(Car entity, string userId)
        {
            await _repository.Create(entity);

            await _repository.SaveChangesAsync();

            var car = await _repository.GetIQueryableCars()
                      .FirstOrDefaultAsync(c => c.UniqueNumber == entity.UniqueNumber);

            CustomUser user;

            if (userId != string.Empty)
            {
                user = await _identityService.FindUser(userId);

                if (car != null && user != null)
                {
                    var carId  = car.Id;
                    var result = await _repository.AddVehicleRelationToUser(carId, userId);

                    if (result > 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #3
0
        public async Task <ActionResult> Create(VMCars carEntity)
        {
            if (ModelState.IsValid)
            {
                carEntity.Car.ModPerson = _businessLogic.CheckIfUserIsAuthAndReturnName();
                _carsRepository.Create(carEntity.Car);
                var model = new Email().CreateEmailModel(carEntity.Car.ModPerson.Contains("Niezalogowany")
                    ? EmailType.OtherUser
                    : EmailType.UserAuth);

                await _emailAdapter.SendEmail(model);

                return(RedirectToAction("Index"));
            }

            return(View(carEntity));
        }
예제 #4
0
 public IActionResult Create([Bind("Brand,Name")] Car car)
 {
     if (ModelState.IsValid)
     {
         _carsRepository.Create(car.Brand, car.Name);
         return(RedirectToAction("Index"));
     }
     return(View(car));
 }
예제 #5
0
        public void Create(CarModel carmodel)
        {
            var car = new Car
            {
                Id   = carmodel.Id,
                Name = carmodel.Name
            };

            repository.Create(car);
        }
예제 #6
0
        public ActionResult Create(VMCars carEntity)
        {
            if (ModelState.IsValid)
            {
                carEntity.Car.ModPerson = _businessLogic.CheckIfUserIsAuthAndReturnName();
                _carsRepository.Create(carEntity.Car);
                return(RedirectToAction("Index"));
            }

            return(View(carEntity));
        }
예제 #7
0
        public void Create(CarModel carmodel)
        {
            var car = new Car
            {
                Name  = carmodel.Name,
                Parts = carmodel.Parts.Select(x => new Detail {
                    CarId = x.CarId, Name = x.Name, Price = x.Price
                }).ToList()
            };

            repository.Create(car);
        }
예제 #8
0
        public async Task <ActionResult> Create(VMCars carEntity)
        {
            if (ModelState.IsValid)
            {
                carEntity.Car.ModPerson = _businessLogic.CheckIfUserIsAuthAndReturnName();
                _carsRepository.Create(carEntity.Car);
                var model = new EmailApiModel();
                model.To = "doKogo";
                await _emailClient.Post(model);

                return(RedirectToAction("Index"));
            }

            return(View(carEntity));
        }
        public async Task <ActionResult> Create(VMCars carEntity)
        {
            if (ModelState.IsValid)
            {
                carEntity.Car.ModPerson = _carBusinessLogic.CheckIfUserIsAuthAndReturnName();
                _carsRepository.Create(carEntity.Car);
                var client = new Client();
                var model  = new EmailApiModel();
                model.To = "*****@*****.**";

                await client.SendEmail(model);

                return(RedirectToAction("Index"));
            }

            return(View(carEntity));
        }
예제 #10
0
        public async Task <ActionResult> Create(VMCars carEntity)
        {
            if (ModelState.IsValid)
            {
                carEntity.Car.ModPerson = _businessLogic.CheckIfUserIsAuthAndReturnName();
                _carsRepository.Create(carEntity.Car);
                var client = new Client();
                var model  = new ContactForm();
                model.Email   = "*****@*****.**";
                model.Body    = "message";
                model.Subject = "Test";
                var email = await client.SendEmail(model);

                return(RedirectToAction("Index"));
            }

            return(View(carEntity));
        }
예제 #11
0
 public void Create(Car car)
 {
     _validator.ValidateCreationFieldsAreFilled(car);
     _carsRepository.Create(car);
 }