public async Task <IActionResult> Update(CarTransportaionUpdateViewModel model, IFormFile pic) { var result = await _carTransportRepository.UpdateCars(model, pic); TempData.AddResult(result); return(Redirect(IndexUrlWithQueryString)); }
public async Task <SweetAlertExtenstion> UpdateCars(CarTransportaionUpdateViewModel model, IFormFile file) { if (file != null) { if (model.Pic != null) { var WebContent = _hostingEnvironment.WebRootPath; if (model.Pic != "Images/no-Pic.jpg") { System.IO.File.Delete(WebContent + FilePath.Product.GetDescription()); } } model.Pic = await MFile.Save(file, FilePath.Cars.GetDescription()); } var result = model.ToEntity(await GetByIdAsync(model.Id)); await UpdateAsync(result); return(SweetAlertExtenstion.Ok()); }