Ejemplo n.º 1
0
        public ActionResult GetDetail(string id)
        {
            var model = _FooterService.GetById(id);

            return(Json(new
            {
                status = true,
                data = model
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetById(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                var model = _footerService.GetById(id);

                var responseData = Mapper.Map <Footer, FooterViewModel>(model);

                var response = request.CreateResponse(HttpStatusCode.OK, responseData);

                return response;
            }));
        }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> Put(HttpRequestMessage request, FooterViewModel footerVm)
        {
            //Khoi tao
            var footerDb = await _footerService.GetById(footerVm.ID);

            //AutoMapper
            footerDb.UpdateFooter(footerVm);
            return(await CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (ModelState.IsValid)
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    _footerService.Update(footerDb);
                    _footerService.SaveAsync();
                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                return response;
            }));
        }