public async Task <bool> UpdateData(string id, Parameterstbl obj) { try { if (id != obj.ParametersNo.ToString()) { return(false); } using (var context = new smlpobDB()) { context.Parameterstbl.Attach(obj); context.Entry(obj).Property(x => x.String0).IsModified = true; context.Entry(obj).Property(x => x.String1).IsModified = true; context.Entry(obj).Property(x => x.String2).IsModified = true; context.Entry(obj).Property(x => x.String3).IsModified = true; context.Entry(obj).Property(x => x.String4).IsModified = true; context.Entry(obj).Property(x => x.String5).IsModified = true; context.Entry(obj).Property(x => x.String6).IsModified = true; context.Entry(obj).Property(x => x.String7).IsModified = true; context.Entry(obj).Property(x => x.String8).IsModified = true; context.Entry(obj).Property(x => x.String9).IsModified = true; context.Entry(obj).Property(x => x.ModBy).IsModified = true; context.Entry(obj).Property(x => x.ModDate).IsModified = true; await context.SaveChangesAsync(); return(true); } } catch (Exception ex) { LogHelpers.source = this.GetType().Name; LogHelpers.message = ex.Message; LogHelpers.user = ""; LogHelpers.WriteLog(); } return(false); }
public async Task <bool> AddData(Parameterstbl obj) { try { using (var context = new smlpobDB()) { context.Parameterstbl.Add(obj); await context.SaveChangesAsync(); return(true); } } catch (Exception ex) { LogHelpers.source = this.GetType().Name; LogHelpers.message = ex.Message; LogHelpers.user = ""; LogHelpers.WriteLog(); } return(false); }