public AddSubscriberViewModel() { TypeOfOffer = new ObservableCollection <tariff>(); SaveCommand = new SimpleRelayCommand(Save); using (SubscriptionContext context = new SubscriptionContext()) { foreach (tariff t in context.tariffs) { TypeOfOffer.Add(t); } } using (SubscriptionContext context = new SubscriptionContext()) { var result = (from s in context.subscriptions orderby s.subscriptionId descending select s).FirstOrDefault(); if (result == null) { SubscriptionId = "A1000"; } else { SubscriptionId = (result.subscriptionId + 1).ToString(); } } }
public RentTabViewModel() { RentDateStart = DateTime.Now; RentDateEnd = DateTime.Now; CalculateCommand = new SimpleRelayCommand(Calculate); RentCommand = new SimpleRelayCommand(Rent); CollectionOfDevices = new ObservableCollection <device>(); //dadanie urządzeń do listy urządzeń wyświetlanych na liście dostępnych do wypozyczenia using (SubscriptionContext context = new SubscriptionContext()) { //var result = (from d in context.devices select d).ToList(); //porównanie daty zwrotu z datą dzisiejszą, //jeśli dzisiaj powinien być oddany to będzie już dostępny na liście foreach (rent r in context.rents) { if (r.date_of_return < DateTime.Now || r.date_of_rent > DateTime.Now) { //pobranie z listy wypozyczen-urzadzen urządzenie, ktore jest aktualanie niezajęte var result2 = (from dr in context.devices_rents where r.rentId == dr.rent_id select dr.device).First(); //zmienna tymczasowa potrzebna do zaktualizowania statusu wypozyczenia device deviceToChangeIsRentedStatus = (device)result2; //context.devices.Attach(deviceToChangeIsRentedStatus); deviceToChangeIsRentedStatus.is_rented = false; } } context.SaveChanges(); var result = (from d in context.devices select d).ToList(); //odrzucenie urządzeń ktore sa aktualnie wypozyczone foreach (device dev in result) { if (!dev.is_rented) { CollectionOfDevices.Add(dev); } } } }
public DeleteDeviceViewModel() { CollectionOfDevices = new ObservableCollection <device>(); using (SubscriptionContext context = new SubscriptionContext()) { try { foreach (device dev in context.devices) { CollectionOfDevices.Add(dev); } } catch (Exception e) { File.AppendAllText(MainWindowViewModel.PathToLog, e.ToString()); } } SelectDeviceCommand = new SimpleRelayCommand(SelectDevice); }
public SubscriptionViewModel() { SubscriptionFunctionality = new ObservableCollection <SubscriptionViewModelBase>(); SubscriptionFunctionality.Add(new AddSubscriberViewModel()); SubscriptionFunctionality.Add(new AddTariffViewModel()); SubscriptionFunctionality.Add(new AddDeviceViewModel()); SubscriptionFunctionality.Add(new EditDeviceViewModel()); SubscriptionFunctionality.Add(new DeleteDeviceViewModel()); SearchCommand = new SimpleRelayCommand(Search); CollectionOfClients = new ObservableCollection <subscription>(); ListOfSearchingParameters = new List <string>(); ListOfSearchingParameters.Add("Nazwa klienta"); ListOfSearchingParameters.Add("Nr abonamentu"); ListOfSearchingParameters.Add("NIP"); ListOfSearchingParameters.Add("Nazwisko"); ListOfSearchingParameters.Add("Adres e-mail"); }
public AddDeviceViewModel() { SaveCommand = new SimpleRelayCommand(Save); Title = "DODAWANIE URZĄDZENIA"; }
public TariffViewModel() { SaveTariffCommand = new SimpleRelayCommand(SaveTariff); }