public async Task <ActionResult> AddVehicleAsync(AddEditVehicleViewModel model, List <IFormFile> attachment)
        {
            SetAddEditVehicleValidations(model, out bool valid);

            model.ModelID = Convert.ToInt32(Request.Form["modelID"].ToString().Substring(Request.Form["modelID"].ToString().IndexOf(',') + 1));


            //if (!valid)
            //{
            //    AddEditVehicleViewModel viewModel = new AddEditVehicleViewModel
            //    {
            //        Makes = await _vehicle.GenerateMakeList(),
            //        BodyStyles = await _vehicle.GenerateBodyStyleList(),
            //        Transmissions = await _vehicle.GenerateTransmissionTypeList(),
            //        Colors = await _vehicle.GenerateColorList(),
            //        Interiors = await _vehicle.GenerateInteriorList()

            //    };



            //    return View(viewModel);
            //}
            var noDupsList = attachment.GroupBy(x => x).Where(g => g.Count() == 1).Select(y => y.Key).OrderByDescending(x => x.FileName).ToList();



            var res = await _vehicle.AddVehicle(model);

            UploadedFile(noDupsList, res);

            return(View());
        }
Beispiel #2
0
        public async Task <IActionResult> createCar([FromBody] Vehicle vehicle)
        {
            var    token = Request.Headers["Authorization"];
            string id    = _tokenHelper.getUserFromToken(token);

            vehicle.OwnerId = id;

            await _vehicleRepository.AddVehicle(vehicle);

            Users user = await _userRepository.CheckUserById(id);

            if (user != null)
            {
                if (user.Stage == "first")
                {
                    await _userRepository.UpdateStage("second", id);

                    return(Ok(new { status = "update Stage" }));
                }
                if (user.Stage == "second")
                {
                    await _userRepository.UpdateStage("third", id);

                    return(Ok(new { status = "update Stage" }));
                }
            }


            return(Ok(new { status = "updated" }));
        }
Beispiel #3
0
        public async Task <ActionResult> Create(Models.Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                vehicle.CustomerId = User.Identity.GetUserId();
                vehicle.Id         = Guid.NewGuid();
                await _vehicle.AddVehicle(vehicle);

                return(RedirectToAction("Index"));
            }

            return(View(vehicle));
        }