示例#1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <IActionResult> SaveAndUpdate(MpProductInfoDto input)
        {
            MpProductInfoDto result = null;

            //input.LastModificationTime = DateTime.Now;
            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 _MpProductInfoAppService.Create(input);
            }
            else
            {
                result = await _MpProductInfoAppService.Update(input);
            }
            return(Json(result));
        }
示例#2
0
 public CreateOrEditMpProductInfoViewModel(MpProductInfoDto output)
 {
     output.MapTo(this);
 }