private SelectionFilter CreateFilter(SearchFilterTransferObject data) { var customerRepository = ObjectFactory.GetInstance <ICustomerRepository>(); var projectRepository = ObjectFactory.GetInstance <IProjectRepository>(); var taskRepository = ObjectFactory.GetInstance <ITaskRepository>(); var userRepository = ObjectFactory.GetInstance <IUserRepository>(); var filter = new SelectionFilter(); foreach (var customerId in data.Customers) { filter.AddCustomer(customerRepository.GetByID(customerId)); } foreach (var projectId in data.Projects) { filter.AddProject(projectRepository.GetByID(projectId)); } foreach (var taskId in data.Tasks) { filter.AddTask(taskRepository.GetById(taskId)); } if (data.Users != null) { filter.Users = data.Users.Select(u => userRepository.GetByUserID(u)).ToList(); } filter.DateFrom = data.DateFrom; filter.DateTo = data.DateTo; return(filter); }
public static SearchFilterTransferObject ToDtoObject(this ISearchFilterTransferObject transferObject) { var dtoTransfer = new SearchFilterTransferObject(); dtoTransfer.CustomerIds = transferObject.CustomerIds; dtoTransfer.ProjectIds = transferObject.ProjectIds; dtoTransfer.TaskIds = transferObject.TaskIds; dtoTransfer.Users = transferObject.Users; dtoTransfer.DateFrom = transferObject.DateFrom; dtoTransfer.DateTo = transferObject.DateTo; return(dtoTransfer); }
public Guid CreateExcelSheet(SearchFilterTransferObject data) { try { var excelExportService = ObjectFactory.GetInstance <IExcelExportService>(); return(excelExportService.CreateWorkSheet(CreateFilter(data))); } catch (Exception ex) { OnError(ex); throw; } }
private ISearchFilterTransferObject GetTransferObject(ISelectionFilter selectionFilter, ITimeEntryFilter timeEntryFilter) { var entityTransferObject = new SearchFilterTransferObject(); entityTransferObject.CustomerIds = selectionFilter.Customers.Select(c => c.Id).ToList(); entityTransferObject.ProjectIds = selectionFilter.Projects.Select(p => p.Id).ToList(); entityTransferObject.TaskIds = selectionFilter.Tasks.Select(t => t.Id).ToList(); if (timeEntryFilter != null) { entityTransferObject.Users = timeEntryFilter.Users.Select(u => u.Id).ToList(); entityTransferObject.DateFrom = timeEntryFilter.DateFrom; entityTransferObject.DateTo = timeEntryFilter.DateTo; } return(entityTransferObject); }