Пример #1
0
        public IActionResult GetExamById(int id)
        {
            ResponseOnLyExam response = new ResponseOnLyExam();
            var exam = _examServices.GetById(id);

            Global.Mapper.Map(exam, response);
            if (exam != null)
            {
                return(Ok(response));
            }
            else
            {
                return(NotFound());
            }
        }
        public string GetExam(int id)
        {
            ResultObject resultt = new ResultObject();

            try
            {
                var result = services.GetById(id);

                return(JsonConvert.SerializeObject(result, Formatting.Indented, new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                }));
            }
            catch (Exception e)
            {
                resultt.Message = "EXCEPTION: " + e.Message + "Stack: " + e.StackTrace;
                return(JsonConvert.SerializeObject(resultt));
            }
        }