public ActionResult AddEvent(EventCreateDto newEvent) { var theEvent = mapper.Map <Event>(newEvent); repo.CreateEvent(theEvent); repo.SaveChanges(); return(Ok(theEvent)); }
public async Task <IActionResult> CreateEvent([FromBody] EventCreateDto evtCrtDto) { var eventModel = _mapper.Map <Event>(evtCrtDto); var res = await _repository.CreateEvent(eventModel); var evtRdDto = _mapper.Map <EventReadDto>(eventModel); // return CreatedAtRoute(nameof(GetEventById), new {Id = evtRdDto.Id}, evtRdDto); return(Ok(res)); }
public ActionResult CreateEvent(Event e, int eventType) { try { if (ModelState.IsValid) { eventRepo.CreateEvent(e, eventType); return(RedirectToAction("EventList")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(e)); }