示例#1
0
        public static EpicDbContext GetInstance()
        {
            if (_instance == null)
            {
                _instance = new EpicDbContext();
            }

            return(_instance);
        }
        private void CreateNewCardButton_Click(object sender, RoutedEventArgs e)
        {
            CheckData();

            if (isDataCorrect)
            {
                try
                {
                    using (var context = new EpicDbContext())
                    {
                        if (isDateEmpty)
                        {
                            Card card = new Card()
                            {
                                Title       = CardTitle.Text,
                                Status      = Status_ComboBox.SelectedIndex,
                                Description = Description.Text,
                                DeadLine    = null,
                                EpicId      = this.EpicId
                            };
                            context.Cards.Add(card);
                            context.SaveChanges();
                        }

                        else
                        {
                            Card card = new Card()
                            {
                                Title       = CardTitle.Text,
                                Status      = Status_ComboBox.SelectedIndex,
                                Description = Description.Text,
                                DeadLine    = dateTime,
                                EpicId      = this.EpicId
                            };
                            context.Cards.Add(card);
                            context.SaveChanges();
                        }

                        MessageBox.Show("Card succesfully added", "Done", MessageBoxButton.OK, MessageBoxImage.Information);
                    }

                    this.DialogResult = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        public ProfileWindow(int workId)
        {
            InitializeComponent();

            this.workId = workId;

            using (var context = new EpicDbContext())
            {
                var user = context.Users.Where(u => u.Id == this.workId).First();

                FullNickNameLabel.Content = user.FullName + $"({user.NickName})";
                EmailLabel.Content        = user.Email;
                GroupLabel.Content        = user.Group.Title;
            }
        }