public async Task <IHttpActionResult> GetDataDetailsGDQuay(JObject jsonData) { var result = new TransferObj <NvGiaoDichQuayVm.Dto>(); var data = new NvGiaoDichQuayVm.Dto(); var MaGiaoDich = (string)jsonData.SelectToken("data"); if (MaGiaoDich != null) { var giaoDich = _serviceGdQuay.Repository.DbSet.FirstOrDefault(x => x.MaGiaoDichQuayPK == MaGiaoDich); if (giaoDich != null) { data = Mapper.Map <NvGiaoDichQuay, NvGiaoDichQuayVm.Dto>(giaoDich); var chiTietPhieu = _serviceGdQuay.UnitOfWork.Repository <NvGiaoDichQuayChiTiet>().DbSet.Where(x => x.MaGDQuayPK == giaoDich.MaGiaoDichQuayPK).ToList(); data.DataDetails = Mapper.Map <List <NvGiaoDichQuayChiTiet>, List <NvGiaoDichQuayVm.DtoDetail> >(chiTietPhieu).ToList(); result.Data = data; result.Status = true; result.Message = "Tìm thấy giao dịch"; return(Ok(result)); } } else { result.Data = null; result.Status = false; result.Message = "Không tìm thấy mã giao dịch"; } return(Ok(result)); }
public async Task <IHttpActionResult> GetGiaoDichByVoucher(string maGiamGia) { var temp = new NvGiaoDichQuayVm.Dto(); var _parentUnitCode = _service.GetParentUnitCode(); var result = new TransferObj <NvGiaoDichQuayVm.Dto>(); NvGiaoDichQuayVm.DataDto instance = new NvGiaoDichQuayVm.DataDto(); var phieu = _serviceGdq.Repository.DbSet.FirstOrDefault(x => x.MaVoucher == maGiamGia && x.UnitCode.StartsWith(_parentUnitCode)); if (phieu != null) { instance = Mapper.Map <NvGiaoDichQuay, NvGiaoDichQuayVm.DataDto>(phieu); temp = Mapper.Map <NvGiaoDichQuay, NvGiaoDichQuayVm.Dto>(phieu); var chiTietPhieu = _service.UnitOfWork.Repository <NvGiaoDichQuayChiTiet>() .DbSet.Where(x => x.MaGDQuayPK == phieu.MaGiaoDichQuayPK) .ToList(); temp.DataDetails = Mapper.Map <List <NvGiaoDichQuayChiTiet>, List <NvGiaoDichQuayVm.DtoDetail> >(chiTietPhieu).ToList(); if (!string.IsNullOrEmpty(instance.MaKhachHang)) { var customer = _service.UnitOfWork.Repository <MdCustomer>().DbSet.FirstOrDefault(x => x.MaKH == instance.MaKhachHang && x.UnitCode.StartsWith(_parentUnitCode)); if (customer != null) { temp.DiaChi = customer.DiaChi; temp.DienThoai = customer.DienThoai; temp.NgaySinh = customer.NgaySinh; temp.NgayDacBiet = customer.NgayDacBiet; temp.Email = customer.Email; temp.TenKhachHang = customer.TenKH; temp.MaThe = customer.MaThe; temp.QuenThe = customer.QuenThe; temp.TongTien = customer.TongTien; temp.TienNguyenGia = customer.TienNguyenGia; temp.TienSale = customer.TienSale; temp.HangKhachHang = customer.HangKhachHang; } } result.Data = temp; result.Status = true; return(Ok(result)); } else { result.Data = null; result.Message = "Không tìm thấy bản ghi"; result.Status = false; } return(Ok(result)); }
public async Task <IHttpActionResult> PostDetails(NvGiaoDichQuayVm.Dto data) { TransferObj <NvGiaoDichQuayVm.Dto> result = new TransferObj <NvGiaoDichQuayVm.Dto>(); NvGiaoDichQuayVm.Dto temp = new NvGiaoDichQuayVm.Dto(); NvGiaoDichQuay phieu = _service.Repository.DbSet.FirstOrDefault(x => x.MaGiaoDichQuayPK == data.MaGiaoDichQuayPK); if (phieu != null) { temp = Mapper.Map <NvGiaoDichQuay, NvGiaoDichQuayVm.Dto>(phieu); List <NvGiaoDichQuayChiTiet> chiTietPhieu = _service.UnitOfWork.Repository <NvGiaoDichQuayChiTiet>().DbSet.Where(x => x.MaGDQuayPK == phieu.MaGiaoDichQuayPK).ToList(); temp.DataDetails = Mapper.Map <List <NvGiaoDichQuayChiTiet>, List <NvGiaoDichQuayVm.DtoDetail> >(chiTietPhieu).ToList(); string unitcode = _service.GetCurrentUnitCode(); result.Data = temp; result.Status = true; return(Ok(result)); } return(NotFound()); }
public async Task <IHttpActionResult> GetDataReport(string id) { TransferObj <NvGiaoDichQuayVm.Dto> result = new TransferObj <NvGiaoDichQuayVm.Dto>(); NvGiaoDichQuayVm.Dto temp = new NvGiaoDichQuayVm.Dto(); string _unitCode = _service.GetCurrentUnitCode(); string maGiaoDichQuay = id; NvGiaoDichQuay phieu = _service.Repository.DbSet.FirstOrDefault(x => x.MaGiaoDich == maGiaoDichQuay && x.MaDonVi == _unitCode); if (phieu != null) { temp = Mapper.Map <NvGiaoDichQuay, NvGiaoDichQuayVm.Dto>(phieu); List <NvGiaoDichQuayChiTiet> chiTietPhieu = _service.UnitOfWork.Repository <NvGiaoDichQuayChiTiet>() .DbSet.Where(x => x.MaGDQuayPK == phieu.MaGiaoDichQuayPK) .ToList(); temp.DataDetails = Mapper.Map <List <NvGiaoDichQuayChiTiet>, List <NvGiaoDichQuayVm.DtoDetail> >(chiTietPhieu).ToList(); temp.DataDetails.ForEach(x => { var obj = _service.UnitOfWork.Repository <MdMerchandise>().DbSet.FirstOrDefault(y => y.MaVatTu == x.MaVatTu && y.UnitCode == temp.MaDonVi); if (obj != null) { x.TyLeVatVao = obj.TyLeVatVao.ToString(); } }); string unitcode = _service.GetCurrentUnitCode(); result.Data = temp; result.Status = true; return(Ok(result)); } else { result.Data = new NvGiaoDichQuayVm.Dto(); result.Message = "Không tìm thấy !"; result.Status = false; } return(Ok(result)); }