public async Task <IActionResult> EventCreate(EventCreateViewModel createVM) { try { if (ModelState.IsValid) { var createDto = _mapper.Map <EventCreateViewModel, EventCreateDTO>(createVM); await _eventUserManager.CreateEventAsync(createDto); return(RedirectToAction("EventUser")); } var dto = await _eventUserManager.InitializeEventCreateDTOAsync(); var model = _mapper.Map <EventCreateDTO, EventCreateViewModel>(dto); return(View(model)); } catch (Exception e) { return(RedirectToAction("HandleError", "Error", new { code = 500 })); } }
public async Task <IActionResult> EventCreate([FromBody] EventCreateDTO createDTO) { createDTO.Event.ID = await _eventUserManager.CreateEventAsync(createDTO); return(Created(nameof(GetEventUserByUserId), createDTO)); }