Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("AquariumId,Name,Address,Number,Open")] Aquarium aquarium)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aquarium);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aquarium));
        }
Exemplo n.º 2
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();
     }
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
 public void AddFish(Fish fish)
 {
     _context.Add(fish);
     _context.SaveChanges();
 }