public OptionDemandeVueModel(DemandeOption dOpt) { service = Services.OptionService.Instance; Opt = dOpt; OptionVueModels = new ObservableCollection <OptionVueModel>(); List <Option> options = service.GetOptions(); foreach (Option option in options) { OptionVueModel optionVue = new OptionVueModel(option); OptionVueModels.Add(optionVue); } observerOption = CollectionViewSource.GetDefaultView(OptionVueModels); OptionVueModel current = (from opt in OptionVueModels where opt.opt.NumOption == dOpt.IdOption select opt).SingleOrDefault <OptionVueModel>(); if (current == null) { observerOption.MoveCurrentToFirst(); } else { observerOption.MoveCurrentTo(current); } observerOption.CurrentChanged += CurrentChangedOption; }
public void AddDemandeOption(DemandeOption opt) { using (Entities.AppContext context = new Entities.AppContext()) { context.DemandeOptions.Add(opt); context.SaveChanges(); } }
public bool CheckData(DemandeOption option) { using (Entities.AppContext context = new Entities.AppContext()) { DemandeOption Dopt = (from opt in context.DemandeOptions where (opt.IdChambreReservee == option.IdChambreReservee) && (opt.IdOption == option.IdOption) select opt).SingleOrDefault <DemandeOption>(); return(Dopt != null); } }
public void UpdateDemandeOption(DemandeOption option) { using (Entities.AppContext context = new Entities.AppContext()) { DemandeOption optionToSave = (from opt in context.DemandeOptions where (opt.IdChambreReservee == option.IdChambreReservee) && (opt.IdOption == option.IdOption) select opt).SingleOrDefault <DemandeOption>(); optionToSave.IdOption = option.IdOption; optionToSave.IdChambreReservee = option.IdChambreReservee; optionToSave.NbJour = option.NbJour; context.SaveChanges(); } }
private void addOption() { DemandeOption dOpt = new DemandeOption(); dOpt.NbJour = 0; dOpt.IdChambreReservee = ID; OptionDemandeVueModel optVM = new OptionDemandeVueModel(dOpt); optVM.suppresion += SupprimerOption; ListeDemandeOptions.Add(optVM); NotifyPropertyChanged(); }
public void RemoveOption(DemandeOption option) { using (Entities.AppContext context = new Entities.AppContext()) { try { DemandeOption optionToRemove = (from opt in context.DemandeOptions where (opt.IdChambreReservee == option.IdChambreReservee) && (opt.IdOption == option.IdOption) select opt).SingleOrDefault <DemandeOption>(); if (optionToRemove != null) { context.DemandeOptions.Remove(optionToRemove); context.SaveChanges(); } } catch (Exception e) { return; } } }