public ActionResult Delete(int TodoId, int TaskId) { string Error = string.Empty; taskRepo.Delete(TaskId, out Error); return(RedirectToAction("Index", "Task", new { TodoId = TodoId })); }
public void Can_Delete() { var provider = new PetaPocoUnitOfWorkProvider(Logger); var unitOfWork = provider.GetUnitOfWork(); using (var repo = new TaskRepository(unitOfWork, CacheHelper, Logger, SqlSyntax)) { var created = DateTime.Now; var task = new Task(new TaskType("asdfasdf")) { AssigneeUserId = 0, Closed = false, Comment = "hello world", EntityId = -1, OwnerUserId = 0 }; repo.AddOrUpdate(task); unitOfWork.Commit(); repo.Delete(task); unitOfWork.Commit(); task = repo.Get(task.Id); Assert.IsNull(task); } }
public async System.Threading.Tasks.Task TaskRepository__DeleteTask__WithObtainedComponents() { var options = GetDbContextOptions(); // Arrange await using (var context = GetDdContext(options)) { await InitDbContext(context); } // Act await using (var context = GetDdContext(options)) { var repository = new TaskRepository(context); repository.Delete(new Task { Id = 1 }); await repository.SaveAsync(); var task = await context.Tasks.FirstOrDefaultAsync(); var obtainedMontage = await context.ObtainedMontages.FirstOrDefaultAsync(); var obtainedDesign = await context.ObtainedDesigns.FirstOrDefaultAsync(); // Assert Assert.Null(task); Assert.Null(obtainedDesign); Assert.Null(obtainedMontage); } }
public void DeleteTest() { // Arrange var newTask1 = new Task { Title = "Call mum", Completed = false }; var newTask2 = new Task { Title = "Water flowers", Completed = false }; taskRepository.Clear(); taskRepository.Save(newTask1); taskRepository.Save(newTask2); // Assert Assert.AreEqual(2, taskRepository.GetAll().Count()); // Act taskRepository.Delete(newTask2); // Assert Assert.AreEqual(1, taskRepository.GetAll().Count()); Assert.IsNull(taskRepository.GetAll().SingleOrDefault(t => t.Id == newTask2.Id)); Assert.IsNotNull(taskRepository.GetAll().SingleOrDefault(t => t.Id == newTask1.Id)); }
public async System.Threading.Tasks.Task TaskRepository__DeleteTask__WithoutObtainedComponents() { var options = GetDbContextOptions(); // Arrange await using (var context = GetDdContext(options)) { context.Tasks.Add(new Task { Id = 1, Description = "name" }); await context.SaveChangesAsync(); } // Act await using (var context = GetDdContext(options)) { var repository = new TaskRepository(context); repository.Delete(new Task { Id = 1 }); await repository.SaveAsync(); var montage = await context.Tasks.FirstOrDefaultAsync(); // Assert Assert.Null(montage); } }
public ActionResult TaskDelete(int id) { Task Ts = _repo.getSingle(id); _repo.Delete(Ts); return(RedirectToAction("Index")); }
// DELETE: api/ProjTask/5 public void Delete(int id) { ProjTask e = new ProjTask(); e.tid = id; TaskRepository.Delete(id); }
private void Delete() { Console.Clear(); Console.Write("Task ID: "); int id = int.Parse(Console.ReadLine()); TaskRepository taskRepo = new TaskRepository(); Task task = taskRepo.GetByID(id); if (task == null) { Console.WriteLine("Task not found!"); Console.ReadKey(true); return; } else if (task.CreatorID == AuthenticationService.LoggedUser.ID || task.ResponsibleID == AuthenticationService.LoggedUser.ID) { taskRepo.Delete(task); Console.WriteLine("Task successfully deleted!"); } else { Console.WriteLine("You are not allowed to delete this task!"); Console.ReadKey(true); return; } Console.ReadKey(true); }
public ActionResult Delete(long id) { var taskRepo = new TaskRepository(); taskRepo.Delete(id); return(RedirectToAction("Index")); }
async void Delete() { var repo = new TaskRepository(); await repo.Delete(Todo); MessagingCenter.Send <TodoItemViewModel, Todo>(this, "Deleted", Todo); await Navigation.PopAsync(); }
public IActionResult Delete(int id) { var projectTasks = _taskRepository.GetTasksByProject(id); projectTasks.ForEach(pt => _taskRepository.Delete(pt.id)); _projectRepository.Delete(id); return(NoContent()); }
public ActionResult Delete(Task task) { if (task != null && task.TaskID > 0) { taskRep.Delete(task.TaskID); } return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { var taskTaskNotes = _taskNoteRepository.GetTaskNotesByTaskId(id); taskTaskNotes.ForEach(ttn => _taskNoteRepository.Delete(ttn.id)); _taskRepository.Delete(id); return(NoContent()); }
public void Handle(TaskFinishedEvent args) { _taskRepository.Delete(args.Task.Id); var hubContext = GlobalHost.ConnectionManager.GetHubContext <TaskSchedulerHub>(); var originalfilename = Path.GetFileName(args.Task.OriginalFile); var filename = Path.GetFileNameWithoutExtension(originalfilename) + ".mp4"; var directory = Path.GetDirectoryName(args.Task.OutputFile); var folders = directory.Split('\\'); var folder = ""; switch (args.Task.TaskType) { case TaskType.Presentation: folder = ConfigurationManager.AppSettings["PresentationsFolder"]; break; case TaskType.Video: folder = ConfigurationManager.AppSettings["VideosFolder"]; break; } string userId = folders[folders.Length - 1]; string virtualPath = folder + @"/" + userId + @"/" + filename; Medium medium = null; switch (args.Task.TaskType) { case TaskType.Video: medium = Movie.Create(Path.GetFileNameWithoutExtension(originalfilename), DateTime.Now, DateTime.MaxValue, 0, virtualPath); medium.CreatedBy = userId; medium.ModifiedBy = userId; _mediaRepository.Insert(medium); break; case TaskType.Presentation: medium = Presentation.Create(Path.GetFileNameWithoutExtension(originalfilename), DateTime.Now, DateTime.MaxValue, 0, virtualPath); medium.CreatedBy = userId; medium.ModifiedBy = userId; _mediaRepository.Insert(medium); break; } File.Delete(args.Task.InputFile); hubContext.Clients.All.finishTask(medium.Id.ToString(), virtualPath, originalfilename, medium.Title); EventLog eventLog = new EventLog() { Source = "EyeBoard Scheduler", Log = "EyeBoard Management" }; eventLog.WriteEntry("Task finished: " + args.Task.OutputFile, System.Diagnostics.EventLogEntryType.Information, 1004); }
private async void Remove(object obj) { var todo = (Todo)obj; TaskRepository repo = new TaskRepository(); if (await repo.Delete(todo)) { TodoList.Remove(todo); } }
public ActionResult DeleteTask(int id) { var result = _repo.Delete(id); if (result) { TempData["SuccessMessage"] = "Task Deleted!"; } return(RedirectToAction("ViewTasks")); }
public void Delete_Void_ReturnNull() { _task.Id = _taskRepository.Create(_task); var result = _taskRepository.Get(_task.Id); AreEqualTasks(result, _task); _taskRepository.Delete(_task.Id); result = _taskRepository.Get(_task.Id); Assert.IsNull(result); }
// DELETE api/<controller>/5 public IHttpActionResult Delete(int id) { if (repo.FindbyId(id) == null) { return(NotFound()); } else { repo.Delete(id); return(Ok()); } }
public static bool DeleteTask(int taskId) { var taskRepo = new TaskRepository(); var dbtask = taskRepo.Get(taskId); if (dbtask != null) { taskRepo.Delete(dbtask); return(true); } return(false); }
public void Delete(Task task) { using (var session = _nhSessionDb.ReadAndWrite()) { using (var transaction = session.BeginTransaction()) { var _taskRepository = new TaskRepository(session); _taskRepository.Delete(task); transaction.Commit(); } } }
public ActionResult DeleteTask(int id) { if (AuthenticationManager.LoggedUser == null) { return(RedirectToAction("Login", "Home")); } TaskRepository taskrepo = RepositoryFactory.GetTaskRepository(); Task task = taskrepo.GetByID(id); taskrepo.Delete(task); return(RedirectToAction("Index", "ContactsManager")); }
public IActionResult Delete(int id) { try { var userId = User.GetUserId(); _taskRepository.Delete(id, userId); } catch (Exception ex) { //logowanie do pliku return(Json(new { succes = false, message = ex.Message })); } return(Json(new { succes = true })); }
public ActionResult Delete(int id) { if (AuthenticationManager.LoggedUser == null) { return(RedirectToAction("Login", "Home")); } TaskRepository Repo = RepositoryFactory.GetTaskRepository(); Task task = Repo.GetById(id); Repo.Delete(task); return(RedirectToAction("Index", "TaskManagement")); }
public IHttpActionResult Delete([FromUri] int projectId) { ProjectsRepository projectsRepository = new ProjectsRepository(Connection, User); Project project = projectsRepository.Find(projectId); if (project == null) { return(BadRequest("Projeto não encontrado.")); } TaskRepository taskRepository = new TaskRepository(Connection); taskRepository.Delete(projectId); return(Ok()); }
public ActionResult ConfirmDelete(string id) { TaskModel taskToDelete = context.Find(id); if (taskToDelete == null) { return(HttpNotFound()); } else { context.Delete(id); context.Commit(); return(RedirectToAction("Index")); } }
public HttpResponseMessage Delete(int id) { try { TaskRepository.Delete(id); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (ElementNotFoundException e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Generic error happened.")); } }
private void Run() { var queries = new QueryProcessor(_repo); Set_up_request_handling_processes(); var tasks = queries.Query(""); _ui.Display(tasks); _ui.Show(); void Set_up_request_handling_processes() { _ui.OnQueryTasksRequest += query => { var queryResult = queries.Query(query); _ui.Display(queryResult); }; _ui.OnEditTaskRequest += taskId => { var task = _repo.Tasks.First(t => t.Id == taskId); if (_ui.AllowUserToEditTask(ref task)) { _repo.Save(task); _ui.DisplayUpdate(task); } }; _ui.OnNewTaskRequest += () => { if (_ui.AskUserForNewTask(out var newTask)) { var taskId = _repo.Save(newTask); newTask.Id = taskId; _ui.DisplayUpdate(newTask); } }; _ui.OnDeleteTaskRequest += taskId => { _repo.Delete(taskId); var queryResult = queries.Requery(); _ui.Display(queryResult); }; } } }
public Result TaskDel([FromForm] int Id) { try { if (!GetAccess(User.Id, Id, HandleAccess.DeleteTask)) { return(Fail("您还未拥有权限操作")); } var task = _manager.GetTasks(n => n.Id == Id).FirstOrDefault(); if (task != null && task.IsRuning) { return(Fail("删除失败,程序正在运行,请先停止程序")); } _repository.DbContext.Database.BeginTransaction(); if (_repository.Delete(n => n.Id == Id) <= 0) { _repository.DbContext.Database.RollbackTransaction(); return(Fail("删除失败")); } var path = _config.TaskAppPath + task.TaskGuid.ToString("N"); if (Directory.Exists(path)) { try { Directory.Delete(path, true); } catch (Exception ex) { _repository.DbContext.Database.RollbackTransaction(); _logger.LogError(ex.Message + ex.StackTrace); return(Fail("删除失败, 删除文件夹(" + path + ")失败!")); } } _repository.DbContext.Database.CommitTransaction(); _manager.Remove(task); return(Success(null, "删除成功")); } catch (Exception ex) { _logger.LogError(ex.Message + ex.StackTrace); return(Fail("系统错误")); } }
public async Task <IHttpActionResult> DeleteTask(int id) { var task = _repo.Find(id); if (task == null) { return(NotFound()); } try { _repo.Delete(task); return(Ok(task)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void TaskTestsAllInOneMethod() { using (TransactionScope scope = new TransactionScope()) { var fixture = new Fixture(); var autoTask = fixture.Create <Task>(); ITaskRepository tRep = new TaskRepository(); tRep.Save(autoTask); var insertedTask = tRep.GetById(autoTask.TaskId); Assert.AreEqual(insertedTask.TaskName, autoTask.TaskName); IEnumerable <Task> tList = tRep.GetAll().Where(v => v.TaskId == autoTask.TaskId); Assert.AreEqual(tList.Count(), 1); tRep.Delete(autoTask); var deletedTask = tRep.GetById(autoTask.TaskId); Assert.IsNull(deletedTask); } }
/// <summary> /// 删除指定任务编号的任务 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns>返回删除是否成功</returns> public bool DeleteTask(string taskNumber) { task task = FindByTaskNumber(taskNumber); if (task == null || new FeedService().FindByTaskId(task.Id).Count > 0 || new FodderTakeService().FindByTaskId(task.Id).Count > 0 || new TransferService().FindByTaskId(task.Id).Count > 0 || new PreventionService().FindByTaskId(task.Id).Count > 0 || new InspectionService().FindByTaskId(task.Id).Count > 0 || new SaleService().FindByTaskId(task.Id).Count > 0) { return false; } var cureMethodService = new CureMethodService(); cure_task_course cureCourse = task.cure_task_course.FirstOrDefault(); if (cureCourse != null && cureMethodService.FindByCureTaskCourseId(cureCourse.Id).Count > 0) { return false; } var saleTaskQualityService = new SaleTaskQualityService(); foreach (sale_task_quality delItem in task.sale_task_quality) { saleTaskQualityService.Delete(saleTaskQualityService.Find(delItem.Id)); } var transferTaskPigService = new TaskPigService(); foreach (task_pig transferTaskPig in task.task_pig) { transferTaskPigService.Delete(transferTaskPigService.Find(transferTaskPig.Id)); } var taskIntervalCycleService = new TaskIntervalCycleService(); foreach (task_interval_cycle item in task.task_interval_cycle) { taskIntervalCycleService.Delete(taskIntervalCycleService.Find(item.Id)); } var taskPigstyService = new TaskPigstyService(); var feedTaskQualityService = new FeedTaskQualityService(); foreach (task_pigsty item in task.task_pigsty) { foreach (feed_task_quality delItem in item.feed_task_quality) { feedTaskQualityService.Delete(feedTaskQualityService.Find(delItem.Id)); } taskPigstyService.Delete(taskPigstyService.Find(item.Id)); } var taskEmployeeService = new TaskEmployeeService(); foreach (task_employee item in task.task_employee) { taskEmployeeService.Delete(taskEmployeeService.Find(item.Id)); } var cureTaskCourseService = new CureTaskCourseService(); var cureTaskMethodService = new CureTaskMethodService(); var cureTaskMedicineService = new CureTaskMedicineService(); foreach (cure_task_course cureTaskCourse in task.cure_task_course) { foreach (cure_task_method cureTaskMethod in cureTaskCourse.cure_task_method) { foreach (cure_task_medicine cureTaskMedicine in cureTaskMethod.cure_task_medicine) { cureTaskMedicineService.Delete(cureTaskMedicineService.Find(cureTaskMedicine.Id)); } cureTaskMethodService.Delete(cureTaskMethodService.Find(cureTaskMethod.Id)); } cureTaskCourseService.Delete(cureTaskCourseService.Find(cureTaskCourse.Id)); } var taskPreventionService = new TaskPreventionService(); foreach (task_prevention taskPrevention in task.task_prevention) { taskPreventionService.Delete(taskPreventionService.Find(taskPrevention.Id)); } var taskPigHouseService = new TaskPigHouseService(); foreach (task_pighouse taskPighouse in task.task_pighouse) { taskPigHouseService.Delete(taskPigHouseService.Find(taskPighouse.Id)); } var taskRepository = new TaskRepository(); taskRepository.Delete(taskRepository.Find(task.Id)); return true; }