Example #1
0
 public void AddFish(Fish fish)
 {
     if (fish.PhotoAvatar != null && fish.PhotoAvatar.Length > 0)
     {
         string imageURL = UploadImageAsync(fish.PhotoAvatar).GetAwaiter().GetResult();
         fish.ImageURL  = imageURL;
         fish.ImageName = Path.GetFileName(fish.PhotoAvatar.FileName);
         _context.Add(fish);
         _context.SaveChanges();
     }
 }
 public void AddFish(Fish fish)
 {
     if (fish.PhotoAvatar != null && fish.PhotoAvatar.Length > 0)
     {
         fish.ImageMimeType = fish.PhotoAvatar.ContentType;
         fish.ImageName     = Path.GetFileName(fish.PhotoAvatar.FileName);
         using (var memoryStream = new MemoryStream())
         {
             fish.PhotoAvatar.CopyTo(memoryStream);
             fish.PhotoFile = memoryStream.ToArray();
         }
         _context.Add(fish);
         _context.SaveChanges();
     }
 }
Example #3
0
 public void AddFish(Fish fish)
 {
     _context.Add(fish);
     _context.SaveChanges();
 }