private void LoadViewGroup() { if (ItemID.HasValue) { ViewGroup = CacheHelper.GetGroup(ItemID.Value); } }
public static void AddGroupUser(Group group, User user) { if (group.ID.HasValue && user.ID.HasValue) AddGroupUser(group.ID.Value, user.ID.Value); else throw new Exception("Cannot add a user to a group when either the user or group has not been saved"); }
public static void AddGroup(Group group, out int? groupId, out DateTime createdDate) { using (SqlConnection conn = Helper.GetConnection()) { using (SqlCommand cmd = new SqlCommand(Constants.StoredProcedures.GroupManager.AddGroup, conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", group.Name); if (group.GeoLatitude.HasValue) cmd.Parameters.AddWithValue("@GeoLat", group.GeoLatitude.Value); if (group.GeoLongitude.HasValue) cmd.Parameters.AddWithValue("@GeoLng", group.GeoLongitude.Value); if (!string.IsNullOrEmpty(group.Name)) cmd.Parameters.AddWithValue("@Profile", group.Profile); if (!string.IsNullOrEmpty(group.PostalCode)) cmd.Parameters.AddWithValue("@PostalCode", group.PostalCode); SqlParameter prmGroupId = new SqlParameter(); prmGroupId.Direction = ParameterDirection.Output; prmGroupId.DbType = DbType.Int32; prmGroupId.ParameterName = "@GroupID"; cmd.Parameters.Add(prmGroupId); SqlParameter prmCreatedDate = new SqlParameter(); prmCreatedDate.Direction = ParameterDirection.Output; prmCreatedDate.DbType = DbType.DateTime; prmCreatedDate.ParameterName = "@CreatedDate"; cmd.Parameters.Add(prmCreatedDate); conn.Open(); cmd.ExecuteScalar(); groupId = (int)cmd.Parameters["@GroupID"].Value; createdDate = (DateTime)cmd.Parameters["@CreatedDate"].Value; } } }
public static void UpdateGroup(Group group) { using (SqlConnection conn = Helper.GetConnection()) { using (SqlCommand cmd = new SqlCommand(Constants.StoredProcedures.GroupManager.UpdateGroup, conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@GroupID", group.ID); cmd.Parameters.AddWithValue("@Name", group.Name); if (group.GeoLatitude.HasValue) cmd.Parameters.AddWithValue("@GeoLat", group.GeoLatitude.Value); if (group.GeoLongitude.HasValue) cmd.Parameters.AddWithValue("@GeoLng", group.GeoLongitude.Value); if (!string.IsNullOrEmpty(group.Profile)) cmd.Parameters.AddWithValue("@Profile", group.Profile); if (!string.IsNullOrEmpty(group.PostalCode)) cmd.Parameters.AddWithValue("@PostalCode", group.PostalCode); conn.Open(); cmd.ExecuteNonQuery(); } } }
public static void RemoveGroupUser(Group group, User user) { if (group.ID.HasValue && user.ID.HasValue) RemoveGroupUser(group.ID.Value, user.ID.Value); else throw new Exception("Cannot remove a user from a group when either the user or group has not been saved"); }
public static void RemoveGroup(Group group) { if (group.ID.HasValue) RemoveGroup(group.ID.Value); else throw new Exception("Group has not been saved and thus cannot be removed."); }
public static Dictionary<Venue, int> GetVenuesForGroup(Group group, bool limit) { return GetVenuesForGroup(group.ID.Value, limit); }
public static Dictionary<Venue, int> GetVenuesForGroup(Group group) { return GetVenuesForGroup(group, false); }