Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="task"></param>
 /// <returns></returns>
 private Entities.Task ConvertToEntityTask(DataLayer.Task task)
 {
     return
         (new Entities.Task
     {
         Id = task.ID,
         Name = task.Description,
         StartDate = task.StartDate,
         EndDate = task.EndDate,
         Priority = task.Priority,
         Status = task.Status,
         Parent = task.ParentID.HasValue ? ConvertToEntityTask(task.ParentTask) : null
     });
 }
Exemplo n.º 2
0
        public void AddTask(TaskModel newTask)
        {
            DataLayer.Task newObj = new DataLayer.Task()
            {
                Task1      = newTask.TaskName,
                ParentTask = newTask.ParentTaskName == null ? null : new ParentTask()
                {
                    Parent_Task = newTask.ParentTaskName
                },
                Start_Date = newTask.StartDate,
                End_Date   = newTask.EndDate,
                Priority   = newTask.Priority
            };

            _dbService.AddTask(newObj);
        }
Exemplo n.º 3
0
        public void UpdateTask(DataLayer.Task task, int?parentId = null, int?userId = null)
        {
            if (userId.HasValue && userId.Value > 0)
            {
                var user = _db.Users.FirstOrDefault(x => x.User_ID == userId.Value);
                if (user != null)
                {
                    task.Users.Add(user);
                }

                if (parentId.HasValue && parentId.Value > 0)
                {
                    task.Parent_ID = parentId;
                }
            }
            _db.SaveChanges();
        }
Exemplo n.º 4
0
        public void UpdateTask(TaskModel updTask)
        {
            DataLayer.Task updObj = new DataLayer.Task()
            {
                Task_ID    = updTask.TaskID,
                Task1      = updTask.TaskName,
                Parent_ID  = updTask.ParentTaskName == null ? null : updTask.ParentTaskID,
                ParentTask = updTask.ParentTaskName == null ? null : new ParentTask()
                {
                    Parent_ID = updTask.ParentTaskID.Value, Parent_Task = updTask.ParentTaskName
                },
                Start_Date = updTask.StartDate,
                End_Date   = updTask.EndDate,
                Priority   = updTask.Priority
            };

            _dbService.UpdateTask(updObj);
        }
        public void Test_GetTaskById()
        {
            DataLayer.Task objTsk = new DataLayer.Task()
            {
                Task1      = "Task1",
                Start_Date = new DateTime(2018, 08, 14),
                End_Date   = new DateTime(2018, 08, 20),
                Priority   = 10,
                ParentTask = new ParentTask()
                {
                    Parent_Task = "ParentTask1"
                }
            };

            Mock <ITaskDbService> mockDb = new Mock <ITaskDbService>();
            TaskManagerBL         obj    = new TaskManagerBL(mockDb.Object);

            mockDb.Setup(c => c.GetTaskById(It.IsAny <Int32>())).Returns(objTsk);
            var expectedTaskName = "Task1";
            var result           = obj.GetTaskById(1);

            Assert.AreEqual(expectedTaskName, result.TaskName);
        }
        public ActionResult Edit(int id, DataLayer.Task task)
        {
            TransactionResult <DataLayer.Task> result = DataLayer.Factories.TaskFactory.Save(task);

            return(ClientSideTransactionResult(result));
        }