public DAL.Location saveInDB()
        {
            DAL.Location entity = null;

            if (this.point.id == 0)
            {
                return(null);
            }
            // Create, if not existant
            if (this.id == 0)
            {
                entity = MainClass.Instance.db.Location.Add(new DAL.Location()
                {
                    latLongCoordinateId = this.point.id,
                    name = this.name
                });
                MainClass.Instance.db.SaveChanges();
                this.id = entity.id;
            }
            else
            {
                entity = MainClass.Instance.db.Location.Where(v => v.id == this.id).FirstOrDefault();

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

                entity.latLongCoordinateId = this.point.id;
                entity.name = this.name;
                MainClass.Instance.db.SaveChanges();
            }
            return(entity);
        }
        public bool removeLocation(Location location)
        {
            DAL.Location entity = db.Location.Where(v => v.id == location.id).FirstOrDefault();

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

            // entity.boatToursManagerId = null;
            db.SaveChanges();
            return(this.locations.Remove(location));
        }
Beispiel #3
0
 public void LocationSelectAll(DataGridView locationList)
 {
     try
     {
         location = new DAL.Location();
         PopulateDataLayer();
         locationList.DataSource = location.LocationSelectAll().Tables[0];
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #4
0
 public DataTable LocationSelectAll()
 {
     try
     {
         DataTable dtLocation;
         location = new DAL.Location();
         PopulateDataLayer();
         dtLocation = location.LocationSelectAll().Tables[0];
         return(dtLocation);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #5
0
 public DataTable LocationSearchByKey()
 {
     try
     {
         location = new DAL.Location();
         DataTable dataResult = new DataTable();
         PopulateDataLayer();
         dataResult = location.LocationSearchByKey().Tables[0];
         return(dataResult);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #6
0
 public DataTable LocationSearchByScheduleCategory()
 {
     try
     {
         DataTable dtLocation;
         location = new DAL.Location();
         PopulateDataLayer();
         dtLocation = location.LocationSearchbyScheduleCategory().Tables[0];
         return(dtLocation);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public Location(DAL.Location location)
        {
            this.id    = location.id;
            this.point = new LatLongCoordinate(location.LatLongCoordinate);
            this.name  = location.name;

            foreach (DAL.Boat boat in location.Boat)
            {
                this.boats.Add(new Boat(boat));

                foreach (DAL.BoatRental rental in boat.BoatRental)
                {
                    this.boatRentals.Add(new BoatRental(rental));
                }
            }
        }
Beispiel #8
0
 public Boolean Save()
 {
     try
     {
         Boolean status = false;
         location = new DAL.Location();
         PopulateDataLayer();
         location.Save();
         MessageBox.Show("Location Record Save!", "Record Save");
         status = true;
         return(status);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #9
0
 public Boolean LocationDelete()
 {
     try
     {
         Boolean status = false;
         location = new DAL.Location();
         PopulateDataLayer();
         location.LocationDelete();
         MessageBox.Show("Record Successfully Deleted!", "Delete Record");
         status = true;
         return(status);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool addLocation(Location location)
        {
            if (this.locations.Contains(location))
            {
                return(false);
            }

            DAL.Location entity = db.Location.Where(v => v.id == location.id).FirstOrDefault();

            if (entity == null && (entity = location.saveInDB()) == null)
            {
                return(false);
            }

            //entity.boatToursManagerId = this.id;
            db.SaveChanges();

            this.locations.Add(location);
            return(true);
        }
 private static BusinessEntities.Search.Location ConvertLocation(DAL.Location location)
 {
     return(location.toLocation());
 }
 public static BusinessEntities.Search.Location toLocation(this DAL.Location location)
 {
     return(Mapper.Map <DAL.Location, BusinessEntities.Search.Location>(location));
 }