private void AddExecutor(int UserId) { if (cardExecutors.Count < 5) { Executor executor = new Executor() { UserId = UserId, CardId = EpicOrCardId }; var changeExecutor = new ExecutorChange() { CardId = EpicOrCardId, OldExecutorId = null, NewExecutorId = UserId, Reason = ReasonTextBox.Text, Date = DateTime.Today }; context.ExecutorsChanges.Add(changeExecutor); context.Executors.Add(executor); } else { MessageBox.Show("There can't be more than five performers", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ReplaceExecutor(int UserId) { var changeExecutor = new ExecutorChange() { CardId = EpicOrCardId, OldExecutorId = ExecutorId, NewExecutorId = UserId, Reason = ReasonTextBox.Text, Date = DateTime.Today }; context.ExecutorsChanges.Add(changeExecutor); var cardExecutor = context.Executors.Where(ce => ce.UserId == ExecutorId).First(); cardExecutor.UserId = UserId; }
private void DeleteMaster_Click(object sender, RoutedEventArgs e) { if (purposeType == PurposeType.Epic) { var epic = context.Epics.Where(ep => ep.Id == EpicOrCardId).First(); epic.MasterId = null; MessageBox.Show("Epic Master successfully delete", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } else if (purposeType == PurposeType.Project) { var project = context.Projects.Where(ep => ep.Id == ProjectId).First(); project.MasterId = null; MessageBox.Show("Project Master successfully delete", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } else { var executor = context.Executors.Where(ce => ce.UserId == ExecutorId).First(); context.Executors.Remove(executor); var changeExecutor = new ExecutorChange() { CardId = EpicOrCardId, OldExecutorId = ExecutorId, NewExecutorId = null, Reason = ReasonTextBox.Text, Date = DateTime.Today }; context.ExecutorsChanges.Add(changeExecutor); MessageBox.Show("Card Executor successfully delete", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } this.DialogResult = true; context.SaveChanges(); }