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)); }
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(); } }
public void AddFish(Fish fish) { _context.Add(fish); _context.SaveChanges(); }