コード例 #1
0
ファイル: Menu.cs プロジェクト: alisherKAK/classWork
        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
ファイル: AdminServices.cs プロジェクト: alisherKAK/classWork
        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();
            }
        }