예제 #1
0
        public void TaskCreatingWorks()
        {
            Guid userGuid    = Guid.NewGuid();
            Guid managerGuid = Guid.NewGuid();
            User user        = userRepositoriy.CreateUser(new User()
            {
                Id = userGuid, FirstName = "test_name", FamilyName = "test_family", MiddleName = "test_middlename", Level = UserLevel.Scaner, CreatedAt = DateTime.UtcNow, Login = "******", Password = "******"
            });
            User manager = userRepositoriy.CreateUser(new User()
            {
                Id = userGuid, FirstName = "test_manager_name", FamilyName = "test_manager_family", MiddleName = "test_manager_middlename", Level = UserLevel.Scaner, CreatedAt = DateTime.UtcNow, Login = "******", Password = "******"
            });

            Company company = companyRepositoriy.CreateCompany("Тест1");

            Business.Model.Inventorization inventarisation = inventorizationRepositoriy.CreateInventorization(company.Id, DateTime.UtcNow);
            Guid firstTaskId = Guid.NewGuid();

            taskRepository.CreateTask(firstTaskId, managerGuid, userGuid, inventarisation.Id);

            List <Business.Model.Task> tasks = taskRepository.GetTasks(userGuid, inventarisation.Id);

            Assert.IsNotNull(tasks);
            Assert.AreEqual(1, tasks.Count());

            taskRepository.DeleteTask(firstTaskId);
            inventorizationRepositoriy.DeleteInventorization(inventarisation.Id);
            companyRepositoriy.DeleteCompany(company.Id);
        }
예제 #2
0
        public void DeleteTask_Successful()
        {
            Task taskEdit = new Task();

            taskEdit.TaskId    = 1;
            taskEdit.TaskName  = "ABCD";
            taskEdit.StartDate = DateTime.Now;
            taskEdit.Priority  = 1;
            var tasks = new List <Task>();

            tasks.Add(taskEdit);
            var t = tasks.AsQueryable();
            //var mockSet = new Mock<DbSet<Task_Table>>();
            var mockSet = new Mock <DbSet <Task> >();

            mockSet.As <IQueryable <Task> >().Setup(m => m.Provider).Returns(t.Provider);
            mockSet.As <IQueryable <Task> >().Setup(m => m.Expression).Returns(t.Expression);
            mockSet.As <IQueryable <Task> >().Setup(m => m.ElementType).Returns(t.ElementType);
            mockSet.As <IQueryable <Task> >().Setup(m => m.GetEnumerator()).Returns(t.GetEnumerator());


            IQueryable <Task> childTasks = Enumerable.Empty <Task>().AsQueryable();

            var mockTaskMangerContext = new Mock <TaskManagerContext>();

            mockTaskMangerContext.Setup(c => c.Tasks).Returns(mockSet.Object);
            mockTaskMangerContext.Setup(p => p.SaveChanges());
            var objTestTaskrepo = new TaskRepository(mockTaskMangerContext.Object);

            objTestTaskrepo.DeleteTask(taskEdit);


            mockTaskMangerContext.Verify(mock => mock.SaveChanges(), Times.Once());
        }
예제 #3
0
파일: TaskBL.cs 프로젝트: RAJUKSX/Capsule
        public bool DeleteTask(int taskId)
        {
            TaskRepository obj = new TaskRepository();

            obj.DeleteTask(taskId);
            return(true);
        }
예제 #4
0
        public bool DeleteTask(object taskModel)
        {
            TaskRepository obj = new TaskRepository();

            obj.DeleteTask(ModelConverter(taskModel));
            return(true);
        }
예제 #5
0
        // DELETE: api/Task/5
        public void Delete(int id)
        {
            Tasks task = new Tasks();

            task.projecttaskid = id;
            TaskRepository.DeleteTask(task);
        }
예제 #6
0
        public ActionResult DeleteTask(int taskId)
        {
            var taskRepo    = new TaskRepository();
            var currentTask = taskRepo.GetTaskById(taskId);

            taskRepo.DeleteTask(taskId);
            return(RedirectToAction("Index", new { ProjectId = currentTask.ProjectId }));
        }
예제 #7
0
        public async Task DeleteExistingTask()
        {
            int numberOfRecord = _appDbContext.Tasks.First().TaskId;

            await Sut.DeleteTask(numberOfRecord);

            Assert.DoesNotContain(_appDbContext.Tasks, task => task.TaskId == numberOfRecord);
        }
예제 #8
0
        public async Task Repository_DeleteTask_Test()
        {
            //arrange
            var collection = new List <TaskModel>
            {
                new TaskModel
                {
                    TaskId = 1,
                    Name   = "First"
                },
                new TaskModel
                {
                    TaskId = 2,
                    Name   = "Second"
                },
                new TaskModel
                {
                    TaskId = 3,
                    Name   = "Third"
                }
            };
            var contextMock = new Mock <IProjectContext>();

            contextMock.Setup(x => x.Tasks).Returns(CreateDbSetMock(collection).Object);
            var userServiceMock = new Mock <IUserService>();
            var repository      = new TaskRepository(contextMock.Object, userServiceMock.Object);

            //act
            var firstResult = await repository.DeleteTask(1);

            var thirdResult = await repository.DeleteTask(3);

            var fourthResult = await repository.DeleteTask(4);

            //assert
            Assert.IsTrue(firstResult);
            Assert.IsTrue(thirdResult);
            Assert.IsFalse(fourthResult);
            Assert.IsTrue(contextMock.Object.Tasks.Select(t => t.TaskId).Contains(2));
            Assert.IsTrue(contextMock.Object.Tasks.Select(t => t.TaskId).Contains(1));
            Assert.IsTrue(contextMock.Object.Tasks.Select(t => t.TaskId).Contains(3));
            Assert.IsTrue(contextMock.Object.Tasks.SingleOrDefault(t => t.TaskId == 1).IsDeleted);
            Assert.IsFalse(contextMock.Object.Tasks.SingleOrDefault(t => t.TaskId == 2).IsDeleted);
            Assert.IsTrue(contextMock.Object.Tasks.SingleOrDefault(t => t.TaskId == 3).IsDeleted);
        }
예제 #9
0
        private void DeleteCommandHandler(object sender, ExecutedRoutedEventArgs e)
        {
            var source         = e.Source;
            var originalSource = e.OriginalSource as CheckBox;
            var param          = Convert.ToInt32(e.Parameter);

            repo.DeleteTask(param);
            BindTasks();
        }
예제 #10
0
 public IActionResult DeleteTask(string taskId)
 {
     try
     {
         TaskRepository.DeleteTask(taskId, _logger, _redisCache, _appSettings);
         return(Ok("deleted"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public async Task <IActionResult> DeleteTask(int id)
        {
            bool add = await _taskRepository.AddToDeletedTasks(id);

            if (add == true)
            {
                bool success = await _taskRepository.DeleteTask(id);

                return(RedirectToAction(nameof(GetAllTasks), new { delete = add }));
            }

            return(null);
        }
예제 #12
0
        public async System.Threading.Tasks.Task Delete_Task_Returns_True()
        {
            // Arrange
            await sut.CreateTask(task);

            _context.Entry(task).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
            var getTasks = await sut.GetTasks(task.TenantId);

            var id             = getTasks.First().Id;
            var expectedResult = true;
            // Act
            var result = await sut.DeleteTask(id);

            // Assert
            Assert.Equal(expectedResult, result);
        }
        public async Task DeleteTaskAndCheckWhetherSavedInDatabaseOrNot()
        {
            var mockContext = new Mock <ProjectManagerApiDbContext>(contextOptions);

            var taskRepository = new TaskRepository(mockContext.Object);

            var taskDetail = TestData.GetTasks().Where(task => task.Id == 113).FirstOrDefault();

            var mockSet = new Mock <DbSet <TaskDetail> >();

            mockContext.Setup(m => m.Tasks).Returns(mockSet.Object);
            var result = await taskRepository.DeleteTask(taskDetail);

            mockSet.Verify(m => m.Remove(taskDetail), Times.Once);
            mockContext.Verify(m => m.SaveChangesAsync(System.Threading.CancellationToken.None), Times.Once);
        }
예제 #14
0
        public void TestDeleteTask()
        {
            try
            {
                var data = new List <ProjectManager.Persistence.Task>()
                {
                    new Persistence.Task {
                        ProjectId = 25, TaskName = "Support Test Driven Development", IsParentTask = true, Priority = 2, ParentTask = 5, StartDate = new DateTime(2018, 8, 12), EndDate = DateTime.Now, UserId = 20
                    },
                    new Persistence.Task {
                        ProjectId = 25, TaskName = "Support Mobile Screens", IsParentTask = true, Priority = 8, ParentTask = 4, StartDate = new DateTime(2018, 3, 6), EndDate = DateTime.Now, UserId = 14
                    },
                }.AsQueryable();

                var mockSet = new Mock <DbSet <ProjectManager.Persistence.Task> >();
                mockSet.As <IQueryable <ProjectManager.Persistence.Task> >().Setup(m => m.Provider).Returns(data.Provider);
                mockSet.As <IQueryable <ProjectManager.Persistence.Task> >().Setup(m => m.Expression).Returns(data.Expression);
                mockSet.As <IQueryable <ProjectManager.Persistence.Task> >().Setup(m => m.ElementType).Returns(data.ElementType);
                mockSet.As <IQueryable <ProjectManager.Persistence.Task> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
                mockSet.As <IQueryable <ProjectManager.Persistence.Task> >().Setup(m => m.Provider).Returns(data.Provider);



                var mockContext = new Mock <ProjectManagerContext>();
                mockContext.Setup(m => m.tasks).Returns(mockSet.Object);

                var service = new TaskRepository(mockContext.Object);

                List <Task> TaskList = service.GetAllTasks();

                Assert.That(TaskList.Count == 2);

                bool ret = service.DeleteTask(10);

                Assert.That(1 == 1);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Assert.That(1 == 0);
            }
        }
        public async Task <ActionResult> Index(int?pageIndex, int?pageSize, string taskId)
        {
            TaskRepository repository = new TaskRepository();

            if (Request.HttpMethod == "POST" && taskId != null)
            {
                await repository.DeleteTask(taskId);

                return(Redirect("/"));
            }

            TaskViewModel model = new TaskViewModel();

            if (pageIndex == null)
            {
                model.PageIndex = 0;
            }
            else
            {
                model.PageIndex = (int)pageIndex;
            }

            if (pageSize == null)
            {
                model.PageSize = 10;
            }
            else
            {
                model.PageSize = (int)pageSize;
            }

            try
            {
                model.Tasks = await repository.GetTasks(model.PageIndex, model.PageSize);
            }
            catch (RedirectRequiredException x)
            {
                return(Redirect(x.RedirectUri.ToString()));
            }

            return(View(model));
        }
        public IActionResult DeleteTaskItem([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //var taskItem = await _context.taskItems.SingleOrDefaultAsync(m => m.ID == id);
            var taskItem = _taskRepository.GetTaskByID(id);

            if (taskItem == null)
            {
                return(NotFound());
            }

            _taskRepository.DeleteTask(taskItem.ID);
            _taskRepository.Save();
            //_context.taskItems.Remove(taskItem);
            //await _context.SaveChangesAsync();

            return(Ok(taskItem));
        }
예제 #17
0
        public JsonResult DeleteTask(int id)
        {
            try
            {
                var taskRespo = new TaskRepository();
                taskRespo.DeleteTask(id);

                // Inform all connected clients
                var clientName = Request["clientName"];
                Task.Factory.StartNew(
                    () =>
                {
                    // var clients = Hub.GetClients<TaskHub>();
                    _context.Clients.RecDeleted(clientName, id);
                });

                // Return result to current (caller) client
                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
예제 #18
0
        public static object ModifyTaskEntity(this TaskOptions taskOptions, ISchedulerFactory schedulerFactory, TaskAction action)
        {
            object result = null;
            switch (action)
            {
                case TaskAction.删除:
                    TaskRepository.DeleteTask(new List<string> { taskOptions.id });
                    break;
                case TaskAction.修改:
                    result = taskOptions.AddJob(schedulerFactory, true).GetAwaiter().GetResult();
                    break;
                case TaskAction.暂停:
                case TaskAction.开启:
                case TaskAction.停止:
                case TaskAction.立即执行:
                    if (action == TaskAction.暂停)
                    {
                        taskOptions.status = (int)TriggerState.Paused;
                    }
                    else if (action == TaskAction.停止)
                    {
                        taskOptions.status = (int)action;
                    }
                    else
                    {
                        taskOptions.status = (int)TriggerState.Normal;
                    }
                    break;
            }
            if (action != TaskAction.删除)
            {
                TaskRepository.UpdateTask(taskOptions);
            }

            return result;
        }
예제 #19
0
 // DELETE: api/Task/5
 public void Delete(int id)
 {
     repository.DeleteTask(id);
 }
예제 #20
0
 public static int DeleteTask(int id)
 {
     return(TaskRepository.DeleteTask(id));
 }
예제 #21
0
 // DELETE: api/Task/5
 public void Delete(int id)
 {
     repo.DeleteTask(id);
 }
예제 #22
0
 public void DeleteTask(int id)
 {
     TaskRep.DeleteTask(id);
 }
예제 #23
0
 public ActionResult deleteTask(int id)
 {
     _repository.DeleteTask(id);
     return(Ok("Task is deleted"));
 }
예제 #24
0
        public ActionResult Tasks(Task model)
        {
            Guid            recordId = Guid.Empty;
            TaskRepository  tskDB    = RepositoryManager.GetRepository <TaskRepository>();
            CrmRepository   crmDB    = RepositoryManager.GetRepository <CrmRepository>();
            GenelRepository gnlDB    = RepositoryManager.GetRepository <GenelRepository>();

            SessionContext.Current.ActiveUser.MenuId = model.MenuId;
            ViewBag.Success = true;

            model.activeProjects = crmDB.GetProjectList();
            model.activeUsers    = gnlDB.GetActiveUsers();
            model.taskStatus     = tskDB.GetTaskStatusList();
            model.taskPriority   = tskDB.GetTaskPriorityList();

            ModelState.Remove("is_active");
            ModelState.Remove("is_task_sent");

            if (model.FromDeleteButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    tskDB.DeleteTask(model, Guid.Parse(model.RecordId));
                    return(RedirectToAction("ListPage", "General", new { MenuId = Dcm.Source.GlobalHelper.Encrypt(model.MenuId) }));
                }
            }
            else if (model.FromCreateTaskButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    tskDB.UpdateTaskStatus(model, Guid.Parse(model.RecordId), (int)Enums.TaskStatus.Gonderildi, true);
                    model = tskDB.BindTask(model, Guid.Parse(model.RecordId));

                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                }
            }
            else if (model.FromAddExplanationButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    tskDB.UpdateExplanation(model, Guid.Parse(model.RecordId));
                    model = tskDB.BindTask(model, Guid.Parse(model.RecordId));

                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (GlobalHelper.IsGuid(model.RecordId))
                    {
                        recordId = Guid.Parse(model.RecordId);
                        try
                        {
                            if (model.task_user_id != BaseDB.SessionContext.Current.ActiveUser.UserUid.ToString() && model.assigned_user_id == BaseDB.SessionContext.Current.ActiveUser.UserUid.ToString())
                            {
                                tskDB.UpdateTaskStatus(model, Guid.Parse(model.RecordId), Convert.ToInt32(model.task_status_id), model.is_active);
                                model = tskDB.BindTask(model, Guid.Parse(model.RecordId));
                            }
                            else
                            {
                                model = tskDB.UpdateTask(model, recordId);
                                model = tskDB.BindTask(model, Guid.Parse(model.RecordId));
                            }

                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            tsk_tasks task = new tsk_tasks();
                            tskDB.AddTask(task, model);
                            model.RecordId = task.task_id.ToString();

                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                }
                else
                {
                    ViewBag.Success = false;
                }
            }

            return(View(model));
        }
예제 #25
0
 public bool DeleteTask(UserTaskModel model)
 {
     return(_repository.DeleteTask(Mapper.MapUserTask(model)));
 }
예제 #26
0
 public bool DeleteTask(long taskId)
 {
     return(_taskRepo.DeleteTask(taskId));
 }
예제 #27
0
 public void TestDeleteTask()
 {
     taskrp.DeleteTask("*****@*****.**", 1);
 }