/// <summary> /// Initializes a new instance of the <see cref="Cemetery"/> class. /// </summary> /// <param name="id">The ID of the cemetery, used for identification.</param> /// <param name="name">The name of the cemetery.</param> /// <param name="address">The address of the cemetery.</param> /// <param name="postalCode">The postal code of the cemetery.</param> /// <param name="residence">The residence of the cemetery.</param> /// <param name="map">The map of the cemetery.</param> public Cemetery(int id, string name, string address, string postalCode, string residence, Map map) { this.ID = id; this.Name = name; this.Address = address; this.PostalCode = postalCode; this.Map = map; this.GraveLocations = new List<GraveLocation>(); }
private static Cemetery ParseCemetery(DataTable dataTable) { DataRow firstRow = dataTable.Rows[0]; int cemeteryID = (int)firstRow["BEG_ID"]; string name = firstRow["BEG_NAAM"].ToString(); string address = firstRow["BEG_ADRES"].ToString(); string postalCode = firstRow["BEG_POSTCODE"].ToString(); string residence = firstRow["BEG_PLAATS"].ToString(); int mapID = (int)firstRow["PL_ID"]; string mapFilePath = firstRow["PL_BESTANDSNAAM"].ToString(); DateTime mapStartDate = DateTime.Parse(firstRow["PL_STARTDATUM"].ToString()); DateTime mapEndDate = DateTime.Parse(firstRow["PL_EINDDATUM"].ToString()); float locationLeftTopX = (float)firstRow["PL_LINKSBOVENX"]; float locationLeftTopY = (float)firstRow["PL_LINKSBOVENY"]; float locationRightBottomX = (float)firstRow["PL_RECHTSONDERX"]; float locationRightBottomY = (float)firstRow["PL_RECHTSONDERY"]; PointFloat locationLeftTop = new PointFloat(locationLeftTopX, locationLeftTopY); PointFloat locationRightBottom = new PointFloat(locationRightBottomX, locationRightBottomY); Map map = new Map(mapID, mapFilePath, mapStartDate, mapEndDate, locationLeftTop, locationRightBottom); Cemetery cemetery = new Cemetery(cemeteryID, name, address, postalCode, residence, map); foreach (DataRow row in dataTable.Rows) { int graveLocationID = (int)row["GL_ID"]; GraveLocation graveLocation = cemetery.GraveLocations.Find(gl => gl.ID == graveLocationID); if (graveLocation == null) { int graveLocationNumber = (int)row["GL_NUMMER"]; int graveLocationSectionNumber = (int)row["GL_VAK"]; int graveLocationRowNumber = (int)row["GL_RIJ"]; GraveLocationState graveLocationState = (GraveLocationState)Enum.Parse(typeof(GraveLocationState), row["GL_STATUS"].ToString()); float graveLocationLocationX = (float)row["GL_COORDINATENX"]; float graveLocationLocationY = (float)row["GL_COORDINATENY"]; PointFloat graveLocationLocation = new PointFloat(graveLocationLocationX, graveLocationLocationY); graveLocation = new GraveLocation(graveLocationID, graveLocationNumber, graveLocationRowNumber, graveLocationSectionNumber, graveLocationState, graveLocationLocation); cemetery.AddGraveLocation(graveLocation); } Object gravesSpreadIDUnparsed = row["gs_ID"]; if (gravesSpreadIDUnparsed != null) { int graveSpreadID = (int)row["GS_ID"]; GraveSpread graveSpread = cemetery.GraveSpreads.Find(gs => gs.ID == graveSpreadID); if (graveSpread == null) { DateTime startTime = DateTime.Parse(row["GS_STARTDATUM"].ToString()); DateTime endTime = DateTime.Parse(row["GS_EINDDATUM"].ToString()); graveSpread = new GraveSpread(graveSpreadID, startTime, endTime); } graveSpread.AddGraveLocation(graveLocation); } } return cemetery; }