Beispiel #1
0
 public HttpResponseMessage GetAll(HttpRequestMessage request)
 {
     return(CreateHttpResponse(request, () =>
     {
         Footer footerDb = _footerService.GetAll();
         FooterViewModel footerVm = Mapper.Map <FooterViewModel>(footerDb);
         return request.CreateResponse(HttpStatusCode.OK, footerVm);
     }));
 }
Beispiel #2
0
        public HttpResponseMessage GetAll(HttpRequestMessage request)
        {
            Func <HttpResponseMessage> func = () =>
            {
                var model = _FooterService.GetAll();
                //var a = _FooterService.GetFooterByNotPrice(22);
                var responseData = Mapper.Map <IEnumerable <Footer>, IEnumerable <FooterViewModel> >(model);

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

            return(CreateHttpResponse(request, func));
        }
Beispiel #3
0
        public ActionResult Index()
        {
            var model = _FooterService.GetAll().SingleOrDefault();
            var data  = Mapper.Map <Footer, FooterViewModel>(model);

            return(View(data));
        }
Beispiel #4
0
        public HttpResponseMessage Get(HttpRequestMessage request)
        {
            return(CreateHttpResponse(request, () =>
            {
                var listFooter = _footerService.GetAll();
                var listFooterVM = Mapper.Map <List <FooterViewModel> >(listFooter);
                HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, listFooterVM);

                return response;
            }));
        }
Beispiel #5
0
        public async Task <HttpResponseMessage> Get(HttpRequestMessage request)
        {
            var listFooter = await _footerService.GetAll();

            var listFooterVm = Mapper.Map <List <FooterViewModel> >(listFooter);

            return(await CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, listFooterVm); //Map
                return response;
            }));
        }
        //[OutputCache(Duration = 3600)]
        public ActionResult Footer()
        {
            FooterCommon footVm = new FooterCommon();
            IEnumerable <ProductCategory> listAll    = _productCategoryService.GetAll();
            IEnumerable <ProductCategory> listParent = listAll.Where(x => x.ParentID == null);
            List <ProductCategory>        listChild  = new List <ProductCategory> {
            };

            foreach (var item in listParent)
            {
                var list = listAll.Where(x => x.ParentID == item.ID);
                if (list.Count() == 0)
                {
                    listChild.Add(item);
                }
                else
                {
                    listChild.AddRange(list);
                }
            }
            listChild = listChild.OrderBy(x => x.Name).Take(9).ToList();
            IEnumerable <ProductCategoryViewModel> listCategoryVm = Mapper.Map <IEnumerable <ProductCategoryViewModel> >(listChild);

            footVm.listCategoryProduct = listCategoryVm;

            IEnumerable <Tag>          listTagProdut = _tagService.GetAll().Where(x => x.Type == Common.CommonConstant.ProductTag.ToString()).OrderBy(x => x.Name).Take(18);
            IEnumerable <TagViewModel> listTagVm     = Mapper.Map <IEnumerable <TagViewModel> >(listTagProdut);

            footVm.tagVm = listTagVm;

            SupportOnline          supportDb = _supportOnline.Get();
            SupportOnlineViewModel supportVm = Mapper.Map <SupportOnlineViewModel>(supportDb);

            footVm.supportOnlineVm = supportVm;

            Footer          footerDb = _footerService.GetAll();
            FooterViewModel footerVm = Mapper.Map <FooterViewModel>(footerDb);

            footVm.footerVm = footerVm;

            return(PartialView(footVm));
        }
Beispiel #7
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var cacheEntry = await _cache.GetOrCreateAsync(CacheKeys.FooterViewComponent, entry =>
            {
                entry.SlidingExpiration = TimeSpan.FromDays(1);
                var listFooters         = _footerService.GetAll().OrderBy(x => x.Order);
                var footer = new List <FooterDetails>();
                foreach (var item in listFooters)
                {
                    footer.Add(new FooterDetails()
                    {
                        FooterViewModel = item,
                        PageViewModels  = _footerService.GetAllPagesByFooterId(item.Id),
                    });
                }
                return(Task.FromResult(footer));
            });

            return(View(cacheEntry));
        }
Beispiel #8
0
        public HttpResponseMessage GetAll(HttpRequestMessage request, string keyword, int page, int pageSize = 20)
        {
            return(CreateHttpResponse(request, () =>
            {
                int totalRow = 0;
                var model = _footerService.GetAll(keyword);                                                 //lấy về toàn bộ số bản ghi và từ khoá tìm kiếm

                totalRow = model.Count();                                                                   //đếm
                var query = model.OrderByDescending(x => x.ID).Skip(page * pageSize).Take(pageSize);
                var reponseData = Mapper.Map <IEnumerable <Footer>, IEnumerable <FooterViewModel> >(query); //lấy giữ liệu thông qua mapper và duyệt từng phần từ

                var paginationSet = new PaginationSet <FooterViewModel>()
                {
                    Items = reponseData,
                    Page = page,
                    TotalCount = totalRow,
                    TotalPages = (int)Math.Ceiling((decimal)totalRow / pageSize)
                };
                var response = request.CreateResponse(HttpStatusCode.OK, paginationSet);
                return response;
            }));
        }
Beispiel #9
0
 public IEnumerable <Footer> GetAll()
 {
     return(_footerRepository.GetAll());
 }