Пример #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("Зарегистрированно");
                    }
                }
            }
        }
Пример #2
0
        public static void CreateMagazine()
        {
            Magazine newMagazine = new Magazine()
            {
                Name        = SetInformation.SetName(),
                Theme       = SetInformation.SetTheme(),
                DateOfIssue = DateTime.Now
            };

            using (var context = new MagazineContext())
            {
                context.Magazines.Add(newMagazine);
                context.SaveChanges();
            }
        }
Пример #3
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());
            }
        }