Beispiel #1
0
        public IActionResult AddQuestion([FromBody] PrecautionQADto questionDto)
        {
            var question = _mapper.Map <PrecautionQA>(questionDto);

            try
            {
                _service.Create(question);
                return(Ok("Records Added Successfully.. "));
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Beispiel #2
0
        public IActionResult UpdateQuestion(int id, [FromBody] PrecautionQADto questionDto)
        {
            var question = _mapper.Map <PrecautionQA>(questionDto);

            try
            {
                _service.Update(id, question);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Beispiel #3
0
        ///TODO- need to add this profile fields in db and api
        public IActionResult GetQuestionByTypeID([FromBody] PrecautionQADto queDto)
        {
            var           question = _service.GetAllQuestions();
            List <string> Dto      = new List <string>();

            foreach (var item in question)
            {
                if (queDto.PrecautionTypeID == item.PrecautionTypeID)
                {
                    PrecautionQADto Dtos = _mapper.Map <PrecautionQADto>(item);
                    Dto.Add(Dtos.Question);
                }
            }
            return(Ok(Dto));
        }
Beispiel #4
0
        public IActionResult GetAllQuestion() //[FromBody]JObject jobject
        {
            var question = _service.GetAllQuestions();
            List <PrecautionQADto> Dto = new List <PrecautionQADto>();

            foreach (var item in question)
            {
                PrecautionQADto Dtos = _mapper.Map <PrecautionQADto>(item);
                Dto.Add(Dtos);
            }
            return(Ok(Dto));
            //return Ok(new
            //{
            //    items = Dto,
            //    totalCount = Dto.Count(),
            //    errorMessage = string.Empty
            //});
        }
Beispiel #5
0
        ///TODO- need to add this profile fields in db and api
        public IActionResult GetQuestionByID(int id)
        {
            var question = _service.GetById(id);

            if (question == null)
            {
                return(new UnauthorizedResult());
            }

            PrecautionQADto questionDto = new PrecautionQADto()
            {
                ID = question.ID,
                PrecautionTypeID = question.PrecautionTypeID,
                Question         = question.Question,
                CreatedBy        = question.CreatedBy,
                CreatedOn        = question.CreatedOn,
                ModifiedBy       = question.ModifiedBy,
                ModifiedOn       = question.ModifiedOn,
            };

            return(Ok(questionDto));
        }