예제 #1
0
        public static Person AutorizeConfirm(string login, string password)
        {
            Person person;

            using (var ctx = new MusicContext("MusicContext"))
            {
                person = ctx.Persons.FirstOrDefault(p => p.Login == login);
            }

            return((person != null && person?.Password == password) ? person : null);
        }
예제 #2
0
        public static Person PersonLoginExists(string login)
        {
            Person person;

            using (var ctx = new MusicContext("MusicContext"))
            {
                person = ctx.Persons.FirstOrDefault(p => p.Login == login);
            }

            return(person);
        }
예제 #3
0
        public static Person PersonEmailExists(string email)
        {
            Person person;

            using (var ctx = new MusicContext("MusicContext"))
            {
                person = ctx.Persons.FirstOrDefault(p => p.Email == email);
            }

            return(person);
        }
예제 #4
0
        protected override void Seed(MusicContext context)
        {
            var roles = new List <Role>()
            {
                new Role()
                {
                    Id = 1, Name = "Admin"
                },
                new Role()
                {
                    Id = 2, Name = "User"
                }
            };

            roles.ForEach(role => context.Roles.Add(role));
            context.SaveChanges();
        }
예제 #5
0
        public static void UpdatePassword(Person user)
        {
            using (var ctx = new MusicContext("MusicContext"))

            {
                ctx.Persons.Attach(user);
                var entry = ctx.Entry(user);
                entry.Property(x => x.Password).IsModified = true;
                try
                {
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    throw new Exception();
                }
            }
        }
예제 #6
0
        public static void CreatePerson
            (string firstName, string secondName, string login, string email, string password, DateTime dateOfBirth)
        {
            Person person = new Person()
            {
                FirstName   = firstName,
                SecondName  = secondName,
                Email       = email,
                Password    = password,
                Login       = login,
                DateOfBirth = dateOfBirth
            };

            using (var ctx = new MusicContext("MusicContext"))
            {
                ctx.Persons.Add(person);
                ctx.SaveChanges();
            }
        }