public void SaveOldRow(TblJournalSettingViewModel oldRow) { if (oldRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(oldRow, new ValidationContext(oldRow, null, null), valiationCollection, true); if (isvalid) { var save = oldRow.Iserial == 0; if (AllowUpdate != true && !save) { MessageBox.Show(strings.AllowUpdateMsg); return; } var saveRow = new TblJournalSetting(); saveRow.InjectFrom(oldRow); if (!Loading) { Loading = true; Glclient.UpdateOrInsertTblJournalSettingsAsync(saveRow, save, MainRowList.IndexOf(oldRow), LoggedUserInfo.DatabasEname); } } } }
private TblJournalSetting UpdateOrInsertTblJournalSettings(TblJournalSetting newRow, bool save, int index, out int outindex, string company) { outindex = index; using (var entity = new ccnewEntities(GetSqlConnectionString(company))) { if (save) { entity.TblJournalSettings.AddObject(newRow); } else { var oldRow = (from e in entity.TblJournalSettings where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, entity); } } entity.SaveChanges(); return(newRow); } }