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))));
        }
Esempio n. 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));
            }
        }
        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));
            }
        }