public async Task <ActionResult <EventDayDto> > CreateEvent(EventDayDto dto) { if (await _eventDayRepo.GetEventAsync(dto.Name, false) is not null) { ModelState.AddModelError("Name", "Name already in use"); return(BadRequest(ModelState)); } var eventday = _mapper.Map <EventDay>(dto); await _eventDayRepo.AddAsync(eventday); if (await _eventDayRepo.SaveAsync()) { var model = _mapper.Map <EventDayDto>(eventday); return(CreatedAtAction(nameof(GetEvent), new { name = model.Name }, model)); } else { return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }