예제 #1
0
        private async Task <IActionResult> SaveCar(CarModel carModel, string redirectAction)
        {
            List <string> imageErrors = new List <string>();

            if (Request != null)
            {
                imageErrors.AddRange(_carModelService.ValidateCarImages(Request.Form["images"]));
            }

            foreach (string error in imageErrors)
            {
                ModelState.AddModelError("", error);
            }

            if (!ModelState.IsValid)
            {
                return(View(carModel));
            }

            await _carModelService.SaveCarModelAsync(carModel, Request == null?new List <string>() : Request.Form["images"].ToList());

            return(RedirectToAction(redirectAction).WithSuccess("Success", "Successfully saved Car."));
        }
예제 #2
0
 public void ValidateCarImagesValidTest()
 {
     Assert.Empty(_carModelService.ValidateCarImages(new string[] { _jObject1.ToString(), _jObject2.ToString() }));
 }