public static void SaveKidsUser(KidsUser user, object p, Action<Object> a) { using (var ctx = new BMIKidsEntities(ConnectionString)) { try { if (user.ChangeTracker.State == ObjectState.Unchanged) user.MarkAsModified(); if (user.ChangeTracker.State == ObjectState.Added) { user.CreateDateTime = DateTime.Now; user.LastUpdateDateTime = null; } else user.LastUpdateDateTime = DateTime.Now; ctx.KidsUsers.ApplyChanges(user); ctx.SaveChanges(); user.AcceptChanges(); if (a != null) a(p); } catch (Exception ex) { LogUtility.WriteEntryEventLog("SaveSystemUser_DataProvider_UpdateTransaction", ex, EventLogEntryType.Information); if (ex.InnerException != null) throw ex.InnerException; throw; } } }
protected void btnSave_Click(object sender, EventArgs e) { CurrentKidsUser = ucEditableUserProfile.GetUserInfo(CurrentKidsUser); if (PageState == Action.Add) CurrentKidsUser.MarkAsAdded(); else if (PageState == Action.Update) CurrentKidsUser.MarkAsModified(); KidsUser_DataProvider.SaveKidsUser(CurrentKidsUser, this, KidsSecureFormBaseClass.RefreshOnlineKidsUserInfo); pnlDetails.Visible = false; BindGrid(); }