예제 #1
0
        public void OnLogIn()
        {
            // validacija popunjenih polja
            this.Validate();

            if (this.IsValid)
            {
                string hashPassword = SecurityHandler.CreateHash(Password);
                using (var dbContext = new ClinicDBEntities())
                {
                    var user = dbContext.Korisniks.Where(korisnik => korisnik.Korisnicko_Ime == username && korisnik.Lozinka == password).FirstOrDefault();


                    if (user is Doktor)
                    {
                        var doktor = user as Doktor;
                        if (doktor.Uloga == DoctorType.DOCTOR_SPECIALIST.ToString())
                        {
                            DbContextHandler.Instance.Logging(Username, hashPassword);
                            MainWindowViewModel.ChangeViewCommand.Execute(ViewType.DOCTOR_SPECIALIST_VIEW);
                        }
                        else
                        {
                            DbContextHandler.Instance.Logging(Username, hashPassword);
                            MainWindowViewModel.ChangeViewCommand.Execute(ViewType.GENERAL_PRACTICIONER_VIEW);
                        }
                    }
                    else if (user is Pacijent)
                    {
                        DbContextHandler.Instance.Logging(Username, hashPassword);
                        MainWindowViewModel.ChangeViewCommand.Execute(ViewType.PATIENT_VIEW);
                    }
                }
            }
        }