/// <summary> /// Updates a ClanGroup /// </summary> public static void Update(ClanGroup clanGroup) { using (var dbContext = new HouseOfClansEntities()) { ClanGroup clanGroupInfo = ClanGroupManager.SelectByClanGroupId(clanGroup.id); clanGroupInfo.updatedOn = DateTime.Now; dbContext.ClanGroups.Attach(clanGroupInfo); dbContext.Entry(clanGroupInfo).CurrentValues.SetValues(clanGroup); dbContext.SaveChanges(); } }
/// <summary> /// Deletes a ClanGroup /// </summary> public static bool Delete(int clanGroupId) { bool isDeleted = false; ClanGroup deleteClanGroup = ClanGroupManager.SelectByClanGroupId(clanGroupId); using (var dbContext = new HouseOfClansEntities()) { dbContext.ClanGroups.Attach(deleteClanGroup); dbContext.ClanGroups.Remove(deleteClanGroup); isDeleted = dbContext.SaveChanges() > 0; } return(isDeleted); }
/// <summary> /// Gets the all group members(except Leader) based on the group id /// </summary> /// <param name="clanId">Clan Id</param> public static List <ClanUser> SelectGroupMembersByGroupId(int groupId) { List <ClanUser> groupMembers = new List <ClanUser>(); using (var dbContext = new HouseOfClansEntities()) { groupMembers = dbContext.ClanUsers.Where(p => p.clanGroupId == groupId).ToList(); } ClanGroup group = ClanGroupManager.SelectByClanGroupId(groupId); groupMembers.RemoveAll(member => member.id == group.groupLeaderId); return(groupMembers); }