public TransferObj <MdBoHangVm.Dto> GetDetails(string id) { var result = new TransferObj <MdBoHangVm.Dto>(); var temp = new MdBoHangVm.Dto(); var boHang = _service.FindById(id); var chitietBoHang = _service.UnitOfWork.Repository <MdBoHangChiTiet>().DbSet; if (boHang != null) { temp = Mapper.Map <MdBoHang, MdBoHangVm.Dto>(boHang); var chiTietBoHang = chitietBoHang.Where(x => x.MaBoHang == boHang.MaBoHang).ToList(); //foreach (var x in chitietBoHang) //{ //} temp.DataDetails = Mapper.Map <List <MdBoHangChiTiet>, List <MdBoHangVm.DtoDetail> >(chiTietBoHang); result.Data = temp; result.Status = true; } return(result); }
public TransferObj <MdBoHangVm.Dto> GetDetails(string id) { var unitCode = _service.GetCurrentUnitCode(); var result = new TransferObj <MdBoHangVm.Dto>(); var temp = new MdBoHangVm.Dto(); var boHang = _service.FindById(id); var chitietBoHang = _service.UnitOfWork.Repository <MdBoHangChiTiet>().DbSet; if (boHang != null) { temp = Mapper.Map <MdBoHang, MdBoHangVm.Dto>(boHang); var chiTietBoHang = chitietBoHang.Where(x => x.MaBoHang == boHang.MaBoHang).ToList(); temp.DataDetails = Mapper.Map <List <MdBoHangChiTiet>, List <MdBoHangVm.DtoDetail> >(chiTietBoHang); if (temp.DataDetails.Count > 0) { var merchandisePriceService = _service.UnitOfWork.Repository <MdMerchandisePrice>(); foreach (var a in temp.DataDetails) { MdMerchandisePrice merchandisePrice = merchandisePriceService.DbSet.FirstOrDefault(x => x.MaVatTu.Equals(a.MaHang) && x.MaDonVi.Equals(unitCode)); if (merchandisePrice != null) { a.GiaMua = merchandisePrice.GiaMua; a.GiaMuaVat = merchandisePrice.GiaMuaVat; a.GiaBanLe = merchandisePrice.GiaBanLe; a.GiaBanBuon = merchandisePrice.GiaBanBuon; a.GiaBanLeVat = merchandisePrice.GiaBanLeVat; a.GiaBanBuonVat = merchandisePrice.GiaBanBuonVat; a.DonGia = merchandisePrice.GiaBanLeVat; } } } result.Data = temp; result.Status = true; } return(result); }