public async Task<string> InserirAsync(Material oMaterial) { try { return await Material.InserirAsync(oMaterial); } catch (Exception ex) { return ex.Message; } }
public async static Task<string> InserirAsync(Material oMaterial) { using (var oDB = new CAPEntities()) { try { oDB.Material.Add(oMaterial); await oDB.SaveChangesAsync(); return null; } catch (Exception ex) { return ex.ToString(); } } }
public async static Task<string> AlterarAsync(Material oMaterial) { using (var oDB = new CAPEntities()) { try { oDB.Material.Attach(oMaterial); oDB.Entry(oMaterial).State = EntityState.Modified; await oDB.SaveChangesAsync(); return null; } catch (Exception ex) { return ex.ToString(); } } }