Example #1
0
        public IActionResult Add(PointViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                var point = _Mapper.Map <Point>(viewModel);

                _PointBL.Add(GetUserId(), point);

                return(Ok(_Mapper.Map <PointViewModel>(point)));
            }
            catch (BusinessException ex)
            {
                return(BadRequest((ErrorCodes)ex.ErrorCode));
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex, $"Error in {typeof(PointsController)}: {ex.Message}");
                return(StatusCode(500));
            }
        }
Example #2
0
        public IActionResult Add(TeamViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                var team = _mapper.Map <Team>(viewModel);

                _teamBL.Add(GetUserId(), team);

                viewModel = _mapper.Map <TeamViewModel>(team);
                viewModel.AddQrCode(viewModel.RaceId);
                return(Ok(viewModel));
            }
            catch (BusinessException ex)
            {
                return(BadRequest((ErrorCodes)ex.ErrorCode));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error in {typeof(TeamsController)}: {ex.Message}");
                return(StatusCode(500));
            }
        }