public IPembelianModel GetByNoNota(object noNota) { var dataAccessStatus = new DataAccessStatus(); using (var context = new DbContext()) { var queryStr = "SELECT * FROM pembelian WHERE no_nota = @noNota"; var model = context.Conn.Query <PembelianModel>(queryStr, new { noNota }).FirstOrDefault(); if (model != null) { var supplierModel = context.Conn.Get <SupplierModel>(model.supplier_id); if (supplierModel != null) { model.Supplier = supplierModel; } var pdRepo = new PembelianDetailRepository(context); model.PembelianDetails = pdRepo.GetAll(model); } return(model); } }
private IEnumerable <PembelianModel> MappingObjects(DbContext context, IEnumerable <PembelianModel> listObjs) { if (listObjs != null && listObjs.ToList().Count > 0) { listObjs = listObjs.Map(p => p.Supplier = context.Conn.Get <SupplierModel>(p.supplier_id)); var pdRepo = new PembelianDetailRepository(context); foreach (var p in listObjs) { p.PembelianDetails = pdRepo.GetAll(p); } } return(listObjs); }