private void LoginUser(object sender, RoutedEventArgs e) { string username = users.Text; string salt; using (var ctx = new FiscalDbContext()) { salt = ctx.Set <Serviceman>(). Where(x => x.Name + " " + x.Surname == username). Select(x => x.Salt). FirstOrDefault(); } var hashedPassword = SHA256Hasher(passwd.Password, salt); if (IsPasswordValid(username, hashedPassword)) { using (var ctx = new FiscalDbContext()) { LoggedUser = ctx.Set <Serviceman>(). Where(x => x.Name + " " + x.Surname == username). FirstOrDefault(); } GoToMainWindow(username); } else { // WriteLoginFailedMessage(); } }
public MainWindow(Serviceman user, Window w) { InitializeComponent(); loginWindow = w; this.Language = XmlLanguage.GetLanguage("pl-PL"); this.Closed += CloseLoginWindow; this.DataContext = new MainViewModel(user); }
public MainViewModel(Serviceman user) { LoggedUser = user; LoggedInformation = "Zalogowano jako: " + user.NameAndSurname; // Init navigation lists PreviousUserControls = new List <UserControl>(); NextUserControls = new List <UserControl>(); // Default value AllClients ac = new AllClients(SetUserControl); ac.Tag = "Clients"; UserControl = ac; }
/// <summary> /// Get all done services from db context /// </summary> public ObservableCollection <Service> GetServicesWhichBelongToServiceman(Serviceman s) { ObservableCollection <Service> doneServices; using (var context = (Context == null ? new FiscalDbContext() : Context)) { var query = (from service in context.Set <Service>() join device in context.Set <Device>() on service.Device.ID equals device.ID join repgroup in context.Set <RepairGroup>() on device.ID equals repgroup.Device.ID where repgroup.Serviceman.ID == s.ID select service).Include("Device"). Include("Device.Place"). Include("Device.Client"). Include("TypeOfService").ToList(); doneServices = new ObservableCollection <Service>(query); } return(doneServices); }
/// <summary> /// Прийти на склад /// </summary> /// <param name="serviceman">Военнослужащий</param> /// <param name="countArmor">Кол-во брони на складе</param> /// <param name="countFood">Кол-во еды на складе</param> /// <param name="countWeapon">Кол-во оружия на складе</param> public ProxyStock(Serviceman serviceman, int countArmor, int countFood, int countWeapon) { this.stock = new Stock(countArmor, countFood, countWeapon); this.rank = serviceman.rank; }
public PlannedServicesViewModel(Func <UserControl, int> ucSetMethod, Serviceman serviceman) : base(ucSetMethod) { loggedUser = serviceman; EntitySearcher.Collection = GetDataFromDB(); }
public DoneServicesViewModel(Func <UserControl, int> ucSetMethod, Serviceman user) : base(ucSetMethod) { serviceman = user; EntitySearcher.Collection = GetDataFromDB(); ShowServicesButtonName = "Wszystkie"; }
public PlannedServices(Func <UserControl, int> ucSetMethod, Serviceman serviceman) { InitializeComponent(); this.DataContext = new PlannedServicesViewModel(ucSetMethod, serviceman); }
public DoneServices(Func <UserControl, int> ucswitcher, Serviceman user) { InitializeComponent(); this.DataContext = new DoneServicesViewModel(ucswitcher, user); }