public ActionResult Create([Bind(Include = "TimelineItem")] TimelineViewModel _timelineViewModel) { if (ModelState.IsValid) { timelineService.Create(_timelineViewModel.TimelineItem); return(RedirectToAction("Details", "Referees", new { id = _timelineViewModel.TimelineItem.RefereeId, active = "Timeline" })); } _timelineViewModel.CategoryList = GetCategoryList(_timelineViewModel.TimelineItem.Referee.TournamentId); _timelineViewModel.LevelList = GetLevelList(); return(View(_timelineViewModel)); }
public IActionResult Create([FromBody] CreateTimelineDto timelineDto) { try { var timelineEntity = _timelineService.Create(_mapper.Map <Timeline>(timelineDto)); var responseDto = _mapper.Map <CreateTimelineResponseDto>(timelineEntity); return(Ok(responseDto)); } catch (UnauthorizedAccessException ex) { return(Unauthorized(new ErrorResponseDto { InternalErrorMessage = ex.Message, DisplayErrorMessage = "User is not authorized to execute the given request.", })); } catch (Exception ex) { return(BadRequest(new ErrorResponseDto(ex))); } }