public override async Task <PagedResultDto <CongViecDto> > GetAll(GetAllCongViecInput input) { input.Keyword = GlobalFunction.RegexFormat(input.Keyword); var query = from CongViec in _congViecRepository.GetAll() .WhereIf(!string.IsNullOrEmpty(input.Keyword), w => w.KhachHangName.Contains(input.Keyword) || w.SoDienThoai.Contains(input.Keyword)) .WhereIf(input.TramDichVuId.HasValue, w => w.TramDichVuId == input.TramDichVuId || (input.TramDichVuId == 0 && w.TramDichVuId == null)) .WhereIf(input.TrangThaiId.HasValue, w => w.TrangThaiId == input.TrangThaiId) join DichVu in _dichVuRepository.GetAll() on CongViec.DichVuId equals DichVu.Id into J1 from DichVu in J1.DefaultIfEmpty() join TramDichVu in _tramDichVuRepository.GetAll() on CongViec.TramDichVuId equals TramDichVu.Id into J5 from TramDichVu in J5.DefaultIfEmpty() join NhanVien in _nhanVienRepository.GetAll() on CongViec.NhanVienId equals NhanVien.Id into J2 from NhanVien in J2.DefaultIfEmpty() join TinhThanh in _tinhThanhRepository.GetAll() on CongViec.DiaChiTinhThanhId equals TinhThanh.Id into J3 from TinhThanh in J3.DefaultIfEmpty() join QuanHuyen in _quanHuyenRepository.GetAll() on CongViec.DiaChiQuanHuyenId equals QuanHuyen.Id into J4 from QuanHuyen in J4.DefaultIfEmpty() select new { CongViec, DichVuName = DichVu.Name, TramDichVuName = TramDichVu.Name, NhanVienName = NhanVien.Name, TinhThanhName = TinhThanh.Name, QuanHuyenName = QuanHuyen.Name }; var TotalCount = await query.CountAsync(); var PagedCongViec = await query.OrderBy(o => o.CongViec.NgayGioHen).PageBy(input).ToListAsync(); var CongViecs = new List <CongViecDto>(); foreach (var item in PagedCongViec) { var CongViec = ObjectMapper.Map <CongViecDto>(item.CongViec); CongViec.DichVuName = item.DichVuName; CongViec.TramDichVuName = item.TramDichVuName; CongViec.NhanVienName = item.NhanVienName; CongViec.DiaChi += string.IsNullOrWhiteSpace(item.QuanHuyenName) ? "" : ", " + item.QuanHuyenName; CongViec.DiaChi += string.IsNullOrWhiteSpace(item.TinhThanhName) ? "" : ", " + item.TinhThanhName; CongViec.TrangThaiName = item.CongViec.TrangThaiId >= 0 && GlobalModel.TrangThaiCongViec.ContainsKey((int)item.CongViec.TrangThaiId) ? GlobalModel.TrangThaiCongViec[(int)item.CongViec.TrangThaiId] : ""; CongViecs.Add(CongViec); } return(new PagedResultDto <CongViecDto> { TotalCount = TotalCount, Items = CongViecs }); }
public async Task <PagedResultDto <GetTramDichVuForView> > GetAllNew(GetAllTramDichVuInput input) { input.Keyword = GlobalFunction.RegexFormat(input.Keyword); var query = from TramDV in _tramDichVuRepository.GetAll() .WhereIf(!input.Keyword.IsNullOrWhiteSpace(), w => w.Name.Contains(input.Keyword)) join TramTruong in _userRepository.GetAll() on TramDV.TramTruongId equals TramTruong.Id into J1 from TramTruong in J1.DefaultIfEmpty() join DmQuanHuyen in _danhMucQuanHuyenRepository.GetAll() on TramDV.DiaChiQuanHuyenId equals DmQuanHuyen.Id into J2 from DmQuanHuyen in J2.DefaultIfEmpty() join DmTinhThanh in _danhMucTinhThanhRepository.GetAll() on TramDV.DiaChiTinhThanhId equals DmTinhThanh.Id into J3 from DmTinhThanh in J3.DefaultIfEmpty() select new { TramDV, TramTruongName = TramTruong != null ? TramTruong.UserName : "", QuanHuyenName = DmQuanHuyen != null ? ", " + DmQuanHuyen.Name : "", TinhThanhName = DmTinhThanh != null ? ", " + DmTinhThanh.Name : "", }; var TotalCount = await query.CountAsync(); var PagedDanhMucTram = await query.OrderBy(o => o.TramDV.Name).PageBy(input).ToListAsync(); var PagedDanhMucTramForView = PagedDanhMucTram.Select(s => new GetTramDichVuForView { TramDichVu = ObjectMapper.Map <TramDichVuDto>(s.TramDV), TramTruongName = s.TramTruongName, DiaChi = s.TramDV.DiaChi + s.QuanHuyenName + s.TinhThanhName, }).ToList(); return(new PagedResultDto <GetTramDichVuForView> ( TotalCount, PagedDanhMucTramForView )); }
public async Task <PagedResultDto <KhachHangDto> > GetAll(GetAllKhachHangInput input) { var query = from KhachHang in _khachHangRepository.GetAll() .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), w => w.Name.Contains(input.Filter) || w.PhoneNumber.Contains(input.Filter)) join TaiKhoan in _userRepository.GetAll() on KhachHang.UserId equals TaiKhoan.Id into J1 from TaiKhoan in J1.DefaultIfEmpty() join TinhThanh in _tinhThanhRepository.GetAll() on KhachHang.ProvinceId equals TinhThanh.Id into J3 from TinhThanh in J3.DefaultIfEmpty() join QuanHuyen in _quanHuyenRepository.GetAll() on KhachHang.DistrictId equals QuanHuyen.Id into J4 from QuanHuyen in J4.DefaultIfEmpty() select new { KhachHang, TaiKhoan.UserName, IsActive = TaiKhoan != null?TaiKhoan.IsActive.ToString() : "", TaiKhoan.EmailConfirmationCode, TinhThanhName = TinhThanh.Name, QuanHuyenName = QuanHuyen.Name }; var TotalCount = await query.CountAsync(); var PagedKhachHang = await query.OrderBy(o => o.KhachHang.Name).PageBy(input).ToListAsync(); var KhachHangs = new List <KhachHangDto>(); foreach (var item in PagedKhachHang) { var KhachHang = ObjectMapper.Map <KhachHangDto>(item.KhachHang); KhachHang.UserName = item.UserName; KhachHang.AddressFull = KhachHang.Address + (string.IsNullOrWhiteSpace(item.QuanHuyenName) ? "" : ", " + item.QuanHuyenName); KhachHang.AddressFull += string.IsNullOrWhiteSpace(item.TinhThanhName) ? "" : ", " + item.TinhThanhName; if (!string.IsNullOrWhiteSpace(item.IsActive)) { // Không active và không có email confirm code // => Đã active, đang bị lock if (item.IsActive == "False" && string.IsNullOrWhiteSpace(item.EmailConfirmationCode)) { KhachHang.IsActived = true; KhachHang.IsLocked = true; KhachHang.Status = "Đã khóa"; } // Không active và có email confirm code // => Đang chờ active, không bị lock else if (item.IsActive == "False" && !string.IsNullOrWhiteSpace(item.EmailConfirmationCode)) { KhachHang.IsActived = false; KhachHang.IsLocked = false; KhachHang.Status = "Chưa kích hoạt"; } // Có active, không quan tâm email confirm code // => Đang active, không bị lock else { KhachHang.IsActived = true; KhachHang.IsLocked = false; KhachHang.Status = "Đang hoạt động"; } } else { KhachHang.Status = "-"; } KhachHangs.Add(KhachHang); } return(new PagedResultDto <KhachHangDto>( TotalCount, KhachHangs )); }
public async Task <List <CongViecDto> > GetAll(DanhSachCongViecInput input) { var UserCache = await _globalCache.GetUserCache((long)AbpSession.UserId); if (UserCache.Id == 0) { return(new List <CongViecDto>()); } var query = from CongViec in _congViecRepository.GetAll() .WhereIf(input.TrangThaiIds.Length > 0, w => input.TrangThaiIds.ToList().Contains(w.TrangThaiId)) .WhereIf(UserCache.IsCustomer, w => w.KhachHangId == UserCache.CustomerId) .WhereIf(!UserCache.IsCustomer, w => w.NhanVienId == AbpSession.UserId) join DichVu in _dichVuRepository.GetAll() on CongViec.DichVuId equals DichVu.Id into J1 from DichVu in J1.DefaultIfEmpty() join NhomDichVu in _nhomDichVuRepository.GetAll() on DichVu.NhomDichVuId equals NhomDichVu.Id into J6 from NhomDichVu in J6.DefaultIfEmpty() join TramDichVu in _tramDichVuRepository.GetAll() on CongViec.TramDichVuId equals TramDichVu.Id into J5 from TramDichVu in J5.DefaultIfEmpty() join NhanVien in _nhanVienRepository.GetAll() on CongViec.NhanVienId equals NhanVien.Id into J2 from NhanVien in J2.DefaultIfEmpty() join TinhThanh in _tinhThanhRepository.GetAll() on CongViec.DiaChiTinhThanhId equals TinhThanh.Id into J3 from TinhThanh in J3.DefaultIfEmpty() join QuanHuyen in _quanHuyenRepository.GetAll() on CongViec.DiaChiQuanHuyenId equals QuanHuyen.Id into J4 from QuanHuyen in J4.DefaultIfEmpty() select new { CongViec, NhomDichVuId = NhomDichVu != null ? NhomDichVu.Id : 0, NhomDichVuName = NhomDichVu.Name, DichVuName = DichVu.Name, TramDichVuName = TramDichVu.Name, NhanVienName = NhanVien.Name, NhanVienPhone = NhanVien.PhoneNumber, TinhThanhName = TinhThanh.Name, QuanHuyenName = QuanHuyen.Name }; var CongViecs = await query.OrderBy(o => o.CongViec.NgayGioHen).Skip((input.Page - 1) * 10).Take(10).ToListAsync(); var CongViecDtos = new List <CongViecDto>(); foreach (var item in CongViecs) { var CongViec = ObjectMapper.Map <CongViecDto>(item.CongViec); if (item.NhomDichVuId > 0) { CongViec.NhomDichVuId = item.NhomDichVuId; } CongViec.NhomDichVuName = item.NhomDichVuName; CongViec.DichVuName = item.DichVuName; CongViec.TramDichVuName = item.TramDichVuName; CongViec.NhanVienName = item.NhanVienName; CongViec.NhanVienPhone = item.NhanVienPhone; CongViec.DiaChi += string.IsNullOrWhiteSpace(item.QuanHuyenName) ? "" : ", " + item.QuanHuyenName; CongViec.DiaChi += string.IsNullOrWhiteSpace(item.TinhThanhName) ? "" : ", " + item.TinhThanhName; CongViec.TrangThaiName = item.CongViec.TrangThaiId >= 0 && GlobalModel.TrangThaiCongViec.ContainsKey((int)item.CongViec.TrangThaiId) ? GlobalModel.TrangThaiCongViec[(int)item.CongViec.TrangThaiId] : ""; CongViec.Image1 = string.IsNullOrWhiteSpace(CongViec.Image1) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.Image1); CongViec.Image2 = string.IsNullOrWhiteSpace(CongViec.Image2) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.Image2); CongViec.Image3 = string.IsNullOrWhiteSpace(CongViec.Image3) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.Image3); CongViec.ImageHoanThanh1 = string.IsNullOrWhiteSpace(CongViec.ImageHoanThanh1) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.ImageHoanThanh1); CongViec.ImageHoanThanh2 = string.IsNullOrWhiteSpace(CongViec.ImageHoanThanh2) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.ImageHoanThanh2); CongViec.ImageHoanThanh3 = string.IsNullOrWhiteSpace(CongViec.ImageHoanThanh3) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.ImageHoanThanh3); CongViec.ImageKhachHang1 = string.IsNullOrWhiteSpace(CongViec.ImageKhachHang1) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.ImageKhachHang1); CongViec.ImageKhachHang2 = string.IsNullOrWhiteSpace(CongViec.ImageKhachHang2) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.ImageKhachHang2); CongViec.ImageKhachHang3 = string.IsNullOrWhiteSpace(CongViec.ImageKhachHang3) ? "" : string.Format("/Common/CongViecs/{0}/{1}", item.CongViec.TimeId, CongViec.ImageKhachHang3); CongViecDtos.Add(CongViec); } return(CongViecDtos); }
public async Task <CongViecDto> Get(long Id) { var UserCache = await _globalCache.GetUserCache((long)AbpSession.UserId); if (UserCache.Id == 0) { throw new UserFriendlyException(L("UserIsNotLogin")); } var query = await(from CongViec in _congViecRepository.GetAll().Where(w => w.Id == Id) .WhereIf(UserCache.IsCustomer, w => w.KhachHangId == UserCache.CustomerId) .WhereIf(!UserCache.IsCustomer, w => w.NhanVienId == AbpSession.UserId) join DichVu in _dichVuRepository.GetAll() on CongViec.DichVuId equals DichVu.Id into J1 from DichVu in J1.DefaultIfEmpty() join NhomDichVu in _nhomDichVuRepository.GetAll() on DichVu.NhomDichVuId equals NhomDichVu.Id into J6 from NhomDichVu in J6.DefaultIfEmpty() join TramDichVu in _tramDichVuRepository.GetAll() on CongViec.TramDichVuId equals TramDichVu.Id into J2 from TramDichVu in J2.DefaultIfEmpty() join NhanVien in _nhanVienRepository.GetAll() on CongViec.NhanVienId equals NhanVien.Id into J3 from NhanVien in J3.DefaultIfEmpty() join TinhThanh in _tinhThanhRepository.GetAll() on CongViec.DiaChiTinhThanhId equals TinhThanh.Id into J4 from TinhThanh in J4.DefaultIfEmpty() join QuanHuyen in _quanHuyenRepository.GetAll() on CongViec.DiaChiQuanHuyenId equals QuanHuyen.Id into J5 from QuanHuyen in J5.DefaultIfEmpty() select new { CongViec, NhomDichVuId = NhomDichVu != null ? NhomDichVu.Id : 0, NhomDichVuName = NhomDichVu.Name, DichVuName = DichVu.Name, TramDichVuName = TramDichVu.Name, NhanVienName = NhanVien.Name, NhanVienPhone = NhanVien.PhoneNumber, TinhThanhName = TinhThanh.Name, QuanHuyenName = QuanHuyen.Name }).FirstOrDefaultAsync(); if (query == null) { throw new UserFriendlyException(L("CongViecIsNotFound")); } var result = ObjectMapper.Map <CongViecDto>(query.CongViec); if (query.NhomDichVuId > 0) { result.NhomDichVuId = query.NhomDichVuId; } result.NhomDichVuName = query.NhomDichVuName; result.DichVuName = query.DichVuName; result.TramDichVuName = query.TramDichVuName; result.NhanVienName = query.NhanVienName; result.NhanVienPhone = query.NhanVienPhone; result.DiaChi += string.IsNullOrWhiteSpace(query.QuanHuyenName) ? "" : ", " + query.QuanHuyenName; result.DiaChi += string.IsNullOrWhiteSpace(query.TinhThanhName) ? "" : ", " + query.TinhThanhName; result.TrangThaiName = query.CongViec.TrangThaiId >= 0 && GlobalModel.TrangThaiCongViec.ContainsKey((int)query.CongViec.TrangThaiId) ? GlobalModel.TrangThaiCongViec[(int)query.CongViec.TrangThaiId] : ""; result.Image1 = string.IsNullOrWhiteSpace(result.Image1) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.Image1); result.Image2 = string.IsNullOrWhiteSpace(result.Image2) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.Image2); result.Image3 = string.IsNullOrWhiteSpace(result.Image3) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.Image3); result.ImageHoanThanh1 = string.IsNullOrWhiteSpace(result.ImageHoanThanh1) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.ImageHoanThanh1); result.ImageHoanThanh2 = string.IsNullOrWhiteSpace(result.ImageHoanThanh2) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.ImageHoanThanh2); result.ImageHoanThanh3 = string.IsNullOrWhiteSpace(result.ImageHoanThanh3) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.ImageHoanThanh3); result.ImageKhachHang1 = string.IsNullOrWhiteSpace(result.ImageKhachHang1) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.ImageKhachHang1); result.ImageKhachHang2 = string.IsNullOrWhiteSpace(result.ImageKhachHang2) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.ImageKhachHang2); result.ImageKhachHang3 = string.IsNullOrWhiteSpace(result.ImageKhachHang3) ? "" : string.Format("/Common/CongViecs/{0}/{1}", query.CongViec.TimeId, result.ImageKhachHang3); // Lấy danh sách hạng mục công việc result.DanhSachHangMuc = await(from CongViecHangMuc in _congViecHangMucRepository.GetAll().Where(w => w.CongViecId == query.CongViec.Id) join DanhMucHangMuc in _hangMucRepository.GetAll() on CongViecHangMuc.HangMucId equals DanhMucHangMuc.Id select new CongViecHangMucDto { HangMucId = DanhMucHangMuc.Id, Name = DanhMucHangMuc.Name, DonViTinh = DanhMucHangMuc.DonViTinh, SoLuong = CongViecHangMuc.SoLuong, DonGia = CongViecHangMuc.DonGia, ThanhTien = CongViecHangMuc.ThanhTien }).ToListAsync(); // Tạm tính thành tiền của công việc bằng cách lấy tổng result.ThanhTien = result.PhuPhi ?? 0 + result.DanhSachHangMuc.Sum(s => s.ThanhTien); return(result); }