Beispiel #1
0
        public static void RegistrationMenu()
        {
            Console.WriteLine("===========\n" +
                              "РЕГИСТРАЦИЯ\n" +
                              "===========");

            Person newPerson = new Person()
            {
                Name        = SetInformation.SetName(),
                Surname     = SetInformation.SetSurname(),
                Address     = SetInformation.SetAddress(),
                PhoneNumber = SetInformation.SetPhoneNumber()
            };

            User newUser = new User()
            {
                Login    = SetInformation.SetLogin(),
                Password = SetInformation.SetPassword(),
                Person   = newPerson
            };

            using (var context = new MagazineContext())
            {
                if (!context.People.Contains(newPerson))
                {
                    if (!context.Users.Contains(newUser))
                    {
                        context.Users.Add(newUser);
                        context.SaveChanges();

                        Console.WriteLine("Зарегистрированно");
                    }
                }
            }
        }
Beispiel #2
0
        public static User Entry()
        {
            Console.WriteLine("====" +
                              "ВХОД\n" +
                              "====");
            Console.WriteLine("Введите логин:");
            string login = SetInformation.SetLogin();

            Console.WriteLine("Введите пароль:");
            string password = SetInformation.SetLogin();

            using (var context = new MagazineContext())
            {
                return(context.Users.Where(user => user.Login == login && user.Password == password).SingleOrDefault());
            }
        }