/// <summary> /// Commit all changes in the repository /// </summary> public void SaveRange(IEnumerable <Speaker> entityList) { using (var context = new CodemashContext()) { SaveChanges(context, entityList); SaveRemovals(context, entityList); context.SaveChanges(); } }
/// <summary> /// Commit all changes in the repository /// </summary> public void SaveRange(IEnumerable<Speaker> entityList) { using (var context = new CodemashContext()) { SaveChanges(context, entityList); SaveRemovals(context, entityList); context.SaveChanges(); } }
/// <summary> /// Update the client identified by the channel Uri to the latest changeset /// </summary> /// <param name="channelUri">The channel URI used to identify a client</param> /// <param name="changesetLoaded">The changeset of the most recently loaded changeset</param> public void UpdateClientChangeset(string channelUri, int changesetLoaded) { using (var context = new CodemashContext()) { var client = context.Clients.FirstOrDefault(c => c.ChannelUri == channelUri); if (client != null) { client.CurrentChangeSet = changesetLoaded; context.SaveChanges(); } } }
/// <summary> /// Update the client identified by the channel Uri to the latest changeset /// </summary> /// <param name="channelUri">The channel URI used to identify a client</param> /// <param name="changesetLoaded">The changeset of the most recently loaded changeset</param> public void UpdateClientChangeset(string channelUri, int changesetLoaded) { using (var context = new CodemashContext()) { var client = context.Clients.FirstOrDefault(c => c.ChannelUri == channelUri); if (client != null) { client.CurrentChangeSet = changesetLoaded; context.SaveChanges(); } } }
/// <summary> /// Register a client for push notifications /// </summary> /// <param name="client"></param> public void RegisterClient(Client client) { using (var context = new CodemashContext()) { // determine the latest changeset number var changeset = 0; if (context.Changes.Any()) changeset = context.Changes.Max(c => c.Changeset); client.CurrentChangeSet = changeset; context.Clients.Add(client); context.SaveChanges(); } }
/// <summary> /// Register a client for push notifications /// </summary> /// <param name="client"></param> public void RegisterClient(Client client) { using (var context = new CodemashContext()) { // determine the latest changeset number var changeset = 0; if (context.Changes.Any()) { changeset = context.Changes.Max(c => c.Changeset); } client.CurrentChangeSet = changeset; context.Clients.Add(client); context.SaveChanges(); } }
/// <summary> /// Apply the changes (add/remove) from a Master Session List /// </summary> /// <param name="masterSessionList">The session data from the master source</param> /// <remarks>The incoming range is expected to be the full measure of session data</remarks> public void SaveRange(IEnumerable<Session> masterSessionList) { var masterList = masterSessionList.ToList(); using (var context = new CodemashContext()) { // get all available speakers var availabelSpeakers = context.Speakers.Select(sp => sp.SpeakerId).ToArray(); // filter the master list so that sessions which do not have a valid speaker are not included masterList = masterList.Where(s => availabelSpeakers.Contains(s.SpeakerId)).ToList(); SaveChanges(context, masterList); SaveRemovals(context, masterList); context.SaveChanges(); } }
/// <summary> /// Apply the changes (add/remove) from a Master Session List /// </summary> /// <param name="masterSessionList">The session data from the master source</param> /// <remarks>The incoming range is expected to be the full measure of session data</remarks> public void SaveRange(IEnumerable <Session> masterSessionList) { var masterList = masterSessionList.ToList(); using (var context = new CodemashContext()) { // get all available speakers var availabelSpeakers = context.Speakers.Select(sp => sp.SpeakerId).ToArray(); // filter the master list so that sessions which do not have a valid speaker are not included masterList = masterList.Where(s => availabelSpeakers.Contains(s.SpeakerId)).ToList(); SaveChanges(context, masterList); SaveRemovals(context, masterList); context.SaveChanges(); } }
/// <summary> /// Commit all changes in the repository /// </summary> public void SaveRange(IEnumerable <Change> entityList) { // establish the changeset number int changeset = 1; using (var context = new CodemashContext()) { if (context.Changes.Any()) { changeset = context.Changes.Max(c => c.Changeset) + 1; } foreach (var change in entityList) { change.Changeset = changeset; context.Changes.Add(change); } context.SaveChanges(); } }