Ejemplo 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));
        }
Ejemplo n.º 2
0
        public async Task AddFishAsync(Fish fish)
        {
            if (fish.PhotoAvatar != null && fish.PhotoAvatar.Length > 0)
            {
                string imageUrl = await UploadImageAsync(fish.PhotoAvatar);

                fish.ImageUrl      = imageUrl;
                fish.ImageMimeType = fish.PhotoAvatar.ContentType;
                fish.ImageName     = Path.GetFileName(fish.PhotoAvatar.FileName);
                await _context.AddAsync(fish);

                await _context.SaveChangesAsync();
            }
        }