コード例 #1
0
 public async Task <IActionResult> Get()
 {
     return(await FunctionWrapper.ExecuteFunction(this, async() =>
     {
         return await _screenRepository.GetAll();
     }));
 }
コード例 #2
0
        public ActionResult <ApiResponse <List <ScreenDto> > > GetAll()
        {
            var response = new ApiResponse <List <ScreenDto> >();

            try
            {
                List <ScreenDto> dtos = _mapper.Map <List <ScreenDto> >(_screenRepository.GetAll());
                foreach (var item in dtos)
                {
                    item.ScreenId = item.Id;
                    item.Id       = 0;
                }
                response.Result = dtos;
            }
            catch (Exception ex)
            {
                response.Result  = null;
                response.Success = false;
                response.Message = "Internal server error";
                _logger.LogError($"Something went wrong: { ex.ToString() }");
                return(StatusCode(500, response));
            }

            return(Ok(response));
        }