Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public bool UpdateEntity(BabyPhotoModel obj)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
 public long SaveEntity(BabyPhotoModel obj)
 {
     obj.UserId = this.accountService.GetCurrentUser().Result.Id;
     this.context.BabyPhotoModels.Add(obj);
     return(this.context.SaveChanges());
 }
Ejemplo n.º 4
0
 public bool Delete(BabyPhotoModel obj)
 {
     throw new NotImplementedException();
 }