Ejemplo n.º 1
0
        // GET: Tasks
        public ActionResult Index(int?id)
        {
            TasksRepository repo  = new TasksRepository();
            List <Task>     tasks = new List <Task>();

            if (id == null)
            {
                tasks = repo.GetAll().ToList();
            }
            else
            {
                tasks = repo.GetAll().Where(t => t.UserID == id).ToList();
            }
            return(View(tasks));
        }
Ejemplo n.º 2
0
 public IEnumerable <Model.Contracts.Task> GetTasks()
 {
     return(tasksRepository
            .GetAll()
            .Select(t => t.AutoMapObject <DB.Task, Model.Contracts.Task>())
            .OrderByDescending(c => c.TaskId));
 }
        public void GetAssignedTasks()
        {
            TasksRepository taskRepo = new TasksRepository("tasks.txt");
            List <Task>     tasks    = new List <Task>();

            tasks = taskRepo.GetAll(Task => Task.AssigneeId == AuthenticationService.LoggedUser.Id);
            if (tasks.Count == 0)
            {
                Console.WriteLine("You haven't been assigned any tasks yet.");
                Console.ReadKey(true);
            }
            else
            {
                UsersRepository userRepo = new UsersRepository("users.txt");
                foreach (Task task in tasks)
                {
                    Console.WriteLine("###########################");
                    Console.WriteLine($"Task id: {task.Id}");
                    Console.WriteLine($"Title: {task.Title}");
                    Console.WriteLine($"Description: {task.Description}");
                    Console.WriteLine($"Evaluated time to complete: {task.EvaluatedTimeToComplete} hours");
                    List <User> users = userRepo.GetAll(User => User.Id == task.AssigneeId);
                    Console.WriteLine($"Assignee: {users[0].FullName}");
                    users = userRepo.GetAll(User => User.Id == task.CreatorId);
                    Console.WriteLine($"Creator: {users[0].FullName}");
                    Console.WriteLine($"Creation date: {task.CreationDate}");
                    Console.WriteLine($"Last edit date: {task.LastEditDate}");
                    Console.WriteLine($"Task state: {task.TaskState}");
                    Console.WriteLine("###########################");
                }
                Console.ReadKey(true);
            }
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <IEnumerable <TasksViewModel> > > GetAll()
        {
            var tasks = await _repository.GetAll();

            IEnumerable <TasksViewModel> maped = _mapper.Map <IEnumerable <TasksViewModel> >(tasks);


            return(Ok(maped));
        }
Ejemplo n.º 5
0
        public void Can_Get_All_Tasks_From_Repository()
        {
            var repository = new TasksRepository(
                new ProjectsRepository(ConfigurationManager.ConnectionStrings["TaskTracker"].ConnectionString),
                new TagsRepository(ConfigurationManager.ConnectionStrings["TaskTracker"].ConnectionString));

            var allTasks = repository.GetAll();

            Assert.That(allTasks, Has.Count.GreaterThan(0));
        }
        public void DeleteUser()
        {
            Console.Clear();
            Console.Write("Enter user id to delete: ");
            int  id    = 0;
            bool isInt = int.TryParse(Console.ReadLine(), out id);

            while (isInt == false)
            {
                Console.WriteLine("Only numbers can be entered for user ID's");
                isInt = int.TryParse(Console.ReadLine(), out id);
            }

            UsersRepository userRepo = new UsersRepository("users.txt");

            if (userRepo.CheckEntityExistence(User => User.Id == id) == false)
            {
                Console.WriteLine("No user with that id exists!!");
                Console.ReadKey(true);
                return;
            }
            if (id == 1)
            {
                Console.WriteLine("You cannot delete the built-in administrator account!!");
                Console.ReadKey(true);
                return;
            }

            CommentsRepository commentRepo = new CommentsRepository("comments.txt");
            List <Comment>     comments    = commentRepo.GetAll(Comment => Comment.CreatorId == id);

            foreach (Comment comment in comments)
            {
                commentRepo.Delete(comment);
            }

            TasksRepository taskRepo = new TasksRepository("tasks.txt");
            List <Task>     tasks    = taskRepo.GetAll(Task => Task.CreatorId == id || Task.AssigneeId == id);

            foreach (Task task in tasks)
            {
                taskRepo.Delete(task);
            }

            List <User> users = userRepo.GetAll(User => User.Id == id);

            foreach (User user in users)
            {
                userRepo.Delete(user);
            }

            Console.WriteLine("User successfully deleted!");
            Console.ReadKey(true);
        }
        public ActionResult Index()
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            TasksRepository tasksRepository = new TasksRepository(new TaskManagerDb());

            ViewData["task"] = tasksRepository.GetAll()
                               .Where(i => i.AssigneeId == AuthenticationManager.LoggedUser.Id || i.CreatorId == AuthenticationManager.LoggedUser.Id).ToList();

            return(View());
        }
Ejemplo n.º 8
0
        public void AddComment()
        {
            Console.Clear();
            Comment comment = new Comment();

            Console.Write("Enter id of the related task: ");
            int  inputRelatedTaskId = 0;
            bool isInt = int.TryParse(Console.ReadLine(), out inputRelatedTaskId);

            while (isInt == false)
            {
                Console.WriteLine("Only integers can be entered for task ID's!!");
                Console.ReadKey();
                return;
            }
            TasksRepository    taskRepo = new TasksRepository("tasks.txt");
            List <Entity.Task> tasks    = taskRepo.GetAll(Task => Task.Id == inputRelatedTaskId);

            if (tasks.Count == 0)
            {
                Console.WriteLine($"No task with id {inputRelatedTaskId} exists!! ");
                Console.ReadKey(true);
                return;
            }
            Entity.Task task = tasks[0];
            if (!(task.AssigneeId == AuthenticationService.LoggedUser.Id || task.CreatorId == AuthenticationService.LoggedUser.Id))
            {
                Console.WriteLine("You can only add comments to tasks which you created or which you are assigned to!");
                Console.ReadKey(true);
                return;
            }

            comment.RelatedTaskId = inputRelatedTaskId;
            comment.CreatorId     = AuthenticationService.LoggedUser.Id;
            Console.Write("Enter comment: ");
            comment.CommentText = Console.ReadLine();
            comment.CommentDate = DateTime.Now;
            CommentsRepository commentRepo = new CommentsRepository("comments.txt");

            commentRepo.Save(comment);
            Console.WriteLine("Comment saved successfully!");
            Console.ReadKey();
        }
Ejemplo n.º 9
0
        public void ViewCommentsForTasksAssignedToMe()
        {
            TasksRepository    taskRepo = new TasksRepository("tasks.txt");
            List <Entity.Task> tasks    = taskRepo.GetAll(Task => Task.AssigneeId == AuthenticationService.LoggedUser.Id);

            if (tasks.Count == 0)
            {
                Console.WriteLine("There are no tasks assigned to you yet.");
                Console.ReadKey(true);
                return;
            }
            CommentsRepository commentRepo = new CommentsRepository("comments.txt");
            UsersRepository    userRepo    = new UsersRepository("users.txt");

            foreach (Entity.Task task in tasks)
            {
                Console.WriteLine();
                Console.WriteLine("#################################");
                Console.WriteLine($"Task id: {task.Id}");
                Console.WriteLine($"Task title: {task.Title}");
                List <Comment> comments = commentRepo.GetAll(Comment => Comment.RelatedTaskId == task.Id);
                if (comments.Count == 0)
                {
                    Console.WriteLine($"No comments for task {task.Id}");
                }
                else
                {
                    foreach (Comment comment in comments)
                    {
                        Console.WriteLine("*********************************");
                        Console.WriteLine($"Comment Id: {comment.Id}");
                        List <User> users = userRepo.GetAll(User => User.Id == comment.CreatorId);
                        Console.WriteLine($"Comment creator: {users[0].FullName}");
                        Console.WriteLine($"Commented on: {comment.CommentDate}");
                        Console.WriteLine($"Comment text: {comment.CommentText}");
                        Console.WriteLine("*********************************");
                    }
                }
                Console.WriteLine("#################################");
            }
            Console.ReadKey(true);
        }
Ejemplo n.º 10
0
        public ActionResult GetThisWeek()
        {
            List <Task> allTasks    = tasksRepository.GetAll();
            List <Task> weeklyTasks = new List <Task>();

            for (var i = 0; i < allTasks.Count; i++)
            {
                if (DateInsideOneWeek(DateTime.Today, allTasks[i].Date))
                {
                    weeklyTasks.Add(allTasks[i]);
                }
            }

            return(Ok(weeklyTasks));
        }
Ejemplo n.º 11
0
        public void DeleteTasks()
        {
            Console.Clear();
            Console.Write("Enter task id to delete: ");
            int  inputId = 0;
            bool isInt   = int.TryParse(Console.ReadLine(), out inputId);

            while (isInt == false)
            {
                Console.WriteLine("You can only enter integers for task ID's!!");
                Console.Write("Enter task id to delete: ");
                isInt = int.TryParse(Console.ReadLine(), out inputId);
            }

            TasksRepository taskRepo = new TasksRepository("tasks.txt");
            List <Task>     tasks    = taskRepo.GetAll(Task => Task.Id == inputId);

            if (tasks.Count == 0)
            {
                Console.WriteLine("No tasks with that Id found.");
                Console.ReadKey(true);
            }
            else if (tasks[0].CreatorId != AuthenticationService.LoggedUser.Id)
            {
                Console.WriteLine("You cannot delete a task which was not created by you!!");
                Console.ReadKey(true);
            }
            else
            {
                foreach (Task task in tasks)
                {
                    taskRepo.Delete(task);
                }

                Console.WriteLine("Task successfully deleted!");
                Console.ReadKey(true);
            }
        }
Ejemplo n.º 12
0
        public JsonResult Data()
        {
            var tasksResult = TasksRepository.GetAll();
            var linksResult = LinksRepository.getAll();
            var jsonData    = new
            {
                // create tasks array
                data = (
                    from t in tasksResult
                    select new
                {
                    id = t.Id,
                    text = t.Text,
                    start_date = t.StartDate.ToString("u"),
                    duration = t.Duration,
                    order = t.SortOrder,
                    progress = t.Progress,
                    open = true,
                    parent = t.ParentId,
                    type = (t.Type != null) ? t.Type : String.Empty
                }
                    ).ToArray(),
                // create links array
                links = (from l in linksResult select new
                {
                    id = l.Id,
                    source = l.SourceTaskId,
                    target = l.TargetTaskId,
                    type = l.Type
                }).ToArray()
            };

            return(new JsonResult {
                Data = jsonData, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
 public async Task <IHttpActionResult> GetTasks()
 {
     return(Ok(await repository.GetAll()));
 }
Ejemplo n.º 14
0
        public void TearDown()
        {
            var data = _repository.GetAll();

            data.ToList().ForEach(task => { _repository.Delete(task.Id); });
        }
 public async Task <ActionResult <IEnumerable <Tasks> > > Get()
 {
     return(await repository.GetAll());
 }
Ejemplo n.º 16
0
 internal IEnumerable <Tasky> GetAll()
 {
     // FIXME Should not be able to get any and all Taskys
     return(_repo.GetAll());
 }
Ejemplo n.º 17
0
 internal IEnumerable <Task> GetAll()
 {
     return(_repo.GetAll());
 }
Ejemplo n.º 18
0
 public ActionResult Index()
 {
     return(View(repository.GetAll()));
 }
Ejemplo n.º 19
0
 // GET: api/Tasks
 public List <Task> Get()
 {
     return(repository.GetAll());
 }
Ejemplo n.º 20
0
        public void ChangeTaskState()
        {
            Console.Clear();
            Console.Write("Enter id of the task which State you would like to change: ");
            int  inputTaskId = 0;
            bool isInt       = int.TryParse(Console.ReadLine(), out inputTaskId);

            while (isInt == false)
            {
                Console.WriteLine("You can only enter integers for task ID's!!");
                Console.Write("Enter id of the task which state you would like to change: ");
                isInt = int.TryParse(Console.ReadLine(), out inputTaskId);
            }
            TasksRepository taskRepo = new TasksRepository("tasks.txt");
            List <Task>     tasks    = taskRepo.GetAll(Task => Task.Id == inputTaskId);

            if (tasks.Count == 0)
            {
                Console.WriteLine($"There are no tasks with id {inputTaskId}");
                Console.ReadKey(true);
            }

            Task task = tasks[0];

            if (!(task.AssigneeId == AuthenticationService.LoggedUser.Id || task.CreatorId == AuthenticationService.LoggedUser.Id))
            {
                Console.WriteLine("You can only modify task status of tasks which you created or which you are assigned to!");
                Console.ReadKey(true);
                return;
            }
            else
            {
                Console.WriteLine($"Current task State: {task.TaskState}");
SelectTaskStatus:
                Console.WriteLine("Enter one of the options below: \"A\" - Awaiting Execution; \"I\" - In Execution; \"F\" - Finished");
                Console.Write("New task State: ");
                string inputTaskState = Console.ReadLine();
                switch (inputTaskState.ToUpper())
                {
                case "A":
                    task.TaskState = TaskState.AwaitingExecution;
                    break;

                case "I":
                    task.TaskState = TaskState.InExecution;
                    break;

                case "F":
                    task.TaskState = TaskState.Finished;
                    break;

                default:
                    Console.WriteLine("Invalid input!! Use one of the available options above!!");
                    Console.ReadKey(true);
                    goto SelectTaskStatus;
                }

                task.LastEditDate = DateTime.Now;
                taskRepo.Save(task);
                Console.WriteLine("Task State changed successfully!");
                Console.ReadKey(true);
            }
        }
Ejemplo n.º 21
0
        public void EditTask()
        {
            Console.Clear();
            Console.Write("Enter task id to edit: ");
            int  id    = 0;
            bool IsInt = int.TryParse(Console.ReadLine(), out id);

            while (IsInt == false)
            {
                Console.WriteLine("Only numbers can be entered for ID's!!");
                Console.Write("Enter task id to edit: ");
                IsInt = int.TryParse(Console.ReadLine(), out id);
            }

            TasksRepository taskRepo = new TasksRepository("tasks.txt");
            List <Task>     tasks    = taskRepo.GetAll(Task => Task.Id == id);

            if (tasks.Count == 0)
            {
                Console.WriteLine($"There is no task with id {id}!!!");
                Console.ReadKey(true);
                return;
            }
            Task task = tasks[0];

            Console.WriteLine($"Old title: {task.Title}");
            Console.Write("New title: ");
            task.Title = Console.ReadLine();

            Console.WriteLine($"Old description: {task.Description}");
            Console.Write("New description: ");
            task.Description = Console.ReadLine();

            Console.WriteLine($"Old evaluated time to complete: {task.EvaluatedTimeToComplete} hours");
            Console.Write("New evaluated time to complete: ");
            int  tempEvalTime = 0;
            bool isInt        = int.TryParse(Console.ReadLine(), out tempEvalTime);

            while (isInt == false)
            {
                Console.WriteLine("Only integers can be entered for the hours!!");
                Console.Write("New evaluated time to complete: ");
                isInt = int.TryParse(Console.ReadLine(), out tempEvalTime);
            }
            task.EvaluatedTimeToComplete = tempEvalTime;

            Console.WriteLine($"Old assignee id: {task.AssigneeId}");
            Console.Write("New assignee id: ");
            int  tempAssigneeId = 0;
            bool isInt1         = int.TryParse(Console.ReadLine(), out tempAssigneeId);

            while (isInt1 == false)
            {
                Console.WriteLine("Only integers can be entered for the ID's!!");
                Console.Write("New assignee id: ");
                isInt1 = int.TryParse(Console.ReadLine(), out tempAssigneeId);
            }
            task.AssigneeId = tempAssigneeId;

            task.LastEditDate = DateTime.Now;

            Console.WriteLine($"Old task state: {task.TaskState}");
            Console.WriteLine("Enter one of the options below: \"A\" - Awaiting Execution; \"I\" - In Execution; \"F\" - Finished");
            Console.Write("New task State: ");
            string inputTaskState = Console.ReadLine();

            switch (inputTaskState.ToUpper())
            {
            case "A":
                task.TaskState = TaskState.AwaitingExecution;
                break;

            case "I":
                task.TaskState = TaskState.InExecution;
                break;

            case "F":
                task.TaskState = TaskState.Finished;
                break;

            default:
                Console.WriteLine("Invalid input!! Use one of the available options above!!");
                Console.ReadKey(true);
                break;
            }

            taskRepo.Save(task);
            Console.WriteLine("Task edited successfully!!");
            Console.ReadKey(true);
        }