public LocationTypeViewModel(LocationType locationType)
 {
     this._mainService = new MainService();
     this.LocationTypes = this._mainService.GetLocationTypes();
     this.Icons = this._mainService.GetIcons();
     this.LocationType = locationType;
 }
 public void Delete(LocationType locationtype)
 {
     try
     {
         this._repository.Delete(locationtype);
         this.Save();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public int Add(LocationType locationtype)
 {
     try
     {
         this._repository.Add<LocationType>(locationtype);
         this.Save();
         return locationtype.location_type_id;
     }
     catch (Exception)
     {
         throw new Exception("Kunde inte lägga till platstypen(säkerställ att ingen platstyp med namnet redan finns.)");
     }
 }
        public void Update(LocationType oldLocationType, LocationType newLocationType)
        {
            try
            {
                oldLocationType.location_type_swe = newLocationType.location_type_swe;
                oldLocationType.location_type_eng = newLocationType.location_type_eng;
                oldLocationType.icon_id = newLocationType.icon_id;

                this.Save();
            }
            catch (Exception)
            {
                throw new Exception("Kunde inte spara platsTypen");
            }
        }
 public static LocationTypeViewModel ToViewModel(LocationType locationType)
 {
     return new LocationTypeViewModel(locationType);
 }