public static List <NationalTeam> ImportData() { if (File.Exists(inputFileName) == true) { try { StreamReader reader = new StreamReader(inputFileName); List <NationalTeam> teams = new List <NationalTeam>(); while (!reader.EndOfStream) { String line = reader.ReadLine(); String[] words = line.Split(','); NationalTeam nt = new NationalTeam(words[0], words[1], Int32.Parse(words[2])); teams.Add(nt); } reader.Close(); return(teams); } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(null); }
public int SaveToDB(CountryDTO dtoObj) { Country dbObj = new Country(); using (UaFootball_DBDataContext db = DBManager.GetDB()) { if (dtoObj.Country_ID > 0) { dbObj = db.Countries.Single(cc => cc.Country_ID == dtoObj.Country_ID); } else { db.Countries.InsertOnSubmit(dbObj); NationalTeam newNationalTeam = new NationalTeam { Country = dbObj, NationalTeamType_Cd = Constants.DB.NationalTeamTypeCd_National }; NationalTeam newNationalU21Team = new NationalTeam { Country = dbObj, NationalTeamType_Cd = Constants.DB.NationalTeamTypeCd_U21 }; db.NationalTeams.InsertOnSubmit(newNationalTeam); db.NationalTeams.InsertOnSubmit(newNationalU21Team); } CopyDTOToDbObject(dtoObj, dbObj); db.SubmitChanges(); return(dbObj.Country_ID); } }
public ActionResult DeleteConfirmed(int id) { NationalTeam nationalTeam = db.NationalTeams.Find(id); db.NationalTeams.Remove(nationalTeam); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "NationalTeamId,Name,Continent,Information,Players")] NationalTeam nationalTeam) { if (ModelState.IsValid) { db.Entry(nationalTeam).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nationalTeam)); }
public ActionResult Create([Bind(Include = "NationalTeamId,Name,Continent,Information,Players")] NationalTeam nationalTeam) { if (ModelState.IsValid) { db.NationalTeams.Add(nationalTeam); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nationalTeam)); }
public NationalTeamDTO ConvertDBObjectToDTO(NationalTeam dbObj) { NationalTeamDTO dtoObj = new NationalTeamDTO() { County_ID = dbObj.Country_Id, ID = dbObj.NationalTeam_Id, Kind = dbObj.NationalTeamType_Cd }; return(dtoObj); }
// GET: NationalTeams/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NationalTeam nationalTeam = db.NationalTeams.Find(id); if (nationalTeam == null) { return(HttpNotFound()); } return(View(nationalTeam)); }
public IActionResult AddNationalTeam([FromBody] NationalTeam entity) { var decodedToken = authentication.DecodeTokenFromRequest(Request.Headers["Authorization"]); string role = authentication.GetRoleFromToken(decodedToken); int id = authentication.GetIDFromToken(decodedToken); if (role == "Player") { if (_playerLogic.AddNationalTeam(entity, id)) { return(Ok()); } } return(StatusCode(500, "Failed")); }
public bool AddNationalTeam(NationalTeam entity, int player_ID) { bool res = false; int rowCount = 0; using (var conn = Connection()) { using (IDbTransaction tran = conn.BeginTransaction()) { try { //Insert National team string nationalTeamSQL = @"INSERT INTO NationalTeam (Name, Appearances, Position, Statistic, Player_ID) VALUES (@Name, @Appearances, @Position, @Statistic, @Player_ID)"; rowCount = conn.Execute(nationalTeamSQL, new { entity.Name, entity.Appearances, entity.Position, entity.Statistic, Player_ID = player_ID }, transaction: tran); if (rowCount == 0) { tran.Rollback(); } else { tran.Commit(); res = true; } } catch (SqlException) { tran.Rollback(); } } } return(res); }
private List <NationalTeam> ParseNationalTeamCoachNode(XmlNode nationalTeamNode) { try { List <NationalTeam> nationalTeamList = new List <NationalTeam>(); foreach (XmlNode xmlNode in nationalTeamNode.ChildNodes) { switch (xmlNode.Name) { case Tags.NationalTeam: if (xmlNode.ChildNodes != null) { NationalTeam newNationalTeam = new NationalTeam(); foreach (XmlNode xmlNodeNationalTeam in xmlNode.ChildNodes) { switch (xmlNodeNationalTeam.Name) { case Tags.NationalTeamID: newNationalTeam.nationalTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNodeNationalTeam.InnerText); break; case Tags.NationalTeamName: newNationalTeam.nationalTeamNameField = xmlNodeNationalTeam.InnerText; break; } } nationalTeamList.Add(newNationalTeam); } break; } } return(nationalTeamList); } catch (Exception ex) { throw ex; } }
public void CopyDTOToDbObject(NationalTeamDTO dtoObj, NationalTeam dbObj) { dbObj.Country_Id = dtoObj.County_ID; dbObj.NationalTeam_Id = dtoObj.ID; dbObj.NationalTeamType_Cd = dtoObj.Kind; }
public bool AddNationalTeam(NationalTeam entity, int player_ID) { return(_playerRepos.AddNationalTeam(entity, player_ID)); }
public async Task <NationalTeam> AddAsync(NationalTeam nationalTeam) { var addedNationalTeam = await _context.NationalTeam.AddAsync(nationalTeam); return(addedNationalTeam.Entity); }
private void Map(Round t) { AxMapWinGIS.AxMap map = new AxMapWinGIS.AxMap(); map.Width = 380; map.Height = 380; host.Child = map; map.Show(); map.CreateControl(); map.ShowZoomBar = false; map.ShowCoordinates = MapWinGIS.tkCoordinatesDisplay.cdmNone; map.CursorMode = MapWinGIS.tkCursorMode.cmNone; MapWinGIS.Shapefile shapeFileMap = new MapWinGIS.Shapefile(); shapeFileMap.Open(@"D:\Projets\TheManager\TheManager_GUI\bin\Debug\gis\world\World_Countries.shp", null); map.AddLayer(shapeFileMap, true); ILocalisation localisation = Session.Instance.Game.kernel.LocalisationTournament(t.Tournament); double logoSize = 30.0; if (localisation as Country != null) { map.ZoomToShape(0, (localisation as Country).ShapeNumber); } else { if (localisation.Name() == "Europe") { map.ZoomToShape(0, 68 /*12 101*/); map.CurrentZoom = 4; } else if (localisation.Name() == "Africa") { map.ZoomToShape(0, 40); map.CurrentZoom = 3; } logoSize = 15.0; } foreach (Club c in t.clubs) { CityClub cc = c as CityClub; if (cc != null) { double projX = -1; double projY = -1; map.DegreesToProj(cc.city.Position.Longitude, cc.city.Position.Latitude, ref projX, ref projY); MapWinGIS.Image img = new MapWinGIS.Image(); img.Open(Utils.Logo(c)); MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile(); sf.CreateNew("", MapWinGIS.ShpfileType.SHP_POINT); sf.DefaultDrawingOptions.AlignPictureByBottom = false; sf.DefaultDrawingOptions.PointType = MapWinGIS.tkPointSymbolType.ptSymbolPicture; sf.DefaultDrawingOptions.Picture = img; sf.DefaultDrawingOptions.PictureScaleX = Math.Round(logoSize / img.OriginalWidth, 2); sf.DefaultDrawingOptions.PictureScaleY = Math.Round(logoSize / img.OriginalHeight, 2); sf.CollisionMode = MapWinGIS.tkCollisionMode.AllowCollisions; MapWinGIS.Shape shp = new MapWinGIS.Shape(); shp.Create(MapWinGIS.ShpfileType.SHP_POINT); shp.AddPoint(projX, projY); sf.EditAddShape(shp); map.AddLayer(sf, true); } } if (_competition.rounds[_indexTour].clubs.Count > 0 && _competition.rounds[_indexTour].clubs[0] as NationalTeam != null) { shapeFileMap.StartEditingTable(); int fieldIndex = shapeFileMap.EditAddField("Qualification", MapWinGIS.FieldType.INTEGER_FIELD, 1, 1); shapeFileMap.DefaultDrawingOptions.FillType = MapWinGIS.tkFillType.ftStandard; for (int i = 0; i < shapeFileMap.NumShapes; i++) { shapeFileMap.EditCellValue(fieldIndex, i, 0); } Dictionary <NationalTeam, int> clubCourses = new Dictionary <NationalTeam, int>(); for (int i = 0; i < _competition.rounds.Count; i++) { Round round = _competition.rounds[i]; foreach (Club c in round.clubs) { NationalTeam nt = c as NationalTeam; if (!clubCourses.ContainsKey(nt)) { clubCourses.Add(nt, 1); } clubCourses[nt] = i + 1; } } foreach (KeyValuePair <NationalTeam, int> kvp in clubCourses) { shapeFileMap.EditCellValue(fieldIndex, kvp.Key.country.ShapeNumber, kvp.Value); } shapeFileMap.Categories.Generate(fieldIndex, MapWinGIS.tkClassificationType.ctUniqueValues, _competition.rounds.Count + 1); shapeFileMap.Categories.ApplyExpressions(); MapWinGIS.ColorScheme colorScheme = new MapWinGIS.ColorScheme(); colorScheme.SetColors2(MapWinGIS.tkMapColor.AliceBlue, MapWinGIS.tkMapColor.DarkBlue); shapeFileMap.Categories.ApplyColorScheme(MapWinGIS.tkColorSchemeType.ctSchemeGraduated, colorScheme); } map.Redraw(); }
public NationalTeamResponse(NationalTeam nationalTeam) : this(true, string.Empty, nationalTeam) { }
private NationalTeamResponse(bool success, string message, NationalTeam nationalTeam) : base(success, message) { NationalTeam = nationalTeam; }