public IActionResult Create()
        {
            var mappedClients = ClientMapper.MapManyToViewModel(clientService.GetClients());
            var mappedOrders  = OrderMapper.MapManyToViewModel(orderService.GetOrders());

            return(View(new InvoiceCreateViewModel(mappedClients, mappedOrders)));
        }
Example #2
0
        public IActionResult Create()
        {
            var mappedEmployees = EmployeeMapper.MapManyToViewModel(employeeService.GetEmployees());
            var mappedClients   = ClientMapper.MapManyToViewModel(clientService.GetClients());
            var mappedProducts  = ProductMapper.MapManyToViewModel(productService.GetProducts());

            return(View(new OrderCreateViewModel(mappedEmployees, mappedClients, mappedProducts)));
        }
Example #3
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(BadRequest());
            }
            try
            {
                var clients       = clientService.GetClients();
                var orders        = orderService.GetOrders();
                var invoice       = invoiceService.GetInvoiceById(id);
                var mappedInvoice = InvoiceMapper.MapToViewModel(invoice, invoice.Order, invoice.Client);

                var details = new InvoiceDetailsViewModel(ClientMapper.MapManyToViewModel(clients), OrderMapper.MapManyToViewModel(orders));
                details.Invoice = mappedInvoice;

                return(View(details));
            }
            catch (Exception ex)
            {
                return(NotFound(ex));
            }
        }