public async Task <KhoPhieuXuatChiTiet> UpdatePartial(KhoPhieuXuatChiTiet obj, params string[] field) { var a = await WithConnection(async c => { var objCheck = await c.GetAsync(obj); if (objCheck == null) { throw new Exception(string.Format("Update id {0} not exist", obj.PhieuXuatChiTietId.ToString())); } var list = field.ToList(); var partialUpdateMapping = OrmConfiguration .GetDefaultEntityMapping <KhoPhieuXuatChiTiet>() .Clone() .UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = true, list.ToArray()); var result = await c.UpdateAsync(obj, statement => statement.WithEntityMappingOverride(partialUpdateMapping)); if (result != true) { throw new Exception("Update Fail"); } return(obj); }); return(a); }
public async Task <KhoPhieuXuatChiTiet> Insert(KhoPhieuXuatChiTiet obj) { obj.XoaYN = "N"; return(await WithConnection(async c => { await c.InsertAsync(obj); if (obj.PhieuXuatChiTietId == 0) { throw new Exception("Insert Fail"); } return obj; })); }
public async Task <KhoPhieuXuatChiTiet> Update(KhoPhieuXuatChiTiet obj) { return(await WithConnection(async c => { var objCheck = await c.GetAsync(obj); if (objCheck == null) { throw new Exception(string.Format("Update id {0} not exist", obj.PhieuXuatChiTietId.ToString())); } var result = await c.UpdateAsync(obj); if (result != true) { throw new Exception("Update Fail"); } return obj; })); }