public IHttpActionResult Putteams(int id, teams teams) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != teams.id) { return(BadRequest()); } db.Entry(teams).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!teamsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Core() { Random randy = new Random(); #region read standart names names.txt using (StreamReader r = new StreamReader("..\\..\\..\\names.txt")) { string line; while ((line = r.ReadLine()) != null) { names.Add(line); } } #endregion #region Create worm for (int i = 0; i < 10; i++) { teams equipo = teams.blue; if (i > 4) { equipo = teams.red; } var index = randy.Next(0, names.Count() - 1); var nombre = names[index]; names.RemoveAt(index); worms[i] = new Worm(randy, nombre, equipo, map.SuperficiesPisables()); map.Add(worms[i].position, "2"); } #endregion }
public void AddUserToTeam(string TeamName, int Teamlead_id, int[] User_ids) { using (scheduler_v2Entities db = new scheduler_v2Entities()) { UserManager umngr = new UserManager(); var teamClass = new teams { name = TeamName, teamlead_id = Teamlead_id }; db.teams.Add(teamClass); db.teams.Attach(teamClass); var teamlead = new user_teams { team_id = teamClass.id, user_id = Teamlead_id }; db.teams.Add(teamClass); db.user_teams.Add(teamlead); foreach (int id in User_ids) { users person = umngr.GetUser(id); var user_team = new user_teams { team_id = teamClass.id, user_id = id }; db.user_teams.Add(user_team); } db.SaveChanges(); } }
//Overloaded constructor public Piece(teams team, types type, Vector2 position) { Team = team; Type = type; Position = position; DrawPosition = position; MovedInTurn = 0; }
public TeamPage(teams tId, string cName, object cImage) { NavigationPage.SetHasNavigationBar(this, false); InitializeComponent(); teamId = tId.id; clubName = cName; clubImage = cImage; }
public ActionResult CreateTeam(string gameid, string name, HttpPostedFileBase photo1, HttpPostedFileBase photo2) { if (gameid == null || name == null || photo1 == null || photo2 == null) { TempData["Message"] = "Values shouldn't be empty!"; return(RedirectToAction("create-team")); } else { List <users> ul = (List <users>)Session["Data"]; int userid = ul[0].userid; string photo = ""; string cover = ""; if (photo1 != null) { string pic = System.IO.Path.GetFileName(photo1.FileName); string newname = "spz-" + pic.Split('.')[0] + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH'-'mm'-'ss") + "." + pic.Split('.')[1]; string path = System.IO.Path.Combine( Server.MapPath("~/uploads/media"), newname); // file is uploaded photo1.SaveAs(path); photo = newname; } if (photo2 != null) { string pic = System.IO.Path.GetFileName(photo2.FileName); string newname = "spz-" + pic.Split('.')[0] + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH'-'mm'-'ss") + "." + pic.Split('.')[1]; string path = System.IO.Path.Combine( Server.MapPath("~/uploads/media"), newname); // file is uploaded photo2.SaveAs(path); cover = newname; } using (var context = new Entities()) { int clubid = (from c in context.clubs where c.userid == userid select c.clubid).SingleOrDefault(); teams tm = new teams { clubid = clubid, gameid = int.Parse(gameid), name = name, logo = photo, cover = cover }; context.teams.Add(tm); //adding games to clubs var update = context.clubs.Find(clubid); update.cg = update.cg + gameid + ","; context.Entry(update).State = EntityState.Modified; //save changes to db context.SaveChanges(); TempData["Message"] = "New team has been created!"; return(RedirectToAction("teams")); }; } }
// takes user ids public teams CreateTeam(string Team_Name, int Teamlead) { teams team = new teams() { name = Team_Name, teamlead_id = Teamlead }; return(team); }
public IHttpActionResult Getteams(int id) { teams teams = db.teams.Find(id); if (teams == null) { return(NotFound()); } return(Ok(teams)); }
public async void GoToTeam(object sender, ItemTappedEventArgs e) { var fav = (Favourite)e.Item; teams team = new teams(); team.id = fav.clubId; team.clubName = fav.clubName; team.name = fav.teamName; team.gender = fav.teamGender; await Navigation.PushAsync(new TeamPage(team, fav.clubName, fav.clubLogo)); }
public IHttpActionResult Deleteteams(int id) { teams teams = db.teams.Find(id); if (teams == null) { return(NotFound()); } db.teams.Remove(teams); db.SaveChanges(); return(Ok(teams)); }
public SingleTeam(teams cT, int cId) { NavigationPage.SetHasNavigationBar(this, false); InitializeComponent(); teamId = cT.id; cTeam = cT; clubId = cId; cName.Text = cT.clubName; cName2.Text = cT.clubName; tSport.Text = cT.sport.sportName; tM.Text = cT.coach.name; }
//Returns team object by given id and returns null if not found public teams GetTeamById(int TeamId) { using (scheduler_v2Entities db = new scheduler_v2Entities()) { teams team = (teams)db.teams.Where(x => x.id == TeamId); if (team == null) { return(null); } else { return(team); } } }
public int SubmitCode(int problemId, int usrId, string userName, string code, int languageId) { int?assignmentId = (from probs in db.problems where probs.problemId == problemId select probs.assignmentId).FirstOrDefault(); int?teamId = (from team in db.teams where team.assignmentId == assignmentId && team.userId == usrId select team.teamId).FirstOrDefault(); // Check if user is in team if (teamId == 0) { // Create a team team newTeam = new team { name = userName }; db.team.Add(newTeam); db.SaveChanges(); teamId = db.team.Max(x => x.id); teams teamsEntry = new teams { assignmentId = Convert.ToInt32(assignmentId), userId = usrId, teamId = Convert.ToInt32(teamId) }; db.teams.Add(teamsEntry); db.SaveChanges(); } submission newSubmission = new submission { code = code, problemId = problemId, languageId = languageId }; db.submission.Add(newSubmission); db.SaveChanges(); int submissionId = db.submission.Max(x => x.id); submissions submissionEntry = new submissions { submissionId = submissionId, teamId = Convert.ToInt32(teamId) }; db.submissions.Add(submissionEntry); db.SaveChanges(); return(submissionId); }
public List <teams> GetTeams(int clubId) { var cs = Services.ContentService; var teams = cs.GetChildren(clubId); var c = cs.GetById(clubId); var AT = new teams(); List <teams> AllTeams = new List <teams>(); foreach (var team in teams) { if (team.ContentTypeId == 1074) { var t = new teams(); t.id = team.Id; t.name = team.Name; t.clubName = c.Name; var sport = (team.Properties["typeOfSport"].Value.ToString() != null) ? this.GetSport(team.Properties["typeOfSport"].Value.ToString()) : null; t.sport = sport; var gender = (team.Properties["typeOfGender"].Value != null) ? team.Properties["typeOfGender"].Value.ToString() : null; try { t.gender = Umbraco.GetPreValueAsString(int.Parse(gender)); } catch { t.gender = ""; } t.coach = (team.Properties["teamManager"].Value != null) ? this.GetManager(team.Properties["teamManager"].Value.ToString()) : null; AllTeams.Add(t); } } return(AllTeams); }
public void BBall() { teams ballers = teams.Cavs; switch (ballers) { case teams.Champs: break; case teams.Cavs: break; case teams.Spurs: break; case teams.Miami: break; default: break; } }
public bool AddTeamMember(int?id, int userId, int memberId) { int assignmentId = Convert.ToInt32(id); int?teamId = (from team in db.teams where team.assignmentId == assignmentId && team.userId == userId select team.teamId).FirstOrDefault(); // Check if target is already in a group if (db.teams.Where(m => m.userId == memberId && m.assignmentId == assignmentId).Count() == 0) { // Check if we need to create a new team if (teamId == null) { // Create new team team newTeam = new team(); db.team.Add(newTeam); db.SaveChanges(); teamId = db.team.Max(x => x.id); teams teamsEntry = new teams { assignmentId = assignmentId, userId = userId, teamId = Convert.ToInt32(teamId) }; db.teams.Add(teamsEntry); db.SaveChanges(); } int tid = Convert.ToInt32(teamId); db.teams.Add(new teams { assignmentId = assignmentId, userId = memberId, teamId = tid }); db.SaveChanges(); return(true); } else { return(false); } }
public void SetTeam(teams team) { this.team = team; }
public ActionResult Clubs(string id, string city, int?game) { try { if (city == "all") { city = null; } if (game == 0) { game = null; } if (id == null) { using (var context = new Entities()) { // if (city == null) city = ""; // if (name == null) name = ""; List <games> gms = (from gm in context.games select gm).ToList(); List <clubs> clubd = new List <clubs>(); List <clubs> cls = (from c in context.clubs where (c.city == null || DbFunctions.Like(c.city, "%" + city + "%")) && (c.cg == null || DbFunctions.Like(c.cg, "%" + game + "," + "%")) select c).ToList(); for (int i = 0; i < cls.Count; i++) { { int uid = cls[i].userid; int cid = cls[i].clubid; string username = (from u in context.users where u.userid == uid select u.username).SingleOrDefault(); int tcount = (from c in context.teams where c.clubid == cid select c).Count(); int ccount = (from cc in context.coach_associations where cc.coachid == cid select cc).Count(); clubs clbd = new clubs { clubid = cls[i].clubid, userid = cls[i].userid, clubname = cls[i].clubname + "♦" + username + "♦" + tcount + "♦" + ccount, city = cls[i].city, C_address = cls[i].C_address, C_state = cls[i].C_state, lat = cls[i].lat, @long = cls[i].@long, logo = cls[i].logo, cover = cls[i].cover }; clubd.Add(clbd); } } ViewBag.Games = gms; return(View(clubd)); } } else { using (var context = new Entities()) { int?uid = (from u in context.users where u.username == id select u.userid).SingleOrDefault(); if (uid != null) { List <clubs> clb = (from c in context.clubs where c.userid == uid select c).ToList(); int cid = clb[0].clubid; //club id // Get Teams Data List <teams> tms = (from t in context.teams where t.clubid == cid select t).ToList(); List <teams> teams = new List <teams>(); for (int i = 0; i < tms.Count; i++) { int teamid = tms[i].teamid; int gameid = tms[i].gameid; int totalplayerinteam = (from tpt in context.player_associations where tpt.teamid == teamid select tpt).Count(); int totalcoachsinteam = (from tct in context.coach_associations where tct.teamid == teamid select tct).Count(); string gamename = (from gn in context.games where gn.gameid == gameid select gn.gamename).SingleOrDefault(); teams tm = new teams() { teamid = teamid, name = tms[i].name + "♦" + gamename + "♦" + totalplayerinteam + "♦" + totalcoachsinteam, logo = tms[i].logo }; teams.Add(tm); } //Get Coachs Data List <int> chs = (from ch in context.coach_associations where ch.clubid == cid select ch.coachid).ToList(); //Get Coachs - Complete data ------------------ List <coachs> ourcoachs = new List <coachs>(); for (int i = 0; i < chs.Count; i++) { int chid = chs[i]; List <coachs> coachs = (from c_c in context.coachs where c_c.coachid == chid select c_c).ToList(); int? positionid = coachs[0].positionid; string position = (from pos in context.games_positions where pos.positionid == positionid select pos.position).SingleOrDefault(); //get user data int userid = coachs[0].userid; List <users> users = (from usr in context.users where usr.userid == userid select usr).ToList(); coachs _coach = new coachs { coachid = coachs[0].coachid, userid = coachs[0].userid, name = coachs[0].name + "♦" + users[0].username + "♦" + position, age = coachs[0].age, picture = coachs[0].picture, }; ourcoachs.Add(_coach); } // get top 3 players List <player_associations> pa = (from plas in context.player_associations where plas.clubid == cid select plas).ToList(); List <players> asplayers = new List <players>(); int j = 0; if (pa.Count >= 3) { j = 3; } else { j = pa.Count; } for (int i = 0; i < j; i++) { int roleid = pa[i].roleid; int playerid = pa[i].playerid; string position = (from rnam in context.games_positions where rnam.positionid == roleid select rnam.position).SingleOrDefault(); List <players> player = (from ply in context.players where ply.playerid == playerid select ply).ToList(); players plyr = new players { playerid = playerid, playername = player[0].playername + "♦" + position, age = player[0].age, photo = player[0].photo, height = player[0].height, }; asplayers.Add(plyr); } ViewBag.Players = asplayers; ViewBag.Teams = teams; ViewBag.Coachs = ourcoachs; return(View("clubdetail", clb)); } else { ViewBag.Message = "Club not found!"; return(View("error404")); } } } } catch (Exception ex) { ViewBag.Message = ex.Message; return(View("error404")); } }
public Worm(Random r, string name, teams equip, List <Coordinate> pisable) { this.name = name; this.equip = equip; this.position = pisable[r.Next(0, pisable.Count)]; }
public void SetTeam(teams team) { this.team = team; }
public async void Handle_FlowItemTapped(object sender, ItemTappedEventArgs e) { teams team = (teams)e.Item; await Navigation.PushAsync(new SingleTeam(team, clubId)); }