public async Task <IActionResult> Create(string returnUrl) { EventAddViewModel vm = new EventAddViewModel(); vm.EventTypes = await _eventService.EventTypes.GetEventTypeSelectListAsync(); vm.EventSerieses = await _eventService.EventSeries.GetEventSeriesSelectListAsync(); vm.States = new StaticDataCollection().States; ViewBag.ReturnUrl = returnUrl; ViewData["Title"] = "Create Event"; ViewData["ActiveMenu"] = "Event"; ViewData["ActiveLink"] = "CreateEvent"; return(View(vm)); }
public async Task <IActionResult> Create([Bind( "EventTypeId," + "EventSeriesId," + "Title," + "Description," + "FundCenter," + "StartDate," + "EndDate," + "RegistrationOpenDate," + "RegistrationClosedDate," + "MinRegistrationCount," + "MaxRegistrationCount," + "AllowStandby," + "MaxStandbyRegistrationCount," + "AddressLine1," + "AddressLine2," + "City," + "State," + "Zip" )] EventAddViewModel form, string returnUrl) { if (!ModelState.IsValid) { form.EventTypes = await _eventService.EventTypes.GetEventTypeSelectListAsync(); form.EventSerieses = await _eventService.EventSeries.GetEventSeriesSelectListAsync(); form.States = new StaticDataCollection().States; ViewBag.ReturnUrl = returnUrl; ViewData["Title"] = "Create Event: Error"; ViewData["ActiveMenu"] = "Event"; ViewData["ActiveLink"] = "CreateEvent"; return(View(form)); } else { if (!_eventService.CreateEvent( out string response, form.EventTypeId, 0, form.Title, form.Description, form.StartDate, form.EndDate, form.RegistrationOpenDate, form.RegistrationClosedDate, form.AddressLine1, form.AddressLine2, form.City, form.State, form.Zip, form?.EventSeriesId ?? 0, form.MaxRegistrationCount, form?.MinRegistrationCount ?? 0, form.AllowStandby, form?.MaxStandbyRegistrationCount ?? 0, form.FundCenter )) { form.EventTypes = await _eventService.EventTypes.GetEventTypeSelectListAsync(); form.EventSerieses = await _eventService.EventSeries.GetEventSeriesSelectListAsync(); form.States = new StaticDataCollection().States; ModelState.AddModelError("", response); ViewBag.ReturnUrl = returnUrl; ViewData["Title"] = "Create Event: Error"; ViewData["ActiveMenu"] = "Event"; ViewData["ActiveLink"] = "CreateEvent"; return(View(form)); }