private void SendButton(object sender, RoutedEventArgs e)
        {
            var prints     = new List <Print>();
            var deliveries = new List <Delivery>();

            using (var context = new NomadContext())
            {
                var journalForPrint = context.Journals.Where(journal => journal.FullName.Contains("Апрель")).FirstOrDefault();
                var subscribeUsers  = context.Users.Where(user => user.Subscribe == true).Where(user => user.Delivered == false).ToList();

                prints.Add(new Print {
                    JournalId = journalForPrint.Id, Edition = subscribeUsers.Count()
                });
                context.Prints.AddRange(prints);

                foreach (var idUsers in subscribeUsers)
                {
                    deliveries.Add(new Delivery {
                        JournalId = journalForPrint.Id, Status = true, UserId = idUsers.Id
                    });
                    for (int i = 0; i < context.Users.ToList().Count; i++)
                    {
                        if (context.Users.ToList()[i].Id == idUsers.Id)
                        {
                            context.Users.ToList()[i].Delivered = true;
                        }
                    }
                }
                context.Deliveries.AddRange(deliveries);
                context.SaveChanges();
            }
        }
        private void SubscribeButtonForDatabase(object sender, RoutedEventArgs e)
        {
            string name;

            if (nameSub.Text.Length == 0)
            {
                MessageBox.Show("Норм введи");
                return;
            }
            else
            {
                name = nameSub.Text;
            }

            string adress;

            if (adressSub.Text.Length == 0)
            {
                MessageBox.Show("Норм введи");
                return;
            }
            else
            {
                adress = adressSub.Text;
            }


            if (yearSub.SelectedItem == null)
            {
                MessageBox.Show("норм введи");
                return;
            }

            using (var context = new NomadContext())
            {
                var user = new User
                {
                    FullName = name, Adress = adress, Subscribe = true, Delivered = false, TimeSubscribe = _year
                };
                context.Users.Add(user);
                context.SaveChanges();
            }

            MessageBox.Show("все подписался");

            Close();
        }
        private void UnsubscribeButtonForDatabase(object sender, RoutedEventArgs e)
        {
            string name;

            if (nameText.Text.Length == 0)
            {
                MessageBox.Show("Норм введи");
                return;
            }
            else if (!CheckInName(nameText.Text))
            {
                MessageBox.Show("нету или уже отписан");
                return;
            }
            else
            {
                name = nameText.Text;
            }

            using (var context = new NomadContext())
            {
                var userUnsub = context.Users.Where(user => user.FullName == name).Where(user => user.Subscribe == true).FirstOrDefault();

                for (int i = 0; i < context.Users.Count(); i++)
                {
                    if (context.Users.ToList()[i].Id == userUnsub.Id)
                    {
                        context.Users.ToList()[i].Subscribe = false;
                    }
                }
                context.SaveChanges();
            }

            MessageBox.Show("отписался.. зряяя");

            Close();
        }