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)); } }
public IActionResult Update(ProtocolViewModel protocol) { if (!ModelState.IsValid) { return(BadRequest()); } try { protocolService.UpdateProtocol(ProtocolMapper.MapToDomainModel(protocol)); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(BadRequest(ex)); } }
public IActionResult Details(int id) { if (id < 1) { return(BadRequest()); } try { var protocol = protocolService.GetProtocolById(id); var mappedProtocol = ProtocolMapper.MapToViewModel(protocol, EmployeeMapper.MapToViewModel(protocol.Employee), OrderMapper.MapToViewModel(protocol.Order)); var details = new ProtocolDetailsViewModel(EmployeeMapper.MapManyToViewModel(employeeService.GetEmployees()), OrderMapper.MapManyToViewModel(orderService.GetOrders()), mappedProtocol); return(View(details)); } catch (Exception ex) { return(NotFound(ex)); } }
public IActionResult Details(int id) { if (id < 1) { return(NotFound()); } try { var employee = (employeeService.GetEmployeeById(id)); var protocols = new List <ProtocolViewModel>(); if (employee.Protocols != null && employee.Protocols.Any()) { protocols = ProtocolMapper.MapManyToViewModel(employee.Protocols).ToList(); } var orders = new List <OrderViewModel>(); if (employee.Orders != null && employee.Orders.Any()) { orders = OrderMapper.MapManyToViewModel(employee.Orders).ToList(); } var mappedEmployee = EmployeeMapper.MapToViewModel(employee, employee.EmployeesQualifications, protocols, orders); var result = new EmployeeDetailsViewModel(QualificationMapper.MapManyToViewModel(qualificationService.GetQualifications()).ToList()) { Employee = mappedEmployee, }; return(View(result)); } catch (Exception ex) { return(NotFound(ex)); } }
public async Task <bool> UpdateProtocolMapperAsync(string realm, string clientScopeId, string protocolMapperId, ProtocolMapper protocolMapperRepresentation) { var response = await GetBaseUrl(realm) .AppendPathSegment($"/admin/realms/{realm}/client-scopes/{clientScopeId}/protocol-mappers/models/{protocolMapperId}") .PutJsonAsync(protocolMapperRepresentation) .ConfigureAwait(false); return(response.IsSuccessStatusCode); }