public List <IQueryFilter> GetFilters() { var result = new List <IQueryFilter>(); var refObj = new MdSupplier(); if (!string.IsNullOrEmpty(this.MaNCC)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaNCC), Value = this.MaNCC, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.TenNCC)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.TenNCC), Value = this.TenNCC, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.DiaChi)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.DiaChi), Value = this.DiaChi, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.MaSoThue)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaSoThue), Value = this.MaSoThue, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.DienThoai)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.DienThoai), Value = this.DienThoai, Method = FilterMethod.Like }); } return(result); }
public async Task <IHttpActionResult> GetDetails(string id) { TransferObj <NvChuongTrinhKhuyenMaiVm.Dto> result = new TransferObj <NvChuongTrinhKhuyenMaiVm.Dto>(); NvChuongTrinhKhuyenMaiVm.Dto temp = new NvChuongTrinhKhuyenMaiVm.Dto(); string _parentUnitCode = _service.GetParentUnitCode(); NvChuongTrinhKhuyenMai phieu = _service.FindById(id); if (phieu != null) { temp = Mapper.Map <NvChuongTrinhKhuyenMai, NvChuongTrinhKhuyenMaiVm.Dto>(phieu); List <NvChuongTrinhKhuyenMaiChiTiet> tb_ChuongTrinhKhuyenMaiChiTiet = _service.UnitOfWork.Repository <NvChuongTrinhKhuyenMaiChiTiet>().DbSet.ToList(); List <NvChuongTrinhKhuyenMaiChiTiet> chiTietChuongTrinhKhuyenMai = tb_ChuongTrinhKhuyenMaiChiTiet.Where(x => x.MaChuongTrinh == phieu.MaChuongTrinh).ToList(); temp.DataDetails = Mapper.Map <List <NvChuongTrinhKhuyenMaiChiTiet>, List <NvChuongTrinhKhuyenMaiVm.DtoDetail> >(chiTietChuongTrinhKhuyenMai); foreach (NvChuongTrinhKhuyenMaiVm.DtoDetail tmp in temp.DataDetails) { switch (tmp.LoaiChuongTrinh) { case TypePromotion.ByItemGetItem: MdMerchandise hangHoa = _service.UnitOfWork.Repository <MdMerchandise>().DbSet.FirstOrDefault(x => x.MaVatTu == tmp.MaHang); tmp.TenHang = (hangHoa != null ? hangHoa.TenHang : ""); break; case TypePromotion.MerchandiseType: MdMerchandiseType loaiHangHoa = _service.UnitOfWork.Repository <MdMerchandiseType>().DbSet.FirstOrDefault(x => x.MaLoaiVatTu == tmp.MaHang); tmp.TenHang = (loaiHangHoa != null ? loaiHangHoa.TenLoaiVatTu : ""); break; case TypePromotion.MerchandiseGroup: MdNhomVatTu nhomHangHoa = _service.UnitOfWork.Repository <MdNhomVatTu>().DbSet.FirstOrDefault(x => x.MaNhom == tmp.MaHang); tmp.TenHang = (nhomHangHoa != null ? nhomHangHoa.TenNhom : ""); break; case TypePromotion.Sponsor: MdSupplier nhaCungCap = _service.UnitOfWork.Repository <MdSupplier>().DbSet.FirstOrDefault(x => x.MaNCC == tmp.MaHang && x.UnitCode.StartsWith(_parentUnitCode)); tmp.TenHang = (nhaCungCap != null ? nhaCungCap.TenNCC : ""); break; default: break; } } result.Data = temp; result.Status = true; return(Ok(result)); } return(NotFound()); }