/// <summary> /// Pobieranie punktu o danym id /// </summary> /// <param name="id">Id punktu</param> /// <returns>Punkt o danym id</returns> public Geodeta.Data.Point PointDetails(int id = 0) { Geodeta.Data.Point punkt = this.db.Point.Find(id); if (punkt == null) { return(null); } return(punkt); }
/// <summary> /// Dodawanie nowej notatki /// </summary> /// <param name="pointId">Id punktu</param> /// <param name="title">Tytuł notatki</param> /// <param name="content">Zawartość notatki</param> /// <returns>Id notatki</returns> public int CreateNote(int pointId, string title, string content) { Geodeta.Data.Note note = this.db.Note.Add(new Geodeta.Data.Note { Title = title, ContentNote = content }); this.db.SaveChanges(); if (pointId != 0) { Geodeta.Data.Point point = this.db.Point.Find(pointId); point.NoteId = note.ID; this.db.Entry(point).State = EntityState.Modified; this.db.SaveChanges(); } return(note.ID); }
/// <summary> /// Dodawanie linii punktów i listy punktów obszaru /// </summary> /// <param name="id">Id obszaru</param> /// <param name="x">Lista wspołrzędnych X punktów</param> /// <param name="y">Lista wspołrzędnych Y punktów</param> /// <param name="note">Lista id notatek</param> public void CreateListOfPoints(int id, List <double> x, List <double> y, List <string> notetitlepoint, List <string> notecontentpoint, List <string> notetitleline, List <string> notecontentline) { List <int> lineid = new List <int>(); List <int> pointid = new List <int>(); Debug.WriteLine(notetitleline.Count); for (int i = 0; i < x.Count; i++) { if (notetitleline[i] != "" && notecontentline[i] != "Brak notatki") { Geodeta.Data.Note note1 = this.db.Note.Add(new Geodeta.Data.Note { Title = notetitleline[i], ContentNote = notecontentline[i] }); this.db.SaveChanges(); Geodeta.Data.Line line = new Geodeta.Data.Line { AreaId = id, NoteId = note1.ID }; this.db.Line.Add(line); this.db.SaveChanges(); lineid.Add(line.ID); } else { Geodeta.Data.Line line = new Geodeta.Data.Line { AreaId = id }; this.db.Line.Add(line); this.db.SaveChanges(); lineid.Add(line.ID); } if (notetitlepoint[i] != "" && notecontentpoint[i] != "Brak notatki") { Debug.WriteLine("waruenk 1"); Geodeta.Data.Note note1 = this.db.Note.Add(new Geodeta.Data.Note { Title = notetitlepoint[i], ContentNote = notecontentpoint[i] }); this.db.SaveChanges(); Geodeta.Data.Point point = new Geodeta.Data.Point { CoordinateX = x[i], CoordinateY = y[i], NoteId = note1.ID }; this.db.Point.Add(point); this.db.SaveChanges(); pointid.Add(point.ID); } else { Debug.WriteLine("waruenk else1"); Geodeta.Data.Point point = new Geodeta.Data.Point { CoordinateX = x[i], CoordinateY = y[i] }; this.db.Point.Add(point); this.db.SaveChanges(); pointid.Add(point.ID); } } for (int i = 0; i < pointid.Count; i++) { if (i == 0) { this.db.ListOfPoints.Add(new Geodeta.Data.ListOfPoints { LineId = lineid[i], PointId = pointid[i] }); this.db.SaveChanges(); } if (i > 0 && pointid.Count - 1 > i) { this.db.ListOfPoints.Add(new Geodeta.Data.ListOfPoints { LineId = lineid[i - 1], PointId = pointid[i] }); this.db.ListOfPoints.Add(new Geodeta.Data.ListOfPoints { LineId = lineid[i], PointId = pointid[i] }); this.db.SaveChanges(); } if (pointid.Count - 1 == i) { this.db.ListOfPoints.Add(new Geodeta.Data.ListOfPoints { LineId = lineid[i - 1], PointId = pointid[i] }); this.db.ListOfPoints.Add(new Geodeta.Data.ListOfPoints { LineId = lineid[i], PointId = pointid[i] }); this.db.ListOfPoints.Add(new Geodeta.Data.ListOfPoints { LineId = lineid[i], PointId = pointid[i - (x.Count - 1)] }); this.db.SaveChanges(); } } }