Example #1
0
 /// <summary>
 /// Edycja obszaru
 /// </summary>
 /// <param name="obszar">Obszar edytowany</param>
 public void Edit(Area obszar)
 {
     Geodeta.Data.Area area = new Geodeta.Data.Area {
         ID = obszar.ID, Name = obszar.Name, UserId = obszar.UserId, IsNewVersion = obszar.IsNewVersion, DateMod = System.DateTime.Now
     };
     this.db.Entry(area).State = EntityState.Modified;
     this.db.SaveChanges();
 }
Example #2
0
 /// <summary>
 /// Dodawanie obszaru do bazy danych
 /// </summary>
 /// <param name="obszar">Obszar dodawany</param>
 /// <returns>Id dodanego obszaru</returns>
 public int CreateArea(Area obszar)
 {
     Geodeta.Data.Area area = new Geodeta.Data.Area {
         ID = obszar.ID, Name = obszar.Name, UserId = obszar.UserId, IsNewVersion = obszar.IsNewVersion, DateMod = obszar.DateMod
     };
     this.db.Area.Add(area);
     this.db.SaveChanges();
     return(area.ID);
 }
Example #3
0
        /// <summary>
        /// Wyszukanie obszaru
        /// </summary>
        /// <param name="id">Id obszaru</param>
        /// <returns>Obszar o danym id</returns>
        public Geodeta.Data.Area Edit(int id = 0)
        {
            Geodeta.Data.Area obszar = this.db.Area.Find(id);
            if (obszar == null)
            {
                return(null);
            }

            return(obszar);
        }
Example #4
0
        /// <summary>
        /// Edycja obszaru o danym id
        /// </summary>
        /// <param name="id">Id area</param>
        /// <param name="a">Informacje do edycji obszaru z pkt i liniami</param>
        /// <returns>Obszar zedytowany</returns>
        public Area PutAreaSync(int id)
        {
            Geodeta.Data.Area area = this.db.Area.Find(id);
            area.IsNewVersion = false;
            Area tmp = new Area {
                Name = area.Name, ID = area.ID, UserId = area.UserId, DateMod = area.DateMod, IsNewVersion = area.IsNewVersion
            };

            this.db.Entry(area).State = EntityState.Modified;
            this.db.SaveChanges();
            return(tmp);
        }
Example #5
0
        /// <summary>
        /// Pobieranie obszaru o danym id
        /// </summary>
        /// <param name="id">Id obszaru</param>
        /// <returns>Obszar o danym id</returns>
        public Geodeta.Services.Area AreaDetails(int id = 0)
        {
            Geodeta.Data.Area obszar = this.db.Area.Find(id);
            if (obszar == null)
            {
                return(null);
            }
            Area obszardto = new Area {
                ID = obszar.ID, Name = obszar.Name, DateMod = obszar.DateMod, UserId = obszar.UserId, IsNewVersion = obszar.IsNewVersion
            };

            return(obszardto);
        }
Example #6
0
        /// <summary>
        /// Pobieranie obszaru o danym id
        /// </summary>
        /// <param name="id">Id obszaru</param>
        /// <returns>Obszar o danym id</returns>
        public Area GetArea(int id)
        {
            this.db.Configuration.ProxyCreationEnabled = false;
            Geodeta.Data.Area tmp = this.db.Area.Find(id);
            Area area             = new Area {
                ID = tmp.ID, Name = tmp.Name, UserId = tmp.UserId, IsNewVersion = tmp.IsNewVersion, DateMod = tmp.DateMod
            };

            if (area == null)
            {
                return(null);
            }

            return(area);
        }
Example #7
0
        /// <summary>
        /// Usuwanie obszaru z jego punktami listami punktów i liniami
        /// </summary>
        /// <param name="id">Id obszaru</param>
        public void DeleteConfirmed(int id)
        {
            var query = from p in this.db.Point
                        from l in this.db.Line
                        from lof in this.db.ListOfPoints
                        where ((l.AreaId == id) && (lof.LineId == l.ID) && (lof.PointId == p.ID))
                        select p;
            List <Geodeta.Data.Point> lista_punktow = query.Distinct().ToList();
            var query2 = from l in this.db.Line
                         where (l.AreaId == id)
                         select l;
            List <Geodeta.Data.Line> lista_linii = query2.ToList();
            var query3 = from l in this.db.Line
                         from lof in this.db.ListOfPoints
                         where ((l.AreaId == id) && (lof.LineId == l.ID))
                         select lof;
            List <Geodeta.Data.ListOfPoints> lista_lof = query3.ToList();

            for (int i = 0; i < lista_lof.Count; i++)
            {
                this.db.ListOfPoints.Remove(lista_lof[i]);

                this.db.SaveChanges();
            }

            for (int i = 0; i < lista_punktow.Count; i++)
            {
                this.db.Point.Remove(lista_punktow[i]);

                this.db.SaveChanges();
            }

            for (int i = 0; i < lista_linii.Count; i++)
            {
                this.db.Line.Remove(lista_linii[i]);

                this.db.SaveChanges();
            }

            Geodeta.Data.Area obszar = this.db.Area.Find(id);
            this.db.Area.Remove(obszar);
            this.db.SaveChanges();
        }