/// <summary> /// Creates a new event for the selected Availalibity /// </summary> /// <param name="venueCode">the code of the venue to be selected</param> /// <param name="eventType">the event type</param> /// <param name="date">The date of the event</param> /// <returns>The create view initialised with values</returns> public IActionResult CreateEvent(string venueCode, string eventType, DateTime date) { if (venueCode == null || eventType == null) { return(NotFound()); } Debug.WriteLine(date); var @event = new VenueEvent { Venue = venueCode, TypeId = eventType, Date = date.ToString("yyyy-MM-dd") }; Debug.WriteLine(@event.Date); return(View(@event)); }
public async Task <IActionResult> CreateEvent([Bind("Id,Title,Date,Duration,TypeId,Venue")] VenueEvent @event) { if (ModelState.IsValid) { var newEvent = new Event { Id = @event.Id, Title = @event.Title, Date = DateTime.Parse(@event.Date), Duration = @event.Duration, TypeId = @event.TypeId, Venue = @event.Venue }; newEvent.IsActive = true; _context.Add(newEvent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), "Events")); } return(View(@event)); }