/// <summary> /// 保存 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IActionResult> SaveAndUpdate(MpProductTypeDto input) { MpProductTypeDto result = null; if (Request.Form.Files.Count > 0) { var profilePictureFile = Request.Form.Files.First(); byte[] fileBytes; using (var stream = profilePictureFile.OpenReadStream()) { fileBytes = stream.GetAllBytes(); } var fileInfo = new FileInfo(profilePictureFile.FileName); var extra = fileInfo.Extension.Substring(fileInfo.Extension.IndexOf(".") + 1); string fileUrl = await _fileServer.UploadFile(fileBytes, extra, MpMessageType.mpnews.ToString()); input.FilePathOrUrl = fileUrl; var filename = fileUrl.Substring(fileUrl.LastIndexOf("/") + 1); } if (input.Id == 0) { result = await _mpProductTypeAppService.Create(input); } else { result = await _mpProductTypeAppService.Update(input); } return(Json(result)); }
public CreateOrEditMpProductTypeViewModel(MpProductTypeDto output) { output.MapTo(this); }