Пример #1
0
 public async System.Threading.Tasks.Task <OperationResult <Task> > GetTasks(Guid userId, int pageSize, int pageNumber, bool descending)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Task> >(() =>
     {
         OperationResult <Task> result = new OperationResult <Task>();
         try
         {
             if (IsInCompany())
             {
                 result.Count = TasksRepository.Count("CompanyId = @CompanyId AND StaffId = @StaffId",
                                                      new { CompanyId = CurrentUser.CompanyId, StaffId = userId });
                 if (result.Count > 0)
                 {
                     result.MultipleResult = TasksRepository.Search("CompanyId = @CompanyId AND StaffId = @StaffId",
                                                                    new { PageSize = pageSize, PageNumber = pageNumber, CompanyId = CurrentUser.CompanyId, StaffId = userId }, descending);
                 }
                 result.Result = true;
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
Пример #2
0
        public void Tasks_SortedByPosition()
        {
            using (var fixture = new FixtureInit("http://localhost"))
            {
                // arrange
                var repository = new TasksRepository(fixture.Setup.Context);

                repository.Save(new Task {
                    UserId = fixture.Setup.User.Id, Position = 3
                });
                repository.Save(new Task {
                    UserId = fixture.Setup.User.Id, Position = 2
                });
                repository.Save(new Task {
                    UserId = fixture.Setup.User.Id, Position = 1
                });

                // act
                var tasks = repository.Tasks.ToArray();

                // assert
                Assert.That(tasks[0].Position, Is.EqualTo(1));
                Assert.That(tasks[1].Position, Is.EqualTo(2));
                Assert.That(tasks[2].Position, Is.EqualTo(3));
            }
        }
Пример #3
0
        public void UpdateTask()
        {
            using (var fixture = new FixtureInit("http://localhost"))
            {
                //INIT
                var repository = new TasksRepository(fixture.Setup.Context);

                var task = new Task()
                {
                    Number      = 0,
                    UserId      = fixture.Setup.User.Id,
                    Description = "My new task",
                    Status      = 0,
                    ActualWork  = 0
                };

                repository.Save(task);

                //ACT
                task.Description = "My new task (update)";
                repository.Save(task);

                //POST
                var foundTask = repository.Tasks.WithId(task.Id);
                Assert.That(foundTask, Is.Not.Null);
                Assert.That(foundTask.Description, Is.EqualTo("My new task (update)"));
            }
        }
Пример #4
0
 public BaseListVM()
 {
     Users    = new UsersRepository().GetAll();
     Tasks    = new TasksRepository().GetAll();
     Comments = new CommentsRepository().GetAll();
     Logworks = new LogworksRepository().GetAll();
 }
Пример #5
0
        public void GetAllTasks()
        {
            using (var fixture = new FixtureInit("http://localhost"))
            {
                //INIT
                var repository = new TasksRepository(fixture.Setup.Context);

                var tasks = new[] {
                    new Task()
                    {
                        UserId = fixture.Setup.User.Id, Description = "test1"
                    },
                    new Task()
                    {
                        UserId = fixture.Setup.User.Id, Description = "test2"
                    }
                };

                foreach (var task in tasks)
                {
                    repository.Save(task);
                }

                //ACT
                var foundTasks = repository.Tasks;

                //POST
                Assert.That(foundTasks, Is.Not.Null);
                Assert.That(foundTasks.Count(), Is.EqualTo(2));
            }
        }
Пример #6
0
        public void SetDone(int taskId)
        {
            var taskRepo = new TasksRepository(Properties.Settings.Default.ConStr);

            taskRepo.SetCompleted(taskId);
            SendTasks();
        }
Пример #7
0
        public ActionResult Edit()
        {
            TasksEditVM model = new TasksEditVM();

            TryUpdateModel(model);

            Task task;

            if (model.ID == 0)
            {
                task = new Task();
            }
            else
            {
                task = new TasksRepository().GetByID(model.ID);
            }

            task.ID      = model.ID;
            task.Caption = model.Caption;
            task.Body    = model.Body;
            task.Date    = model.Date;
            task.Time    = model.Time;

            new TasksRepository().Save(task);

            return(RedirectToAction("List"));
        }
Пример #8
0
        public ActionResult addTask(string title)
        {
            TasksRepository repo = new TasksRepository(Properties.Settings.Default.ConStr);

            repo.AddTask(title);
            return(Redirect("/"));
        }
Пример #9
0
        public ActionResult addUser(User user, string password)
        {
            TasksRepository repo = new TasksRepository(Properties.Settings.Default.ConStr);

            repo.AddUser(user, password);
            return(Redirect("/home/index"));
        }
        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);
            }
        }
Пример #11
0
 public async System.Threading.Tasks.Task <OperationResult <Task> > CreateTask(Task task)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Task> >(() =>
     {
         OperationResult <Task> result = new OperationResult <Task>();
         try
         {
             if (IsInCompany())
             {
                 task.CompanyId = CurrentUser.CompanyId.Value;
                 if (task.StaffId == Guid.Empty)
                 {
                     task.StaffId = CurrentUser.Id;
                 }
                 Task newTask = TasksRepository.CreateOrUpdate(task);
                 if (newTask.Id > 0)
                 {
                     result.SingleResult = newTask;
                     result.Result = true;
                 }
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
Пример #12
0
        private void GetAllResponsibleFor()
        {
            Console.Clear();

            TasksRepository tasksRepository = new TasksRepository("tasks.txt");
            List <TaskData> tasks           = tasksRepository.GetAllResponsibleFor(AuthenticationService.LoggedUser.Id);

            Console.WriteLine("All tasks you are responsible for:");

            foreach (TaskData task in tasks)
            {
                Console.WriteLine("Task ID:" + task.Id);
                Console.WriteLine("Title :" + task.Title);
                Console.WriteLine("Description :" + task.Description);
                Console.WriteLine("Responsible User ID: " + task.ResponsibleUser);
                Console.WriteLine("Creator ID:" + task.Creator);
                Console.WriteLine("Creation Date : " + task.CreationDate);
                Console.WriteLine("Last Update Date :" + task.LastUpdateDate);
                Console.WriteLine("State :" + task.State);

                Console.WriteLine("########################################");
            }

            Console.ReadKey(true);
        }
Пример #13
0
        public Repositories(string connection)
        {
            #region Data context creating
            // ReSharper disable UseObjectOrCollectionInitializer
            _Context = new TimezDataContext(connection);
            // ReSharper restore UseObjectOrCollectionInitializer
#if DEBUG
            _Context.CommandTimeout = 60 * 5;
            _Context.Log            = new DebuggerWriter();
#endif
            #endregion

            Boards        = BoardsRepository.Create(_Context);
            BoardsColors  = BoardsColorsRepository.Create(_Context);
            BoardsUsers   = BoardsUsersRepository.Create(_Context);
            Tasks         = TasksRepository.Create(_Context);
            TasksStatuses = TasksStatusesRepository.Create(_Context);
            Users         = UsersRepository.Create(_Context);
            Organizations = OrganizationsRepository.Create(_Context);
            Projects      = ProjectsRepository.Create(_Context);
            Comments      = CommentsRepository.Create(_Context);
            EventHistory  = EventHistoryRepository.Create(_Context);
            Invites       = InvitesRepository.Create(_Context);
            Texts         = TextsRepository.Create(_Context);
        }
        public TasksPresenter(ITasksLayer view)
        {
            this.view = view;
            repository = new TasksRepository();

            Initialize();
        }
Пример #15
0
        private void MakeComment()
        {
            Console.Clear();

            Comentary comentary = new Comentary();

            comentary.UserId = AuthenticationService.LoggedUser.Id;

            Console.WriteLine("Add new Comment on Task:");
            Console.Write("Task ID: ");
            comentary.TaskId = Convert.ToInt32(Console.ReadLine());

            TasksRepository tasksRepository = new TasksRepository("tasks.txt");
            TaskData        taskData        = tasksRepository.GetById(comentary.TaskId);



            if (taskData.Creator == AuthenticationService.LoggedUser.Id || taskData.ResponsibleUser == AuthenticationService.LoggedUser.Id)
            {
                Console.Write("Commentary: ");
                comentary.ComentaryText = Console.ReadLine();
                ComentaryRepository comentaryRepository = new ComentaryRepository("comentaries.txt");
                comentaryRepository.Insert(comentary);
                Console.WriteLine("Comentary made successfully.");
            }
            else
            {
                Console.WriteLine("You can comment only task you created or you are responsible for.");
            }


            Console.ReadKey(true);
        }
Пример #16
0
        private void Add()
        {
            Console.Clear();

            TaskData taskData = new TaskData();

            taskData.Creator = AuthenticationService.LoggedUser.Id;

            Console.WriteLine("Add new Task:");
            Console.Write("Title: ");
            taskData.Title = Console.ReadLine();
            Console.Write("Description: ");
            taskData.Description = Console.ReadLine();

            Console.Write("Time: ");
            taskData.Time = Convert.ToInt32(Console.ReadLine());

            Console.Write("Responsible User Id: ");
            taskData.ResponsibleUser = Convert.ToInt32(Console.ReadLine());

            Console.Write("Creation Date: ");
            taskData.CreationDate = Console.ReadLine();
            Console.Write("Last Update Date: ");
            taskData.LastUpdateDate = Console.ReadLine();
            Console.Write("State (Waiting or Completed): ");
            taskData.State = Console.ReadLine();


            TasksRepository tasksRepository = new TasksRepository("tasks.txt");

            tasksRepository.Save(taskData);

            Console.WriteLine("Task saved successfully.");
            Console.ReadKey(true);
        }
Пример #17
0
        public bool DelTask(IdDTO iddto, Guid id)
        {
            TasksRepository repository = new TasksRepository();

            var taskId = iddto.Id;

            var tasks = repository.GetItem(taskId);

            if (tasks != null)
            {
                repository.Delete(taskId);

                var tasks2 = repository.GetItem(taskId);

                if (tasks2 == null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #18
0
        public ReportController(DatabaseContext databaseContext, IMapper mapper)
        {
            var taskRepository = new TasksRepository(databaseContext);

            _projectsService = new ProjectsService(new ProjectsRepository(databaseContext), taskRepository, mapper);
            _tasksService    = new TasksService(taskRepository, mapper);
        }
Пример #19
0
        public ActionResult Edit(Task task)
        {
            TasksRepository repo = new TasksRepository();

            repo.Update(task);
            return(RedirectToAction("List", new { id = task.UserID }));
        }
Пример #20
0
        public bool AddTask(Tasks task, Guid id)
        {
            if (task.Name == null || task.Date == null || id == null)
            {
                return(false);
            }
            else
            {
                TasksRepository repository = new TasksRepository();

                //Gerar novo ID
                task.Id      = Guid.NewGuid();
                task.UsersId = id;
                repository.Add(task);


                var tasks = repository.GetItem(task.Id);

                if (tasks != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #21
0
        public void SetDone(int taskId)
        {
            var taskRepo = new TasksRepository(_connectionString);

            taskRepo.SetCompleted(taskId);
            SendTasks();
        }
Пример #22
0
        public void completedTask(int taskId)
        {
            var repo = new TasksRepository(Properties.Settings.Default.ConStr);

            repo.SetTaskAsCompleted(taskId);
            Clients.All.reload();
        }
Пример #23
0
        /// <summary>
        /// Update gantt tasks
        /// </summary>
        /// <param name="ganttData">GanttData object</param>
        private void UpdateTasks(GanttRequest ganttData)
        {
            switch (ganttData.Action)
            {
            case GanttAction.Inserted:
                // add new gantt task entity
                //db.Tasks.Add(ganttData.UpdatedTask);
                TasksRepository.Insert(ganttData.UpdatedTask);
                break;

            case GanttAction.Deleted:
                // remove gantt tasks
                //db.Tasks.Remove(db.Tasks.Find(ganttData.SourceId));
                TasksRepository.Delete(ganttData.UpdatedTask);

                break;

            case GanttAction.Updated:
                // update gantt task
                //db.Entry(db.Tasks.Find(ganttData.UpdatedTask.Id)).CurrentValues.SetValues(ganttData.UpdatedTask);
                TasksRepository.Update(ganttData.UpdatedTask);
                break;

            default:
                ganttData.Action = GanttAction.Error;
                break;
            }
        }
Пример #24
0
        public ActionResult Delete(int id)
        {
            TasksRepository repo = new TasksRepository();

            repo.Delete(id);
            return(RedirectToAction("List"));
        }
        public ActionResult EditTask(int?id)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

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

            Task task = null;

            if (id == null)
            {
                task              = new Task();
                task.CreatorId    = AuthenticationManager.LoggedUser.Id;
                task.DateCreated  = DateTime.Now;
                task.LastModified = DateTime.Now;
                task.IsDone       = false;
            }
            else
            {
                task = tasksRepository.GetById(id.Value);
            }

            ViewData["task"]  = task;
            ViewData["users"] = usersRepository.GetAll();

            return(View());
        }
Пример #26
0
 public TasksRepositoryTests()
 {
     _guidFactory      = new Mock <IGuidFactory>(MockBehavior.Strict);
     _dateTimeProvider = new Mock <IDateTimeProvider>(MockBehavior.Strict);
     _dbRepository     = new Mock <IDbTmRepository <DbTask> >(MockBehavior.Strict);
     _tasksRepository  = new TasksRepository(_guidFactory.Object, _dateTimeProvider.Object, _dbRepository.Object);
     _fixture          = new Fixture();
 }
Пример #27
0
        public void reserveTask(int taskId)
        {
            var repo        = new TasksRepository(Properties.Settings.Default.ConStr);
            var accountRepo = new UserManager(Properties.Settings.Default.ConStr);

            repo.SetUserForTask(taskId, int.Parse(HttpContext.Current.User.Identity.Name));
            Clients.All.reload();
        }
Пример #28
0
        protected override void Initialize(System.Web.Http.Controllers.HttpControllerContext controllerContext)
        {
            base.Initialize(controllerContext);
            var users = new UsersRepository();
            var user  = users.FindUserByEmail(Email.Parse(User.Identity.Name));

            m_task = new TasksRepository(user);
        }
Пример #29
0
        public void RetrieveByPK()
        {
            Tasks tasks = TasksRepository.RetrieveByPK(task3Update);
            JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();

            jsonSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            Console.Write(JsonConvert.SerializeObject(tasks, jsonSerializerSettings));
            Assert.NotNull(tasks);
        }
Пример #30
0
        public void SetDoing(int taskId)
        {
            var userRepo = new UserRepository(_connectionString);
            var user     = userRepo.GetByEmail(Context.User.Identity.Name);
            var taskRepo = new TasksRepository(_connectionString);

            taskRepo.SetDoing(taskId, user.Id);
            SendTasks();
        }
Пример #31
0
        public void RetrieveDeviceFromTask()
        {
            Devices device = TasksRepository.RetrieveByPK(task1WithSchedule).Device;
            JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();

            jsonSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            Console.Write(JsonConvert.SerializeObject(device, jsonSerializerSettings));
            Assert.NotNull(device);
        }