public static HostSet Get(this IDocumentSession session, HostSet set) { var result = from qSet in session.Query<HostSet>() where qSet.Id == set.Id select qSet; return result.FirstOrDefault(); }
/// <summary> /// Creates the set. /// </summary> /// <param name="set">The set.</param> /// <returns></returns> public HostSet CreateSet(HostSet set) { using (var session = this.store.OpenSession()) { session.Store(set); session.SaveChanges(); } return set; }
/// <summary> /// Adds the host to set. /// </summary> /// <param name="host">The host.</param> /// <param name="set">The set.</param> public void AddHostToSet(Host host, HostSet set) { using (var session = this.store.OpenSession()) { var dalSet = session.Get(set); dalSet.Hosts.Add(host); session.SaveChanges(); } }
/// <summary> /// Deactivates the set. /// </summary> /// <param name="set">The set.</param> /// <returns></returns> public HostSet DeactivateSet(HostSet set) { return ToggleSetActivation(set, true); }
protected HostSet ToggleSetActivation(HostSet set, bool value) { using (var session = this.store.OpenSession()) { var dalSet = session.Get(set); dalSet.Active = value; session.SaveChanges(); } return set; }
/// <summary> /// Removes the host from set. /// </summary> /// <param name="host">The host.</param> /// <param name="set">The set.</param> public void RemoveHostFromSet(Host host, HostSet set) { using (var session = this.store.OpenSession()) { var dalSet = session.Get(set); dalSet.Hosts.Remove(host); session.SaveChanges(); } }
/// <summary> /// Deletes the set. /// </summary> /// <param name="set">The set.</param> /// <returns></returns> public HostSet DeleteSet(HostSet set) { using (var session = this.store.OpenSession()) { var result = session.Get(set); if (result != null) { session.Delete(result); session.SaveChanges(); } } return set; }