Esempio n. 1
0
        public async Task <IActionResult> GetCodeId(int id)
        {
            var Response = new SingleResponse <object>();

            try
            {
                if (!_ICodeRepository.DoesCodeExist(id))
                {
                    Response.DidError = true;
                    Response.Message  = $"The Code with the id: {id} was not found in the database.";
                    _Logger.LogError(ControllerContext, Response.Message);
                }
                else
                {
                    Response.Model = await _ICodeRepository.GetCodeByIdAsync(id);

                    Response.Message = $"Querying Code with the id: {id}.";
                    _Logger.LogInfo(ControllerContext, Response.Message);
                }
            }
            catch (Exception ex)
            {
                Response.DidError = true;
                Response.Message  = "Internal Server Error.";
                _Logger.LogError(ControllerContext, $"Error Message: {ex.Message}");
            }
            return(Response.ToHttpResponse());
        }