public IEnumerable<ResponsibilityDto> Search(SearchResponsibilitiesRequest request)
 {
     var responsibilities = _responsibilityRepository.Search(
         request.CurrentUserId,
         request.AllowedSiteIds,
         request.CompanyId,
         request.ResponsibilityCategoryId,
         request.SiteId,
         request.SiteGroupId,
         request.Title,
         request.CreatedFrom,
         request.CreatedTo,
         request.ShowDeleted,
         request.ShowCompleted,
         request.Page,
         request.PageSize,                
         request.OrderBy,
         request.Ascending
     );
     return responsibilities.Select(x => new ResponsibilityDtoMapper(x).WithTasks().Map());
 }
        public void Setup()
        {
            _returnedResponsibilities = new List<Responsibility>()
                                        {
                                            new Responsibility()
                                            {
                                                Id = 1324L,
                                                CreatedBy = new UserForAuditing() { Id = Guid.NewGuid() },
                                                CreatedOn = DateTime.Now.AddDays(-12),
                                                Deleted = false,
                                                Description = "description",
                                                InitialTaskReoccurringType = TaskReoccurringType.FiveYearly,
                                                LastModifiedBy = new UserForAuditing() { Id = Guid.NewGuid() },
                                                LastModifiedOn = DateTime.Now,
                                                Owner = new Employee() { Id = Guid.NewGuid() },
                                                Title = "title",
                                                Site = new Site() { Id = 1346624L },
                                                ResponsibilityCategory = new ResponsibilityCategory() { Id = 21345642L },
                                                ResponsibilityReason = new ResponsibilityReason() { Id = 1234523L }
                                            },
                                            new Responsibility()
                                            {
                                                Id = 1325L,
                                                CreatedBy = new UserForAuditing() { Id = Guid.NewGuid() },
                                                CreatedOn = DateTime.Now.AddDays(-12),
                                                Deleted = false,
                                                Description = "description",
                                                InitialTaskReoccurringType = TaskReoccurringType.FiveYearly,
                                                LastModifiedBy = new UserForAuditing() { Id = Guid.NewGuid() },
                                                LastModifiedOn = DateTime.Now,
                                                Owner = new Employee() { Id = Guid.NewGuid() },
                                                Title = "title",
                                                Site = new Site() { Id = 1346624L },
                                                ResponsibilityCategory = new ResponsibilityCategory() { Id = 21345642L },
                                                ResponsibilityReason = new ResponsibilityReason() { Id = 1234523L }
                                            },
                                            new Responsibility()
                                            {
                                                Id = 1326L,
                                                CreatedBy = new UserForAuditing() { Id = Guid.NewGuid() },
                                                CreatedOn = DateTime.Now.AddDays(-12),
                                                Deleted = false,
                                                Description = "description",
                                                InitialTaskReoccurringType = TaskReoccurringType.FiveYearly,
                                                LastModifiedBy = new UserForAuditing() { Id = Guid.NewGuid() },
                                                LastModifiedOn = DateTime.Now,
                                                Owner = new Employee() { Id = Guid.NewGuid() },
                                                Title = "title",
                                                Site = new Site() { Id = 1346624L },
                                                ResponsibilityCategory = new ResponsibilityCategory() { Id = 21345642L },
                                                ResponsibilityReason = new ResponsibilityReason() { Id = 1234523L }
                                            }
                                        };

            _request = new SearchResponsibilitiesRequest()
                                  {
                                      CompanyId = 12345L,
                                      AllowedSiteIds = new List<long>() { 123L, 456L, 789L },
                                      CreatedFrom = DateTime.Now.AddDays(-10),
                                      CreatedTo = DateTime.Now.AddDays(-2),
                                      CurrentUserId = Guid.NewGuid(),
                                      ResponsibilityCategoryId = 1987L,
                                      ShowCompleted = true,
                                      ShowDeleted = true,
                                      SiteGroupId = 498L,
                                      SiteId = 39236L,
                                      Title = "title"
                                  };

            _responsibilityRepository = new Mock<IResponsibilityRepository>();
            _responsibilityRepository
                .Setup(x => x.Search(
                    It.IsAny<Guid>(),
                    It.IsAny<IEnumerable<long>>(),
                    It.IsAny<long>(),
                    It.IsAny<long?>(),
                    It.IsAny<long?>(),
                    It.IsAny<long?>(),
                    It.IsAny<string>(),
                    It.IsAny<DateTime?>(),
                    It.IsAny<DateTime?>(),
                    It.IsAny<bool>(),
                    It.IsAny<bool>(),
                    It.IsAny<int>(),
                    It.IsAny<int>(),
                    It.IsAny<ResponsibilitiesRequestOrderByColumn>(),
                    It.IsAny<bool>()
                ))
                .Returns(_returnedResponsibilities);

            _log = new Mock<IPeninsulaLog>();

        }
        public int Count(SearchResponsibilitiesRequest request)
        {
            var result = _responsibilityRepository.Count(
                request.CurrentUserId,
                request.AllowedSiteIds,
                request.CompanyId,
                request.ResponsibilityCategoryId,
                request.SiteId,
                request.SiteGroupId,
                request.Title,
                request.CreatedFrom,
                request.CreatedTo,
                request.ShowDeleted,
                request.ShowCompleted
            );

            return result;
        }
 private SearchResponsibilitiesRequest CreateSearchResponsibilitiesRequest()
 {
     SearchResponsibilitiesRequest request = new SearchResponsibilitiesRequest()
                                                 {
                                                     CompanyId = _companyId,
                                                     ResponsibilityCategoryId = _categoryId,
                                                     ShowDeleted = _showDeleted,
                                                     SiteId = _siteId,
                                                     SiteGroupId = _siteGroupId,
                                                     Title = _title,
                                                     CreatedFrom =
                                                         string.IsNullOrEmpty(_createdFrom)
                                                             ? (DateTime?) null
                                                             : DateTime.Parse(_createdFrom),
                                                     CreatedTo =
                                                         string.IsNullOrEmpty(_createdTo)
                                                             ? (DateTime?) null
                                                             : DateTime.Parse(_createdTo),
                                                     Page = _page != default(int) ? _page : 1,
                                                     PageSize = _pageSize != default(int) ? _pageSize : DEFAULT_PAGE_SIZE,
                                                     OrderBy = GetOrderBy(),
                                                     Ascending =  Ascending(),
                                                     AllowedSiteIds = _allowedSiteIds
                                                 };
     return request;
 }