public string UpLoad() { string msg = ""; string webRoot = this.hostingEnvironment.WebRootPath; IFormFileCollection listFiles = this.Request.Form.Files; foreach (IFormFile formFile in listFiles) { long imageSize = formFile.Length; string filrNmae = formFile.FileName; string path = webRoot + @"\Image\" + filrNmae; try { using (var stream = new FileStream(path, FileMode.Create)) { formFile.CopyTo(stream); } BabyPhotoModel obj = new BabyPhotoModel() { Id = Guid.NewGuid().ToString(), PhotoName = filrNmae, PhotoSize = (int)imageSize, Url = "Image/" + filrNmae, UploadDate = DateTime.Now, UploadPerson = "宁凡栋" }; this.babyPhotoRepository.SaveEntity(obj); } catch (Exception e2) { throw e2; } msg = $"文件名:{formFile.FileName};文件类型:{formFile.ContentType}"; } return(msg); }
public bool UpdateEntity(BabyPhotoModel obj) { throw new NotImplementedException(); }
public long SaveEntity(BabyPhotoModel obj) { obj.UserId = this.accountService.GetCurrentUser().Result.Id; this.context.BabyPhotoModels.Add(obj); return(this.context.SaveChanges()); }
public bool Delete(BabyPhotoModel obj) { throw new NotImplementedException(); }