public IActionResult Index(string filter) { var protocols = ProtocolMapper.MapManyToViewModel(protocolService.GetProtocols()); if (string.IsNullOrEmpty(filter)) { return(View(protocols)); } return(View(protocols.Where(protocol => protocol.Name.Contains(filter)))); }
public IActionResult Details(int id) { if (id < 1) { return(BadRequest()); } try { var mappedEmployees = EmployeeMapper.MapManyToViewModel(employeeService.GetEmployees()); if (mappedEmployees == null) { mappedEmployees = new List <EmployeeViewModel>(); } var mappedInvoices = InvoiceMapper.MapManyToViewModel(invoiceService.GetInvoices()); if (mappedInvoices == null) { mappedInvoices = new List <InvoiceViewModel>(); } var mappedProducts = ProductMapper.MapManyToViewModel(productService.GetProducts()); if (mappedProducts == null) { mappedProducts = new List <ProductViewModel>(); } var mappedProtocols = ProtocolMapper.MapManyToViewModel(protocolService.GetProtocols()); if (mappedProtocols == null) { mappedProtocols = new List <ProtocolViewModel>(); } var mappedClients = ClientMapper.MapManyToViewModel(clientService.GetClients()); if (mappedClients == null) { mappedClients = new List <ClientViewModel>(); } var order = orderService.GetOrderById(id); var mappedOrder = OrderMapper.MapToViewModel(order, order.Employee, order.Client, order.Product, order.Protocol, order.Invoice); var orderDetails = new OrderDetailsViewModel(mappedEmployees, mappedClients, mappedProducts, mappedProtocols, mappedInvoices, mappedOrder); return(View(orderDetails)); } catch (Exception ex) { return(NotFound(ex.Message)); } }
/// <summary> /// Gets the protocols. /// </summary> /// <param name="customerId"></param> /// <param name="request">The request.</param> /// <param name="isBrief">if set to <c>true</c> [is brief].</param> /// <returns></returns> public async Task <PagedResultDto <ProtocolResponseDto> > GetProtocols( int customerId, SearchProtocolDto request, bool isBrief ) { var protocols = await protocolService.GetProtocols(customerId, request); var result = Mapper.Map <PagedResult <Protocol>, PagedResultDto <ProtocolResponseDto> >( protocols, o => o.Items.Add("isBrief", isBrief) ); result.Results = result.Results.OrderBy(e => e.Name.Value).ToList(); return(result); }
public List <ProtocolResponseModel> GetProtocols() { return(protocolService.GetProtocols()); }
/// <summary> /// Gets all cached entries. /// </summary> /// <param name="customerId">The customer identifier.</param> /// <returns></returns> public async Task <ConcurrentDictionary <Guid, SearchEntryDto> > GetAllCachedEntries(int customerId) { var cacheKey = string.Format(SearchIndexKeyTemplate, customerId); var allCachedEntries = await cacheProvider.Get <ConcurrentDictionary <Guid, SearchEntryDto> >( cacheKey, async() => { var result = new ConcurrentDictionary <Guid, SearchEntryDto>(); var programs = (await programService.FindPrograms(customerId)).Results; var programsResponses = Mapper.Map <IList <Program>, IList <SearchProgramResponseDto> >(programs); foreach (var program in programsResponses) { result.TryAdd(program.Id, program); } var protocols = Mapper.Map <IList <Protocol>, IList <SearchEntryDto> >((await protocolService.GetProtocols(customerId)).Results); foreach (var protocol in protocols) { result.TryAdd(protocol.Id, protocol); } var measurementElements = Mapper.Map <IList <MeasurementElement>, IList <SearchEntryDto> >((await measurementElementsService.GetAll(customerId)).Results); foreach (var measurementElement in measurementElements) { result.TryAdd(measurementElement.Id, measurementElement); } var assessmentElements = Mapper.Map <IList <AssessmentElement>, IList <SearchEntryDto> >((await assessmentElementsService.GetAll(customerId)).Results); foreach (var assessmentElement in assessmentElements) { result.TryAdd(assessmentElement.Id, assessmentElement); } var questionElements = Mapper.Map <IList <QuestionElement>, IList <SearchEntryDto> >((await questionElementService.Find(customerId)).Results); foreach (var questionElement in questionElements) { result.TryAdd(questionElement.Id, questionElement); } var textMediaElements = Mapper.Map <IList <TextMediaElement>, IList <SearchTextAndMediaDto> >((await textMediaElementsService.GetElements(customerId)).Results); foreach (var textMediaElement in textMediaElements) { result.TryAdd(textMediaElement.Id, textMediaElement); } var scaleAnswerSets = Mapper.Map <IList <ScaleAnswerSet>, IList <SearchEntryDto> >((await scaleAnswerSetService.Find(customerId)).Results); foreach (var scaleAnswerSet in scaleAnswerSets) { result.TryAdd(scaleAnswerSet.Id, scaleAnswerSet); } var selectionAnswerSets = Mapper.Map <IList <SelectionAnswerSet>, IList <SearchEntryDto> >((await selectionAnswerSetService.Find(customerId)).Results); foreach (var selectionAnswerSet in selectionAnswerSets) { result.TryAdd(selectionAnswerSet.Id, selectionAnswerSet); } var openEndedAnswerSet = Mapper.Map <AnswerSet, SearchEntryDto>(await openEndedAnswerSetsService.Get(customerId)); result.TryAdd(openEndedAnswerSet.Id, openEndedAnswerSet); return(result); } ); return(allCachedEntries); }