Example #1
0
        public async Task <IActionResult> BangGia()
        {
            var checkDaiLy = false;

            if (User.Identity.IsAuthenticated)
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                checkDaiLy = _userManager.IsInRoleAsync(user, "Đại lý").Result;
            }
            var cards    = _cardRepository.Cards().ToList();
            var menhgias = _menhgiaRepository
                           .MenhGias().
                           Where(x => x.DaiLy == checkDaiLy).
                           OrderBy(x => x.Price).
                           ToList();
            var menhgia_cardVM = new MenhGia_CardViewModels
            {
                Cards     = cards,
                DsMenhGia = menhgias
            };

            ViewBag.data = menhgia_cardVM;
            return(View());
        }
Example #2
0
        public IActionResult GetCard()
        {
            var cards = _cardRepository.Cards().Where(x => x.Status).ToList();

            return(Json(new
            {
                data = cards
            }));
        }
Example #3
0
        public IActionResult Index()
        {
            var cards    = _CardRepository.Cards();
            var menhgias = (from mg in _menhgiaRepository.MenhGias()
                            orderby mg.Price
                            group mg by mg.DaiLy into dl
                            select new DaiLyThe
            {
                LoaiTaiKhoan = dl.Key  ? "Đại lý" : "Thường dân",
                key = dl.Key?"true":"false",
                MenhGias = dl.Where(x => x.DaiLy == dl.Key).ToList()
            }).ToList();

            var cardVM = new CardViewModels
            {
                Cards     = cards,
                DaiLyThes = menhgias
            };

            return(View(cardVM));
        }
        public IActionResult GetAll(string filter, int page, int pageSize = 10, int statusRad = 0)
        {
            var totalRows = 0;
            var NopCard   = _NopCardRepository.NopCards();
            var users     = _userManager.Users;
            var menhgias  = _menhGiaRepository.MenhGias();
            var cards     = _cardRepository.Cards();


            var data = from nc in NopCard
                       join user in users on nc.UserId equals user.Id
                       join mg in menhgias on nc.menhgiaId equals mg.Id
                       join c in cards on nc.cardId equals c.Id
                       where (statusRad == 1?nc.Status == true:nc.Status == false)
                       where (filter != null?user.UserName.Contains(filter):true)
                       orderby nc.NgayNopCard descending
                       select new NopCardViewModels
            {
                Id            = nc.Id,
                UserName      = user.UserName,
                LoaiThe       = c.Name,
                MenhGia       = mg.Price,
                NgayNopThe    = String.Format("{0:d/M/yyyy h:mm:ss}", nc.NgayNopCard),
                SoDienThoai   = nc.Phone,
                requiredLabel = nc.Required == "0"? "không":"nhanh",
                SoLuong       = nc.warenty,
                TrangThai     = nc.Status
            };

            totalRows = data.Count();
            var model = data.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            return(Json(new
            {
                data = model,
                total = totalRows,
                status = true
            }));
        }
        public IViewComponentResult Invoke()
        {
            var nopcards = _nopCardRepository.NopCards();
            var cards    = _cardRepository.Cards();
            var data     = (from card in cards
                            select new ChartCardViewModel
            {
                Label = card.Name,
                Data = nopcards.Where(x => x.cardId == card.Id).Count()
            }).ToList();

            return(View(data));
        }
Example #6
0
        public IActionResult LoadChartCart()
        {
            var nopcards = _nopCardRepository.NopCards();
            var cards    = _cardRepository.Cards();
            var data     = (from card in cards
                            select new ChartCardViewModel
            {
                Label = card.Name,
                Data = nopcards.Where(x => x.cardId == card.Id).Count()
            }).ToList();

            return(Json(new
            {
                status = true,
                data = data
            }));
        }
        public IViewComponentResult Invoke()
        {
            var nopthetrongngay = _noptheRepository.NopCards().
                                  Where(x => x.NgayNopCard.Subtract(DateTime.Now.Date).Days == 0 && x.ViewStatus == false && x.Status == false).ToList();
            var data = from napthe in nopthetrongngay
                       join user in _userManager.Users on napthe.UserId equals user.Id
                       join card in _cardRepository.Cards() on napthe.cardId equals card.Id
                       join mg in _menhgiaRepository.MenhGias() on napthe.menhgiaId equals mg.Id
                       select new NopTheViewModels
            {
                id       = napthe.Id,
                loaithe  = card.Name,
                menhgia  = mg.Price,
                ngaynop  = String.Format("{0:d/M/yyyy h:mm:ss}", napthe.NgayNopCard),
                userName = user.UserName,
                avatar   = user.UrlAvatar,
                soluong  = napthe.warenty
            };

            return(View(data));
        }
        public IActionResult LichSuNapThe(string userId, int page, int pageSize = 5)
        {
            var totalRows = 0;
            var napthes   = _NopCardRepository.NopCards();
            var menhgias  = _menhgiaRepository.MenhGias();
            var cards     = _cardRepository.Cards();
            var data      = from nc in napthes
                            join mg in menhgias on nc.menhgiaId equals mg.Id
                            join c in cards on nc.cardId equals c.Id
                            where nc.UserId == userId
                            orderby nc.NgayNopCard descending
                            select new NopCardViewModels
            {
                Id            = nc.Id,
                LoaiThe       = c.Name,
                MenhGia       = mg.Price,
                GiaChietKhau  = mg.unit_Price,
                NgayNopThe    = String.Format("{0:d/M/yyyy h:mm:ss}", nc.NgayNopCard),
                SoDienThoai   = nc.Phone,
                requiredLabel = nc.Required == "0" ? "không" : "nhanh",
                SoLuong       = nc.warenty,
                TrangThai     = nc.Status,
                Notes         = nc.NoiDung
            };

            totalRows = data.Count();
            var models = data.Skip(pageSize * (page - 1)).Take(pageSize).ToList();

            return(Json(new
            {
                data = models,
                total = totalRows,
                page = page,
                status = true
            }));
        }