Ejemplo n.º 1
0
        public virtual PagedList <HopDong> GetAllHopDong(string mahopdong             = "",
                                                         string tenhopdong            = "",
                                                         int pageIndex                = 0,
                                                         int pageSize                 = int.MaxValue,
                                                         bool showHidden              = false,
                                                         int OwnerID                  = 0,
                                                         ENTrangThaiHopDong trangthai = ENTrangThaiHopDong.TatCa)
        {
            var query = _hopdongRepository.Table;

            if (!showHidden)
            {
                query = query.Where(m => m.TrangThaiID != (int)ENTrangThaiHopDong.Huy);
            }
            if (!String.IsNullOrWhiteSpace(mahopdong))
            {
                query = query.Where(m => m.MaHopDong.Contains(mahopdong));
            }
            if (!String.IsNullOrWhiteSpace(tenhopdong))
            {
                query = query.Where(m => m.TenHopDong.Contains(tenhopdong));
            }
            if (trangthai != ENTrangThaiHopDong.TatCa)
            {
                query = query.Where(m => m.TrangThaiID == (int)trangthai);
            }
            if (OwnerID > 0)
            {
                query = query.Where(m => m.NguoiTaoID == OwnerID);
            }

            query = query.OrderBy(m => m.MaHopDong);

            return(new PagedList <HopDong>(query, pageIndex, pageSize));
        }
Ejemplo n.º 2
0
        public ActionResult ListHopDong(DataSourceRequest command, HopDongListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLHopDong))
            {
                return(AccessDeniedView());
            }
            int nguoitaoid = _workContext.CurrentCustomer.Id;
            ENTrangThaiHopDong trangthaiid = ENTrangThaiHopDong.TatCa;

            if (_permissionService.Authorize(StandardPermissionProvider.CVSaleManager))
            {
                nguoitaoid  = model.NguoiTaoId;
                trangthaiid = (ENTrangThaiHopDong)model.TrangThaiID;
            }


            var hopdongs = _chonveService.GetAllHopDong(model.TimMaHopDong, model.TimTenHopDong,
                                                        command.Page - 1, command.PageSize, false, nguoitaoid, trangthaiid);

            var gridModel = new DataSourceResult
            {
                Data = hopdongs.Select(x =>
                {
                    var m           = x.ToModel();
                    m.TrangThaiText = x.TrangThai.GetLocalizedEnum(_localizationService, _workContext);
                    return(m);
                }),
                Total = hopdongs.TotalCount
            };

            return(Json(gridModel));
        }