Exemplo n.º 1
0
        private void AddArticle()
        {
            EmployeeValidation VM = new EmployeeValidation();
            bool correctForm      = VM.WikiValidation(Url, Description);

            if (correctForm)
            {
                Article article = new Article()
                {
                    Url         = _Url,
                    Description = _Description,
                    DateAdded   = DateTime.Now,
                    UserID      = Global.user.UserID
                };

                dbContext.Article.Add(article);
                dbContext.SaveChanges();

                Articles = new ObservableCollection <Article>(dbContext.Article);

                setVariableWhenAddArticle();

                ErrorMessage er = new ErrorMessage("Add article!");
                er.ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void AddTask()
        {
            EmployeeValidation EV = new EmployeeValidation();
            bool correctForm      = EV.AddTaskValidation(Name, Description);

            if (correctForm)
            {
                PMSContext dbContext = new PMSContext();

                Subtask subtask = new Subtask
                {
                    Name            = _Name,
                    Description     = _Description,
                    StartTime       = DateTime.Now,
                    EndTime         = _EndTime,
                    MainTaskID      = null,
                    SubtaskStatusID = 1,
                    Priority        = _SelectedPriority,
                    UserID          = SelectedUser.UserID,
                    WhoCreated      = Global.user.UserID
                };


                RecentActivity ra = new RecentActivity
                {
                    DateAdded   = DateTime.Now,
                    TeamID      = (int)Global.user.TeamID,
                    Description = $"User {Global.user.FullName} has created a new task " +
                                  $"for {SelectedUser.FullName} called: {_Name}"
                };


                dbContext.Subtask.Add(subtask);
                dbContext.RecentActivity.Add(ra);
                dbContext.SaveChanges();


                setVariableWhenAddTask();

                ErrorMessage er = new ErrorMessage("Task created successfully!");
                er.ShowDialog();
            }
        }