Esempio n. 1
0
        public DAL.LatLongCoordinate saveInDB()
        {
            DAL.LatLongCoordinate entity = null;

            // Create, if not existant
            if (this.id == 0)
            {
                entity = MainClass.Instance.db.LatLongCoordinate.Add(new DAL.LatLongCoordinate()
                {
                    latitude  = this.latitude,
                    longitude = this.longitude,
                    name      = this.name
                });
                MainClass.Instance.db.SaveChanges();
                this.id = entity.id;
            }
            else
            {
                entity = MainClass.Instance.db.LatLongCoordinate.Where(v => v.id == this.id).FirstOrDefault();

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

                entity.latitude  = this.latitude;
                entity.longitude = this.longitude;
                entity.name      = this.name;
                MainClass.Instance.db.SaveChanges();
            }
            return(entity);
        }
Esempio n. 2
0
 public LatLongCoordinate(DAL.LatLongCoordinate latLongCoordinate)
 {
     this.id        = latLongCoordinate.id;
     this.latitude  = latLongCoordinate.latitude;
     this.longitude = latLongCoordinate.longitude;
     this.name      = latLongCoordinate.name;
 }