public async Task <IActionResult> UpdateEvent([FromRoute] int id, [FromBody] EventUpdateDto evtUpdDto) { var eventItem = await _repository.GetEventById(id); if (eventItem == null) { return(NotFound()); } _mapper.Map(evtUpdDto, eventItem); //Real Update _repository.UpdateEvent(eventItem); // Not Necessary return(NoContent()); }
public ActionResult UpdateEvent(Event e, int id) { try { if (ModelState.IsValid) { eventRepo.UpdateEvent(e); 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)); }