Exemplo n.º 1
0
 public User FindUserByLoginAndPassword( string login, string password )
 {
     var passwordHash = HashUtils.GetStringHash( password );
     var userEntity = _dbContext.Users.FirstOrDefault( u => u.Login == login && u.PasswordHash == passwordHash );
     return _mapper.Map<User>( userEntity );
 }
Exemplo n.º 2
0
        protected override void Seed(SqliteDbContext context)
        {
            //  Users

            context.Users.Add(new UserEntity {
                Id = Guid.NewGuid().ToString(), Name = "admin", Login = "******", PasswordHash = HashUtils.GetStringHash("admin"), Role = Roles.Admin
            });

            context.Users.Add(new UserEntity
            {
                Id            = Guid.NewGuid().ToString(),
                Name          = "Ольга",
                Surname       = "Павлова",
                MiddleName    = "Степановна",
                PasswordHash  = HashUtils.GetStringHash("password"),
                ClinicName    = "Республиканский научно-практический центр «Кардиология»",
                ClinicAddress = "г. Минск",
                Position      = "Заведующая лабораторией артериальной гипертонии,\n" +
                                "кандидат медицинских наук, доцент,\n" +
                                "высшая категория по специальности кардиология".Replace("\n",
                                                                                        Environment.NewLine),
                Role  = Roles.Admin,
                Login = "******"
            });
            context.Users.Add(new UserEntity
            {
                Id            = Guid.NewGuid().ToString(),
                Name          = "Инна",
                Surname       = "",
                MiddleName    = "Викторовна",
                PasswordHash  = HashUtils.GetStringHash("password"),
                ClinicName    = "«30-я городская клиническая поликлиника»",
                ClinicAddress = "г. Минск",
                Position      = "Главврач",
                Role          = Roles.User,
                Login         = "******"
            });
            //  Patients

            var patients = ReadPatients();

            context.Patients.AddRange(patients);

            //  Load initial models from the JSON file stored in resources
            List <ClassificationModelEntity> models;

            try
            {
                var modelsJson = _resourceProvider.ReadAllResourceText("initial_models_data.json");
                models = JsonConvert.DeserializeObject <List <ClassificationModelEntity> >(modelsJson, new ClassificationModelEntityConverter());
            }
            catch (Exception)
            {
                models = new List <ClassificationModelEntity>();
            }

            //            var optimalCutOffCalculator = new OptimalCutOffCalculator(new PatientPropertyProvider());
            //
            //            foreach (var model in models)
            //            {
            //                model.OptimalCutOff = optimalCutOffCalculator.CalculateOptimalCutOff(model, patients);
            //            }

            context.ClassificationModels.AddRange(models);

            context.SaveChanges();
        }