public async Task <IActionResult> UploadXML(IFormFile file)
        {
            List <ShowroomListForXMLModel.Showroom> showroomList = Utils.UploadXML.UploadShowroomXML(file);
            Showroom tempShowroom;
            Car      tempCar;

            foreach (var showroom in showroomList)
            {
                tempShowroom = _showroomModel.GetByName(showroom.Name).Result;
                if (tempShowroom != null)
                {
                    foreach (var car in showroom.Cars)
                    {
                        tempCar = _carModel.GetByVIN(car.VIN).Result;
                        if (tempCar != null)
                        {
                            await _carModel.Update(new Car
                            {
                                Brand      = car.Brand,
                                Model      = car.Model,
                                ShowroomId = tempShowroom.Id,
                                Id         = tempCar.Id
                            });
                        }
                        else
                        {
                            await _carModel.Create(new Car
                            {
                                Brand      = car.Brand,
                                Model      = car.Model,
                                VIN        = car.VIN,
                                ShowroomId = tempShowroom.Id
                            });
                        }
                    }
                }
                else
                {
                    tempShowroom = new Showroom {
                        Name = showroom.Name
                    };
                    await _showroomModel.Create(tempShowroom);

                    foreach (var car in showroom.Cars)
                    {
                        await _carModel.Create(new Car
                        {
                            Brand      = car.Brand,
                            Model      = car.Model,
                            VIN        = car.VIN,
                            ShowroomId = tempShowroom.Id
                        });
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Create(CarViewModel model, int CarTypeId)
 {
     model.Car.CarTypeId = CarTypeId;
     _carRepository.Create(model.Car);
     _carRepository.Save();
     return(RedirectToAction("Index")); //перенаправление на главную страницу со списком
 }
 public IActionResult AddCar(Car car)
 {
     if (ModelState.IsValid)
     {
         repo.Create(car);
         return(RedirectToAction("Index"));
     }
     return(View(car));
 }
Пример #4
0
        public ActionResult Create(Car car, HttpPostedFileBase file)
        {
            _carRep.Create(car);
            var lastCarId = _carRep.GetAll().Max(i => i.Car_ID);

            _carRep.UploadImageReturnID(lastCarId, file);

            return(RedirectToAction("Index"));
        }
        public ActionResult Create(Car car)
        {
            if (ModelState.IsValid)
            {
                _abstractRepository.Create(car);
                return(RedirectToAction("Index"));
            }

            return(View(car));
        }
Пример #6
0
        public IActionResult Create(CarViewModel carViewModel)
        {
            if (!ModelState.IsValid)
            {
                carViewModel.CarMarks = _carMarkRepository.GetAll();
                return(View(carViewModel));
            }
            _carRepository.Create(carViewModel.Car);

            return(RedirectToAction("List"));
        }
Пример #7
0
        public ActionResult Create(Car car, int currentDriverId)
        {
            if (ModelState.IsValid)
            {
                car.CurrentDriver = driverRepository.GetById(currentDriverId);
                carsRepository.Create(car);
                return(RedirectToAction("Index"));
            }

            return(View(car));
        }
        public virtual async Task AddCar(Car car)
        {
            if (car == null)
            {
                throw new ArgumentNullException("addCar");
            }
            car.Id = await GetNewId();

            _carRepository.Create(car);
            await _unitOfWork.SaveChangesAsync();
        }
Пример #9
0
        public ActionResult Reservation(Car car, Customer customer, int reservationId)
        {
            carRepository.Create(car);
            customerRepository.Create(customer);
            var reservation = reservationRepository.Get(reservationId);
            var maintenance = maintenanceService.Create(car.Id, customer.Id, reservation);
            var services    = serviceTypeRepository.GetServiceTypes().ToList();

            return(View("CountPrice", new CountPriceViewModel {
                MaintenanceId = maintenance.Id, Services = services
            }));
        }
Пример #10
0
        public ActionResult Create(Car car)
        {
            if (ModelState.IsValid)
            {
                _carRepository.Create(car);
                var message = _emailService.CreateMailMessage(car);
                _emailService.SendEmail(message);

                return(RedirectToAction("Index"));
            }
            return(View(car));
        }
Пример #11
0
        public async Task <ActionResult> Create([FromBody] CarJson car)
        {
            try
            {
                await carRepository.Create(car);

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
Пример #12
0
        public ActionResult Create(Car car)
        {
            try
            {
                repository.Create(car);

                return(RedirectToAction("List"));
            }
            catch
            {
                return(View());
            }
        }
Пример #13
0
        public ActionResult Reservation(Car car, Customer customer, int reservationId)
        {
            if (masterRepository.GetMasters().Any(m => m.CarBrand == car.Brand))
            {
                carRepository.Create(car);
                customerRepository.Create(customer);
                var reservation = reservationRepository.Get(reservationId);
                var maintenance = maintenanceService.Create(car.Id, customer.Id, reservation);
                return(RedirectToAction("Masters", new { maintenanceId = maintenance.Id }));
            }

            return(RedirectToAction("NoMaster", new { reservationId = reservationId }));
        }
Пример #14
0
 public IActionResult CreateCar([FromBody] CarDto carDto)
 {
     if (ModelState.IsValid)
     {
         var carToCreate = _mapper.Map <Car>(carDto);
         var create      = _carRepo.Create(carToCreate);
         return(Created($"https://localhost:5001/car/{create.Id}", create));
     }
     else
     {
         return(BadRequest("ModelState is not valid."));
     }
 }
Пример #15
0
        public async Task <bool> CreateCar(Car car)
        {
            try
            {
                _carRepository.Create(car);
                await _carRepository.SaveAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
 public ActionResult Create([Bind(Include = "Id,Type,Vin,Model,Make,Year,Milage")] Car car)
 {
     if (ModelState.IsValid)
     {
         _carRepo.Create(car);
         _flashMessenger.Success("Car Created");
         return(RedirectToAction("Index"));
     }
     else
     {
         _flashMessenger.Error("Invalid Car Data");
         return(View("Create", car));
     }
 }
Пример #17
0
        public void Create(CarModel car)
        {
            var carModel = new Car()
            {
                Id      = car.Id,
                Name    = car.Name,
                Details = (from det in car.Details
                           select new Detail()
                {
                    Id = det.Id, CarID = det.CarID, Name = det.Name
                }).ToList()
            };

            repository.Create(carModel);
        }
Пример #18
0
        public ActionResult Create(CarEntity carEntity)

        {
            if (ModelState.IsValid)

            {
                carEntity.ModPerson = _businessLogic.CheckIf();
                _carRepository.Create(carEntity);

                return(RedirectToAction("Index"));
            }



            return(View(carEntity));
        }
Пример #19
0
        public Car CreateCar(string email, Car car)
        {
            var owner = _owner.GetOwnerByEmail(email);

            if (owner == null)
            {
                throw new Exception("Invalid Owner Email");
            }

            car.Validate();
            car.OwnerId = owner.OwnerId;

            var newCar = _car.Create(car);

            return(newCar);
        }
Пример #20
0
        public Car Create(string brand, string modelName, DateTime year)
        {
            if (string.IsNullOrWhiteSpace(brand) ||
                string.IsNullOrWhiteSpace(modelName) ||
                year == null
                )
            {
                return(null);
            }

            Car car = new Car()
            {
                Brand = brand, ModelName = modelName, Year = year
            };

            return(_carRepo.Create(car));
        }
Пример #21
0
        public void Create(CarModel model)
        {
            var car = new Car
            {
                Name  = model.Name,
                Price = model.Price,

                Detals = model.Detals.Select(x => new Detal
                {
                    Model       = x.Model,
                    Name        = x.Name,
                    DetalTypeId = (int)x.Type,
                    Price       = x.Price
                }).ToList()
            };

            _carRepository.Create(car);
        }
Пример #22
0
        public IActionResult Create([FromBody] Car Car)
        {
            var claims = User.Claims.Select(claim => new { claim.Type, claim.Value }).ToDictionary(t => t.Type, t => t.Value);

            if (claims.ContainsKey("name"))
            {
                if (claims["name"].Equals("ADMIN") || claims["name"].Equals("MANAGER") || claims["name"].Equals("PARTNER"))
                {
                    Car.Id = Guid.NewGuid() + "";
                }
                Car.IsDelete = false;
                return(Ok(_repository.Create(Car)));
            }
            else
            {
                return(Forbid());
            }
            return(Forbid());
        }
Пример #23
0
            /// <summary>
            /// Implementación de <see cref="IRequestHandler{TRequest, TResponse}.Handle(TRequest, CancellationToken)"/>
            /// </summary>
            public async Task <int> Handle(Request request, CancellationToken cancellationToken)
            {
                CarInfo car = await _CarRepository.Get(request.License);

                car             = car ?? new CarInfo();
                car.Image       = request.Image;
                car.IsAvailable = request.IsAvailable;
                car.IsNew       = request.IsNew;
                car.License     = request.License;
                car.ModelId     = request.ModelId;
                car.Year        = request.Year;

                using (IUnitOfWork context = _CarUnitOfWorkFactory.Create())
                {
                    if (car.ModelId == 0)
                    {
                        int brandId = await _Mediator.Send(new CreateBrandCommand.Request {
                            Name = request.BrandName
                        });

                        int modelId = await _Mediator.Send(new CreateCarModelCommand.Request {
                            BrandId = brandId, Name = request.ModelName
                        });

                        car.ModelId = modelId;
                    }

                    if (car.Id == 0)
                    {
                        await _CarRepository.Create(car);
                    }
                    else
                    {
                        await _CarRepository.Update(car);
                    }

                    await _CarRepository.Save();

                    context.Commit();
                }
                return(car.Id);
            }
Пример #24
0
        public async Task <IActionResult> Create(CarEditViewModel uniqueModelName)
        {
            if (!ModelState.IsValid)
            {
                var showrooms = await _showroomModel.GetAllActive();

                uniqueModelName.SetList(showrooms);
                return(View(uniqueModelName));
            }

            Car      car      = _mapper.Map <Car>(uniqueModelName);
            Showroom showroom = await _showroomModel.GetById(uniqueModelName.ShowroomId);

            await _carModel.Create(car);

            showroom.Cars.Add(car);

            await _showroomModel.Update(showroom);

            return(RedirectToAction(nameof(Details), new { id = car.Id }));
        }
Пример #25
0
        /// <summary>
        /// Insert new car into database.
        /// </summary>
        /// <param name="carDto"></param>
        /// <returns>Returns mapped car object - carDto.</returns>
        public async Task <CarDto> CreateCarAsync(CarCreateDto carDto)
        {
            Car car = new Car()
            {
                Brand = carDto.Brand,
                Model = carDto.Model,
                RegistrationNumber = carDto.RegistrationNumber,
                TypeOfCar          = carDto.TypeOfCar,
                NumberOfDoor       = carDto.NumberOfDoor,
                NumberOfSits       = carDto.NumberOfSits,
                YearOfProduction   = carDto.YearOfProduction,
                ImagePath          = carDto.ImagePath,
                DateCreated        = DateTime.Now
            };

            carRepository.Create(car);
            await carRepository.SaveChangesAsync();

            car = await carRepository.FindByIdAsync(car.CarId);

            return(mapper.Map <CarDto>(car));
        }
Пример #26
0
 public void Create(CarModel car)
 {
     if (IsValid(car) == false)
     {
         throw new Exception("Please change the name, this name is already taken!");
     }
     else
     {
         var carModel = new Car()
         {
             Id      = car.Id,
             Name    = car.Name,
             Details = car.Details.Select(x => new Detail
             {
                 Id    = x.Id,
                 Name  = x.Name,
                 CarID = x.CarID,
                 Price = x.Price
             }).ToList()
         };
         repository.Create(carModel);
     }
 }
Пример #27
0
        public async Task <int> Create(Car car)
        {
            var newId = await _repository.Create(car);

            return(newId);
        }
Пример #28
0
 public void Add(Car car)
 {
     _carRepository.Create(car);
 }
Пример #29
0
 public async Task Create(Car car)
 {
     await _carRepository.Create(car);
 }
Пример #30
0
 public IActionResult Create(Car newCar)
 {
     carRepo.Create(newCar);
     return(RedirectToAction("Index"));
 }