public void AddToGroup(CMSDataContext Db, string name, int?n) { if (!name.HasValue()) { return; } var mt = Db.MemberTags.SingleOrDefault(t => t.Name == name.Trim() && t.OrgId == OrganizationId); if (mt == null) { mt = new MemberTag { Name = name.Trim(), OrgId = OrganizationId }; Db.MemberTags.InsertOnSubmit(mt); Db.SubmitChanges(); } var omt = Db.OrgMemMemTags.SingleOrDefault(t => t.PeopleId == PeopleId && t.MemberTagId == mt.Id && t.OrgId == OrganizationId); if (omt == null) { mt.OrgMemMemTags.Add(new OrgMemMemTag { PeopleId = PeopleId, OrgId = OrganizationId, Number = n }); } Db.SubmitChanges(); }
public static void AddMemberTag(CMSDataContext db, int orgId, string name) { if (!name.HasValue()) { return; } var name2 = name.Trim().Truncate(200); var mt = db.MemberTags.SingleOrDefault(t => t.Name == name2 && t.OrgId == orgId); if (mt == null) { mt = new MemberTag { Name = name2, OrgId = orgId }; db.MemberTags.InsertOnSubmit(mt); db.SubmitChanges(); } db.SubmitChanges(); }
public ActionResult MakeNewGroup(OrgGroupsModel m) { if (!m.GroupName.HasValue()) return Content("error: no group name"); var Db = DbUtil.Db; var group = Db.MemberTags.SingleOrDefault(g => g.Name == m.GroupName && g.OrgId == m.orgid); if (group == null) { group = new MemberTag { Name = m.GroupName, OrgId = m.orgid }; Db.MemberTags.InsertOnSubmit(group); Db.SubmitChanges(); } m.groupid = group.Id; ViewData["newgid"] = group.Id; return Redirect("/OrgGroups/Management/" + m.orgid); }
public void AddToGroup(CMSDataContext Db, string name, int? n) { if (!name.HasValue()) return; var name2 = name.Trim().Truncate(200); var mt = Db.MemberTags.SingleOrDefault(t => t.Name == name2 && t.OrgId == OrganizationId); if (mt == null) { mt = new MemberTag { Name = name2, OrgId = OrganizationId }; Db.MemberTags.InsertOnSubmit(mt); Db.SubmitChanges(); } var omt = Db.OrgMemMemTags.SingleOrDefault(t => t.PeopleId == PeopleId && t.MemberTagId == mt.Id && t.OrgId == OrganizationId); if (omt == null) mt.OrgMemMemTags.Add(new OrgMemMemTag { PeopleId = PeopleId, OrgId = OrganizationId, Number = n }); Db.SubmitChanges(); }
public static void AddMemberTag(CMSDataContext db, int orgId, string name) { if (!name.HasValue()) return; var name2 = name.Trim().Truncate(200); var mt = db.MemberTags.SingleOrDefault(t => t.Name == name2 && t.OrgId == orgId); if (mt == null) { mt = new MemberTag { Name = name2, OrgId = orgId }; db.MemberTags.InsertOnSubmit(mt); db.SubmitChanges(); } db.SubmitChanges(); }
public void createTeamGroups() { var c = from e in DbUtil.Db.OrganizationMembers where e.Score == 0 where e.OrganizationId == orgid select e; foreach (var coach in c) { var name = "TM: " + coach.Person.Name; var group = DbUtil.Db.MemberTags.SingleOrDefault(g => g.Name == name && g.OrgId == orgid); if (group != null) continue; group = new MemberTag { Name = name, OrgId = orgid }; DbUtil.Db.MemberTags.InsertOnSubmit(group); } DbUtil.Db.SubmitChanges(); // Refresh the list var teamList = (from e in DbUtil.Db.MemberTags where e.OrgId == orgid where e.Name.StartsWith( "TM:" ) select e).ToList(); var p = (from e in DbUtil.Db.OrganizationMembers where e.Score != 0 where e.OrganizationId == orgid select e).ToList(); var teams = teamList.Count(); var players = p.Count(); var perTeam = Math.Floor((double)players / teams); var passes = Math.Floor((double)perTeam / 2); for (int iX = 0; iX < passes; iX++) { foreach (var team in teamList) { var tagTop = new OrgMemMemTag(); var tagBot = new OrgMemMemTag(); var top = p.OrderByDescending(t => t.Score).ThenByDescending(t => t.PeopleId).Take(1).SingleOrDefault(); var bot = p.OrderBy(t => t.Score).ThenBy(t => t.PeopleId).Take(1).SingleOrDefault(); tagTop.MemberTagId = team.Id; tagTop.OrgId = orgid; tagTop.PeopleId = top.PeopleId; tagBot.MemberTagId = team.Id; tagBot.OrgId = orgid; tagBot.PeopleId = bot.PeopleId; DbUtil.Db.OrgMemMemTags.InsertOnSubmit(tagTop); DbUtil.Db.OrgMemMemTags.InsertOnSubmit(tagBot); p.Remove(top); p.Remove(bot); } } if (p.Count() > 0) { foreach (var team in teamList) { var tagBot = new OrgMemMemTag(); var bot = p.OrderBy(t => t.Score).ThenBy(t => t.PeopleId).Take(1).SingleOrDefault(); if (bot == null) break; tagBot.MemberTagId = team.Id; tagBot.OrgId = orgid; tagBot.PeopleId = bot.PeopleId; DbUtil.Db.OrgMemMemTags.InsertOnSubmit(tagBot); p.Remove(bot); } } if (p.Count() > 0) { foreach (var team in teamList) { var tagBot = new OrgMemMemTag(); var bot = p.OrderBy(t => t.Score).ThenBy(t => t.PeopleId).Take(1).SingleOrDefault(); if (bot == null) break; tagBot.MemberTagId = team.Id; tagBot.OrgId = orgid; tagBot.PeopleId = bot.PeopleId; DbUtil.Db.OrgMemMemTags.InsertOnSubmit(tagBot); p.Remove(bot); } } DbUtil.Db.SubmitChanges(); }
public void AddNewSmallGroup() { var o = DbUtil.Db.LoadOrganizationById(Id); var mt = new MemberTag { Name = NewGroup }; o.MemberTags.Add(mt); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("OrgMem AddNewSubGroup " + NewGroup, Id); AddSmallGroup(mt.Id); NewGroup = null; }
private void detach_MemberTags(MemberTag entity) { this.SendPropertyChanging(); entity.Organization = null; }
public string AddNewSmallGroup(int pid) { var o = DbUtil.Db.LoadOrganizationById(OrgId); var mt = new MemberTag { Name = NewGroup }; o.MemberTags.Add(mt); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("OrgMem AddNewSubGroup " + NewGroup, OrgId); NewGroup = null; return SmallGroupChanged(mt.Id, true); }