public JsonResult AddModelImage(VehiclePictureModel model) { var entity = model.ToEntity(); var rs = _carService.AddModelImage(entity); return(Json(rs)); }
public async Task <IActionResult> UpdateVehiclesPicturePath([FromForm] VehiclePictureModel model) { try { if (ModelState.IsValid) { byte[] vehicleImage; using (var memoryStream = new MemoryStream()) { await model.VehicleImage.CopyToAsync(memoryStream); vehicleImage = memoryStream.ToArray(); } string guid = Guid.NewGuid().ToString(); string mime = model.VehicleImage.ContentType.Contains("/") ? model.VehicleImage.ContentType.Split("/")[1] : model.VehicleImage.ContentType; string fileName = $"{guid}.{mime}"; string realPath; try { realPath = _vehicleLogic.SaveVehiclesPicturePath(fileName, vehicleImage, model.VehicleId); } catch (Exception e) { return(StatusCode(500, e)); } if (string.IsNullOrWhiteSpace(realPath)) { return(BadRequest()); } return(Ok(realPath)); } else { return(BadRequest(ModelState)); } } catch (Exception e) { return(BadRequest(e)); } }
public static Model_Image_Mapping ToEntity(this VehiclePictureModel model, Model_Image_Mapping destination) { return(TypeAdapter.Adapt(model, destination)); }
public static Model_Image_Mapping ToEntity(this VehiclePictureModel model) { return(TypeAdapter.Adapt <VehiclePictureModel, Model_Image_Mapping>(model)); }