public async Task <PartialViewResult> CreateOrEditModal(int?id) { ITruckAppService truckAppService = this._truckAppService; NullableIdInput <long> nullableIdInput = new NullableIdInput <long>() { Id = id }; GetTruckForEditOutput truckForEdit = await truckAppService.GetTruckForEdit(nullableIdInput); return(this.PartialView("_CreateOrEditModal", new CreateOrEditTruckModalViewModel(truckForEdit))); }
public virtual async Task <JsonResult> UpdateTruckImage(TruckImageUploadModel model) { JsonResult jsonResult; Guid? imageId; try { if (this.Request.Files.Count <= 0 || this.Request.Files[0] == null) { throw new UserFriendlyException(this.L("TruckImage_Change_Error")); } HttpPostedFileBase item = this.Request.Files[0]; if (item.ContentLength > 512000) { throw new UserFriendlyException(this.L("TruckImage_Warn_SizeLimit")); } GetTruckForEditOutput truckForEdit = await this._truckAppService.GetTruckForEdit(new NullableIdInput <long>(new long?((long)model.TruckId))); GetTruckForEditOutput nullable = truckForEdit; if (nullable.Truck.ImageId.HasValue) { IBinaryObjectManager binaryObjectManager = this._binaryObjectManager; imageId = nullable.Truck.ImageId; await binaryObjectManager.DeleteAsync(imageId.Value); } BinaryObject binaryObject = new BinaryObject(item.InputStream.GetAllBytes()); await this._binaryObjectManager.SaveAsync(binaryObject); nullable.Truck.ImageId = new Guid?(binaryObject.Id); model.Id = nullable.Truck.ImageId; UpdateTruckImageInput updateTruckImageInput = new UpdateTruckImageInput() { TruckId = nullable.Truck.Id.Value }; imageId = nullable.Truck.ImageId; updateTruckImageInput.ImageId = new Guid?(imageId.Value); await this._truckAppService.SaveImageAsync(updateTruckImageInput); jsonResult = this.Json(new MvcAjaxResponse()); } catch (UserFriendlyException userFriendlyException1) { UserFriendlyException userFriendlyException = userFriendlyException1; jsonResult = this.Json(new MvcAjaxResponse(new ErrorInfo(userFriendlyException.Message), false)); } return(jsonResult); }
public CreateOrEditTruckModalViewModel(GetTruckForEditOutput output) { output.MapTo <GetTruckForEditOutput, CreateOrEditTruckModalViewModel>(this); }