예제 #1
0
        public async Task <IActionResult> Index(int id, DateTime FromDate, DateTime ToDate, string ApDung = "0", int page = 1)
        {
            var linhkien = await _lkRepo.getById(id);

            if (linhkien == null)
            {
                return(View("~/Views/Error/404.cshtml"));
            }

            ViewBag.IdProduct   = linhkien.Id;
            ViewBag.NameProduct = linhkien.TenLK;

            IEnumerable <DonGia> gias = new List <DonGia>();

            if (FromDate == DateTime.MinValue)
            {
                gias = await _giaRepo.getAll(linhkien.Id);
            }
            else
            {
                gias = await _giaRepo.Filter(linhkien.Id, FromDate, ToDate, ApDung);
            }

            double count     = gias.Count();
            double i         = (double)(count / ItemPerPage);
            var    pageCount = (int)Math.Ceiling(i);

            gias = gias.Skip((page - 1) * ItemPerPage).Take(ItemPerPage).ToList();

            var dto = _mapper.Map <List <DonGiaDTO> >(gias);

            IndexViewModel <DonGiaDTO> returnList = PaginationServices <DonGiaDTO> .PaginationGia(dto, page, ItemPerPage, pageCount, FromDate, ToDate, ApDung);

            return(View("~/Views/Admin/Gia/Index.cshtml", returnList));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id)
        {
            var linhkien = await _linhKienRepository.getById(id);


            if (linhkien == null)
            {
                return(View("~/Views/Error/404.cshtml"));
            }

            LinhKienDTO dto = _mapper.Map <LinhKienDTO>(linhkien);

            //Get All Category
            var categorys = await _llkRepository.getAll();

            var categoryDTO = _mapper.Map <List <LoaiLinhKienDTO> >(categorys);

            ViewBag.Category = categoryDTO;

            //Get All Manufactuer
            var manufactuers = await _nccRepository.getAll();

            var manuDTO = _mapper.Map <List <NhaCungCapDTO> >(manufactuers);

            ViewBag.Manu = manuDTO;

            var images = dto.Hinh.Split(",");

            ViewBag.Hinh = images;

            return(View("~/Views/Admin/Product/Edit.cshtml", dto));
        }
예제 #3
0
        public async Task <IActionResult> Detail(int id)
        {
            var product = await _linhkienRepo.getById(id);

            if (product == null)
            {
                return(View("~/Views/Error/404.cshtml"));
            }
            product.DonGias = product.DonGias.Where(i => i.ApDung).ToList();
            var result = mapper.Map <LinhKienDTO>(product);

            return(View(result));
        }