예제 #1
0
        public ActionResult Edit(int id)
        {
            Faq faq = _faqService.GetById(id);

            if (faq != null)
            {
                return(View(Mapper.Map <Faq, FaqModel>(faq)));
            }

            return(View("NotfoundDialog"));
        }
예제 #2
0
        public void FaqService_Delete()
        {
            IFaqService service = this.GetService <IFaqService>();
            Faq         result  = service.GetById(15);

            Assert.IsNotNull(result, "We a null value");
        }
예제 #3
0
        public ActionResult <ItemResponse <Faq> > GetById(int id)
        {
            int          responseCode = 200;
            BaseResponse responseData = null;

            try
            {
                Faq faq = _service.GetById(id);

                if (faq == null)
                {
                    responseCode = 404;
                    responseData = new ErrorResponse("Item was not found");
                }
                else
                {
                    responseData = new ItemResponse <Faq> {
                        Item = faq
                    }
                };
            }
            catch (Exception exception)
            {
                responseCode = 500;
                responseData = new ErrorResponse($"Generic Error: {exception.Message}");
                base.Logger.LogError(exception.ToString());
            }
            return(StatusCode(responseCode, responseData));
        }
        public HttpResponseMessage GetById(int id)
        {
            try
            {
                ItemResponse <Faq> response = new ItemResponse <Faq>();
                response.Item = _faqService.GetById(id);


                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                _errorService.LogError(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }