Esempio n. 1
0
        public async Task <IEnumerable <TaskModel> > GetByPerson(Guid personId, TaskSearchOptions searchOptions = null)
        {
            if (searchOptions == null)
            {
                searchOptions = new TaskSearchOptions {
                    Status = TaskStatus.Active
                };
            }

            var tasks = await _taskRepository.GetByAssignedTo(personId, searchOptions);

            return(tasks.Select(BusinessMapper.Map <TaskModel>));
        }
Esempio n. 2
0
        public async Task <IEnumerable <TaskModel> > GetByPerson(Guid personId, TaskSearchOptions searchOptions = null)
        {
            using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork())
            {
                if (searchOptions == null)
                {
                    searchOptions = new TaskSearchOptions {
                        Status = TaskStatus.Active
                    };
                }

                var tasks = await unitOfWork.Tasks.GetByAssignedTo(personId, searchOptions);

                return(tasks.Select(t => new TaskModel(t)));
            }
        }
Esempio n. 3
0
        private void ApplySearch(Query query, TaskSearchOptions searchOptions)
        {
            if (searchOptions.Status == TaskStatus.Overdue)
            {
                query.WhereDate("Task.DueDate", "<", DateTime.Today);
            }

            else if (searchOptions.Status == TaskStatus.Active)
            {
                query.Where(q => q.Where("Task.Completed", false).OrWhereDate("Task.DueDate", ">=", DateTime.Today));
            }

            else if (searchOptions.Status == TaskStatus.Completed)
            {
                query.Where("Task.Completed", true);
            }
        }
Esempio n. 4
0
        private void ApplySearch(Query query, TaskSearchOptions searchOptions)
        {
            if (searchOptions.Status == TaskStatus.Overdue)
            {
                query.Where($"{TblAlias}.Completed", false);
                query.Where($"{TblAlias}.DueDate", "<", DateTime.Today);
            }

            else if (searchOptions.Status == TaskStatus.Active)
            {
                query.Where($"{TblAlias}.Completed", false);
            }

            else if (searchOptions.Status == TaskStatus.Completed)
            {
                query.Where($"{TblAlias}.Completed", true);
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> GetByPerson([FromRoute] Guid personId, [FromQuery] TaskSearchOptions searchOptions)
        {
            try
            {
                var accessResponse = await GetPermissionsForTasksPerson(personId, false);

                if (accessResponse.CanAccess || accessResponse.IsOwner)
                {
                    var tasks = (await _taskService.GetByPerson(personId, searchOptions)).ToArray();

                    return(Ok(tasks));
                }

                return(Error(HttpStatusCode.Forbidden, PermissionMessage));
            }
            catch (Exception e)
            {
                return(HandleException(e));
            }
        }
Esempio n. 6
0
        public async System.Threading.Tasks.Task <IEnumerable <Task> > GetByAssignedTo(Guid personId, TaskSearchOptions searchOptions = null)
        {
            var query = GenerateQuery();

            query.Where($"{TblAlias}.AssignedToId", personId);

            if (searchOptions != null)
            {
                ApplySearch(query, searchOptions);
            }

            return(await ExecuteQuery(query));
        }
Esempio n. 7
0
        public async Task <List <TaskModelWithActualStateAndCreator> > GetTasks(CancellationToken cancellationToken, string query, TaskSearchOptions searchOptions)
        {
            cancellationToken.ThrowIfCancellationRequested();
            await loadAuthTask;
            var   httpQuery = $"api/TaskModel/Search?query={query}&showFinished={!searchOptions.ShowOnlyNotFinished}&showUnassigned={searchOptions.ShowUnassignedToMe}";
            var   response  = await _httpClient.GetAsync(httpQuery, cancellationToken);

            var text = await response.Content.ReadAsStringAsync(cancellationToken);

            var output = JsonSerializer.Deserialize <List <TaskModelWithActualStateAndCreator> >(text, new JsonSerializerOptions {
                PropertyNameCaseInsensitive = true
            });

            return(output);
        }