Esempio n. 1
0
        public int Add(Location location)
        {
            try
            {
                Location loc = new Location();
                loc.area_id = location.area_id;
                loc.floor_nr = location.floor_nr;
                loc.latitude = location.latitude;
                loc.longitude = location.longitude;
                loc.location_type_id = location.location_type_id;
                this._repository.Add(loc);

                this.Save();

                var location_id = loc.location_id;

                //TODO remove usp-create-location

                //add new names
                this.AddNames(location.LocationNames, location_id);

                this.Save();

                return location_id;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Esempio n. 2
0
        public LocationViewModel(Location location)
        {
            this._mainService = new MainService();

            this.SearchResult = null;
            this.SearchTerm = "";
            this.AreaTerm = "";
            this.Location = location;

            this.Cities = this._mainService.GetCities();

            this.Areas = this._mainService.GetAreas();
            this.LocationTypes = this._mainService.GetLocationTypes();
 
            this.FloorNumbers = new List<int>();
            for (int i = -1; i < 10; ++i)
                FloorNumbers.Add(i + 1);

            this.HasChosenCity = false;
            this.HasChosenArea = false;
            this.TriedToAddPlace = false;
        }
Esempio n. 3
0
 public static object ToViewModel(Location location)
 {
     return new LocationViewModel(location);
 }
Esempio n. 4
0
        public void Delete(Location location)
        {
            this._repository.Delete(location);

            this.Save();
        }
Esempio n. 5
0
        public void Update(Location oldLocation, Location newLocation)
        {
            try
            {
                oldLocation.location_type_id = newLocation.location_type_id;
                oldLocation.area_id = newLocation.area_id;
                oldLocation.latitude = newLocation.latitude;
                oldLocation.longitude = newLocation.longitude;
                oldLocation.floor_nr = newLocation.floor_nr;

                this.RemoveNames(oldLocation.LocationNames);
                this.AddNames(newLocation.LocationNames, oldLocation.location_id);

                this.Save();
            }
            catch (Exception)
            {
                throw new Exception("Kunde inte spara platsen.");
            }
        }