コード例 #1
0
        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))));
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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);
        }