public UnitOfWork(MyNewAppContext context)
 {
     _context  = context;
     Todos     = new TodoRepository(_context);
     TaskLists = new TaskListRepository(_context);
     Users     = new UserRepository(_context);
 }
        public async Task Should_Delete_TaskList_By_Id()
        {
            string documentId;

            // get document id for the "groceries" task list
            IMongoCollection <BsonDocument> taskListCollection;
            {
                taskListCollection = _fxt.Database.GetCollection <BsonDocument>("task-lists");
                BsonDocument document = await taskListCollection
                                        .Find(Builders <BsonDocument> .Filter.Eq("name", "groceries"))
                                        .SingleAsync();

                documentId = document.GetValue("_id").ToString();
            }

            ITaskListRepository taskListRepo = new TaskListRepository(
                _fxt.Database.GetCollection <TaskList>("task-lists")
                );

            await taskListRepo.DeleteAsync(documentId);

            var matchingDocuments = await taskListCollection
                                    .Find(Builders <BsonDocument> .Filter.Eq("name", "groceries"))
                                    .ToListAsync();

            Assert.Empty(matchingDocuments);
        }
        public void Given_task_exists_get_task_for_riskassessment()
        {
            var target = new TaskListRepository(ObjectFactory.GetInstance<IBusinessSafeSessionManager>(), ObjectFactory.GetInstance<IBusinessSafeSessionManagerFactory>());
            var result = target.GetFurtherControlMeasureTasksByRiskAssessmentId(66, 62473);

            Console.WriteLine(result.Count());

            ObjectFactory.GetInstance<IBusinessSafeSessionManager>().CloseSession();
        }
        public async Task Should_Throw_When_Delete_TaskList_By_Invalid_Id()
        {
            ITaskListRepository taskListRepo = new TaskListRepository(
                _fxt.Database.GetCollection <TaskList>("task-lists")
                );

            await Assert.ThrowsAsync <EntityNotFoundException>(() =>
                                                               taskListRepo.DeleteAsync("5bea0d905f99824ffcc107d0")
                                                               );
        }
        public async Task Should_Throw_When_Get_NonExisting_TaskList()
        {
            ITaskListRepository taskListRepo = new TaskListRepository(
                _fxt.Database.GetCollection <TaskList>("task-lists")
                );

            await Assert.ThrowsAsync <EntityNotFoundException>(() =>
                                                               taskListRepo.GetByNameAsync("task name ಠ_ಠ", "owner id (ツ)")
                                                               );
        }
Exemplo n.º 6
0
 public UnitOfWork()
 {
     db                 = new AplicationContext();
     userManager        = new ApplicationUserManager(new UserStore <ApplicationUser>(db));
     roleManager        = new ApplicationRoleManager(new RoleStore <ApplicationRole>(db));
     taskListRepository = new TaskListRepository(db);
     userRepository     = new ClientRepository(db);
     boardRepository    = new BoardRepository(db);
     cardRepository     = new CardRepository(db);
 }
        public async Task Should_Throw_When_Add_Duplicate_TaskList()
        {
            ITaskListRepository taskListRepo = new TaskListRepository(
                _fxt.Database.GetCollection <TaskList>("task-lists")
                );

            await Assert.ThrowsAsync <DuplicateKeyException>(() =>
                                                             taskListRepo.AddAsync(new TaskList {
                DisplayId = "groceries", OwnerId = "bobby"
            })
                                                             );
        }
        public void Given_task_exists()
        {
            var russellWilliamsEmployeeId = Guid.Parse("D2122FFF-1DCD-4A3C-83AE-E3503B394EB4");
            var employee = new EmployeeRepository(ObjectFactory.GetInstance<IBusinessSafeSessionManager>()).GetById(russellWilliamsEmployeeId);

            var target = new TaskListRepository(ObjectFactory.GetInstance<IBusinessSafeSessionManager>(), ObjectFactory.GetInstance<IBusinessSafeSessionManagerFactory>());

            List<long> siteIds = employee.User.Site.GetThisAndAllDescendants().Select(x => x.Id).ToList();
            var result = target.Search(55881, new List<Guid>(){russellWilliamsEmployeeId}, false, siteIds);

            ObjectFactory.GetInstance<IBusinessSafeSessionManager>().CloseSession();
        }
        public async Task Should_Add_New_TaskList()
        {
            // insert a new task list into the collection
            TaskList taskList;
            {
                ITaskListRepository taskListRepo = new TaskListRepository(
                    _fxt.Database.GetCollection <TaskList>("task-lists")
                    );
                taskList = new TaskList
                {
                    DisplayId = "GROCERIes",
                    Title     = "My Groceries List",
                    OwnerId   = "bobby",
                };
                await taskListRepo.AddAsync(taskList);
            }

            // ensure task list object is updated
            {
                Assert.Equal("My Groceries List", taskList.Title);
                Assert.Equal("groceries", taskList.DisplayId);
                Assert.Equal("bobby", taskList.OwnerId);
                Assert.NotNull(taskList.Id);
                Assert.True(ObjectId.TryParse(taskList.Id, out _), "Entity's ID should be a Mongo ObjectID.");
                Assert.InRange(taskList.CreatedAt, DateTime.UtcNow.AddSeconds(-5), DateTime.UtcNow);

                Assert.Null(taskList.Description);
                Assert.Null(taskList.Tags);
                Assert.Null(taskList.Collaborators);
                Assert.Null(taskList.ModifiedAt);
            }

            // ensure task list document is created in the collection
            {
                BsonDocument taskListDocument = _fxt.Database
                                                .GetCollection <BsonDocument>("task-lists")
                                                .FindSync(FilterDefinition <BsonDocument> .Empty)
                                                .Single();

                Assert.Equal(
                    BsonDocument.Parse($@"{{
                        _id: ObjectId(""{taskList.Id}""),
                        name: ""groceries"",
                        owner: ""bobby"",
                        title: ""My Groceries List"",
                        created: ISODate(""{taskList.CreatedAt:O}"")
                    }}"),
                    taskListDocument
                    );
            }
        }
Exemplo n.º 10
0
        public IHttpActionResult GetAllTasksForCombo(addWorkLog aw)
        {
            int       entity_Type_Task = 11;
            DataTable dtStatus         = WorkLogRepository.GetTaskStatus(entity_Type_Task);
            string    status           = string.Empty;

            if (!aw.isAllChecked)
            {
                foreach (DataRow dr in dtStatus.Rows)
                {
                    if (Convert.ToInt32(dr["Status"]) < 50)
                    {
                        status = status + Convert.ToString(dr["Status"]) + ",";
                    }
                }
            }
            DataSet ds = TaskListRepository.GetTasks(Convert.ToString(aw.ProjectId), status, null);

            return(Ok(ds.Tables[0]));
        }
        public async Task Should_Get_TaskList_By_Name()
        {
            ITaskListRepository taskListRepo = new TaskListRepository(
                _fxt.Database.GetCollection <TaskList>("task-lists")
                );

            // get task list by unique name and owner
            TaskList taskList = await taskListRepo.GetByNameAsync("grocerIES", "bobby");

            Assert.Equal("My Groceries List", taskList.Title);
            Assert.Equal("groceries", taskList.DisplayId);
            Assert.Equal("bobby", taskList.OwnerId);
            Assert.NotNull(taskList.Id);
            Assert.True(ObjectId.TryParse(taskList.Id, out _), "Entity ID should be a Mongo ObjectID.");
            Assert.InRange(taskList.CreatedAt, DateTime.UtcNow.AddSeconds(-30), DateTime.UtcNow);

            Assert.Null(taskList.Description);
            Assert.Null(taskList.Tags);
            Assert.Null(taskList.Collaborators);
            Assert.Null(taskList.ModifiedAt);
        }
Exemplo n.º 12
0
        public async System.Threading.Tasks.Task AddAsync_ValidRequest_CreateListAndTask()
        {
            using (var context = new TaskDbContext(_options))
            {
                var taskListRepo = new TaskListRepository(context);
                var taskRepo     = new TaskRepository(context);

                var taskList = new TaskList
                {
                    Title       = "New List",
                    OwnerId     = Guid.NewGuid().ToString(),
                    CreatedDate = DateTimeOffset.Now
                };

                var newTaskList = context.TaskLists.Add(taskList).Entity;

                var task = new TaskModel
                {
                    Description = "Write a Task List",
                    TaskList    = newTaskList,
                    CreatedDate = DateTimeOffset.Now,
                    Start       = DateTimeOffset.Now,
                    End         = DateTimeOffset.Now.AddMinutes(45),
                    Status      = Domain.Enums.TaskModelStatus.Open
                };

                var newTask = context.Tasks.Add(task).Entity;
                context.SaveChanges();

                var getListTasks = await context.TaskLists.AsNoTracking().Include(x => x.Tasks).ToListAsync();

                Assert.IsNotNull(newTaskList);
                Assert.IsNotNull(newTask);
                Assert.AreEqual(1, getListTasks.Count);
                Assert.AreEqual(1, getListTasks[0].Tasks.Count);
                Assert.AreEqual(newTask.Id, getListTasks[0].Tasks[0].Id);
            }
        }
Exemplo n.º 13
0
        private static void CreateTasks(UserManager <AspNetUser> userManager)
        {
            IdentityRepository indentityRepo = new IdentityRepository(context, userManager);
            var userId = indentityRepo.GetAspNetUsers.FirstOrDefault().Id;

            TaskListRepository taskRepo = new TaskListRepository(context);

            for (var i = 0; i < 100; i++)
            {
                Task task = new Task();
                task.Description = "Task " + i;
                task.Location    = new Location {
                    LocationId = 2
                };
                task.Status = new Status {
                    StatusId = 1
                };
                task.User = new AspNetUser {
                    Id = userId
                };
                taskRepo.AddTask(task);
            }
        }
Exemplo n.º 14
0
 public PersistanceHandler(TaskListRepository repository)
 {
     Repository = repository;
 }
Exemplo n.º 15
0
 public TaskListService(int userId)
 {
     _repository = new TaskListRepository(userId);
 }
Exemplo n.º 16
0
 public abstract Dictionary<string, List<TaskList>> LoadData(TaskListRepository repository);
Exemplo n.º 17
0
 public TaskListController(ILogger <TaskListController> logger, TaskListRepository taskListRepository)
 {
     _logger             = logger;
     _taskListRepository = taskListRepository;
 }
Exemplo n.º 18
0
        public override Dictionary<string, List<TaskList>> LoadData(TaskListRepository repository)
        {
            LoadXmlDataFromFile();

            RootNode = XmlData.Root;

            if (RootNode == null)
            {
                RootNode = new XElement("TaskData");
                XmlData.Add(RootNode);
            }

            Dictionary<string, List<TaskList>> taskData =
                new Dictionary<string, List<TaskList>>(StringComparer.CurrentCultureIgnoreCase);

            foreach (XElement channelNode in RootNode.Nodes())
            {
                var channelNodeAttribute = channelNode.Attribute("Name");
                if (channelNodeAttribute != null)
                {
                    List<TaskList> channelLists = new List<TaskList>();
                    foreach(XElement taskListNode in channelNode.Nodes())
                    {
                        var taskListCreator = taskListNode.Attribute(TaskListCreatorAttributeName);
                        var taskListName = taskListNode.Attribute("Name");
                        var taskListDefaultStatus = taskListNode.Attribute("DefaultStatus");

                        if(taskListCreator != null && taskListName != null && taskListDefaultStatus != null)
                        {
                            TaskList taskList = new TaskList(taskListCreator.Value, taskListName.Value, repository, taskListDefaultStatus.Value);

                            foreach(XElement taskNode in taskListNode.Nodes())
                            {
                                var taskText = taskNode.Value;
                                var taskCreatorNode = taskNode.Attribute("Creator");
                                var taskOwnerAttribute = taskNode.Attribute("Owner");
                                var taskIdAttribute = taskNode.Attribute("TaskId");
                                var taskStatus = taskNode.Attribute("Status");

                                if (taskCreatorNode != null && taskOwnerAttribute != null
                                    && taskIdAttribute != null && taskStatus != null)
                                {
                                    int taskId = Convert.ToInt32(taskIdAttribute.Value);

                                    if (taskId >= repository.NextTaskId)
                                        repository.NextTaskId = taskId + 1;

                                    Task task = new Task(taskText, taskCreatorNode.Value, taskId, taskList);
                                    task.WasTakenBy(taskOwnerAttribute.Value);
                                    task.UpdateStatus(taskStatus.Value);
                                    taskList.AddTask(task);
                                }
                            }
                            channelLists.Add(taskList);
                        }
                    }

                    taskData.Add(channelNodeAttribute.Value, channelLists);
                }
            }

            return taskData;
        }
Exemplo n.º 19
0
 public XmlPersistance(TaskListRepository repository, string filePath)
     : base(repository)
 {
     Repository = repository;
     _XmlFileNameWithPath = string.Format("{0}\\{1}",filePath,XmlFileName);
 }