public override void ExtraDelete(User user) { TaskRepo repoTask = new TaskRepo(); LogWorkRepo repoWork = new LogWorkRepo(); CommentRepo repoComment = new CommentRepo(); List <Task> tasks = repoTask.GetAll(t => t.creatorId == user.Id).ToList(); List <Comment> comments = repoComment.GetAll().ToList(); List <LogWork> works = repoWork.GetAll().ToList(); foreach (Task item in tasks) { foreach (Comment comment in comments) { if (comment.taskId == item.Id) { repoComment.Delete(comment); } } foreach (LogWork work in works) { if (work.TaskId == item.Id) { repoWork.Delete(work); } } repoTask.Delete(item); } }
public ActionResult Delete(string Id) { try { _db.Delete(Id); return(View("List", _db.getAll().Where(x => x.ApplicationUserId == User.Identity.GetUserId()).ToList())); } catch (Exception ex) { return(View("List", _db.getAll().Where(x => x.ApplicationUserId == User.Identity.GetUserId()).ToList())); } }
protected override void Delete() { Console.Clear(); All(); Console.WriteLine("*** CHOOSE BY ID WHO TO DELETE ***"); Console.Write(" ID: "); int id = int.Parse(Console.ReadLine()); TaskRepo repo = new TaskRepo("tasks.txt"); repo.Delete(repo.GetById(id)); Console.Clear(); Console.WriteLine("*******************************"); Console.WriteLine("********* COMPLETED!!! ********"); Console.WriteLine("*******************************"); Thread.Sleep(1500); }
private void tsMainDelete_Click(object sender, EventArgs e) { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { DialogResult result = MessageBox.Show("Are you sure you want to delete this item", "Delete item", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { TaskRepo edd = new TaskRepo(); MTasks user = (MTasks)tasksBindingSource1.Current; edd.Delete(user); SetDataSources(); } } }
protected override void DeleteFilter(int id) { TaskRepo taskRepository = RepositoryFactory.GetTasksRepository(); List <Task> tasks = taskRepository.GetAll().FindAll(task => task.UserId == id && task.ResponsibleUser == id); foreach (var task in tasks) { taskRepository.Delete(task); } List <Task> tasksRespU = taskRepository.GetAll(); foreach (var task in tasksRespU) { if (task.ResponsibleUser == AuthenticationManager.LoggedUser.Id) { task.UserId = AuthenticationManager.LoggedUser.Id; taskRepository.Save(task); } } CommentRepo comRepository = RepositoryFactory.GetCommentsRepository(); List <Comment> comments = comRepository.GetAll().FindAll(com => com.CreatedBy == id); foreach (var com in comments) { comRepository.Delete(com); } LoggedWorkRepo loggedWorkRepo = RepositoryFactory.GetLoggedWorksRepository(); List <LoggedWork> loggedWorks = loggedWorkRepo.GetAll().FindAll(lw => lw.UserId == id); foreach (var lw in loggedWorks) { loggedWorkRepo.Delete(lw); } }