public async Task <IActionResult> Create(CollabBeersViewModel collabBeersViewModel) { if (ModelState.IsValid) { Collaboration newCollabBeer = new Collaboration(); newCollabBeer.CollaborationRequestId = collabBeersViewModel.CollaborationRequest.Id; newCollabBeer.StyleId = collabBeersViewModel.BeerStyle.Id; newCollabBeer.Name = collabBeersViewModel.CollabBeerName; newCollabBeer.BrewSite = collabBeersViewModel.BrewSite; newCollabBeer.WhenCreated = DateTime.Now; _context.Add(newCollabBeer); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "breweries")); } return(View()); }
public async Task <IActionResult> Create(int?id, CollabBeersViewModel collabBeersViewModel) { Review newReview = collabBeersViewModel.Review; if (ModelState.IsValid) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; Fan loggedInFan = _context.Fan.Where(i => i.ApplicationId == userId).SingleOrDefault(); newReview.FanId = loggedInFan.Id; if (id != null) { newReview.CollaborationId = (int)id; } //newBeer.Name = breweryBeersViewModel.BeerName; _context.Add(newReview); await _context.SaveChangesAsync(); return(RedirectToAction("index", "collaborations")); } return(View()); }