public async Task AddPitchAsync(CreatePitchCommand command) { var pitch = new Pitch(command.Name, command.Surface, command.Lightning, command.Street, command.City); await _context.Pitches.AddAsync(pitch); await _context.SaveChangesAsync(); }
public async Task <IActionResult> NewPitch(CreatePitchCommand command) { if (!ModelState.IsValid) { ViewBag.ShowMessage = true; ViewBag.Message = "Something went wrong"; return(View()); } try { await _pitchservice.AddPitchAsync(command); ViewBag.Added = true; return(View()); } catch (InternalSystemException ex) { ViewBag.ShowMessage = true; ViewBag.Message = ex.Message; return(View()); } catch (Exception) { ViewBag.ShowMessage = true; ViewBag.Message = "Something went wrong!"; return(View()); } }