public void Delete(Asset asset)
 {
     try
     {
         assetRepository.Delete(asset);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public Asset SelectAsset(Asset entity)
 {
     try
     {
         return assetRepository.SelectAsset(entity);
             
     }
     catch (Exception)
     {
         
         throw;
     }
 }
 public bool Delete(Asset entity)
 {
     try
     {
         using (var session = NHibernateHelper.OpenSession(connString))
         {
             session.Delete(entity);
             session.Flush();
             return true;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void Update(Asset entity)
        {
            try
            {
                using (var session = NHibernateHelper.OpenSession(connString))
                {
                    session.Update(entity);
                    session.Flush();
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public bool Add(Asset entity)
        {
            try
            {
                using (var session = NHibernateHelper.OpenSession(connString))
                {
                    session.Save(entity);

                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                using (IAssetComponent assetservice = new AssetComponent())
                {
                   Asset myasset = new Asset();
                  myasset.ID = int.Parse(txtassetID.Text);
                  myasset = assetservice.SelectAsset(myasset);
                  txtroomid.Text = myasset.RoomID.ToString();
                  txtname.Text = myasset.Name;
                  CheckBox1.Checked = myasset.IsEnabled;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
       public void Save(Asset asset)
       {
           try
           {

               if (asset.ID == 0)
               {
                   assetRepository.Add(asset);
               }
               else
               {
                   assetRepository.Update(asset);
               }

           }
           catch (Exception ex)
           {
               throw ex;
           }
       }
        public AssetsFormViewModel()
            : base()
        {
            _assetService = new AssetServiceClient();
            _roomService = new RoomServiceClient();

            _currentAsset = new Asset();

            var rooms = _roomService.GetList(false);
            _allRoomOptions = new ObservableCollection<RoomComboBoxItem>()
                {
                    new RoomComboBoxItem() { Room = null }
                };
            foreach (var room in rooms)
            {
                _allRoomOptions.Add(new RoomComboBoxItem() { Room = room });
            }
            RaisePropertyChanged("RoomOptions");

            SaveAssetCommand = new RelayCommand(this.SaveAsset,
                () => IsValid);
        }
 public Asset SelectAsset(Asset entity)
 {
     try
     {
         using (var session = NHibernateHelper.OpenSession(connString))
         {
             var asset = session.QueryOver<Asset>().Where(x => x.ID == entity.ID).SingleOrDefault();
             return asset;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }