コード例 #1
0
ファイル: OrderMapper.cs プロジェクト: piotrekp9/Application
        public static OrderViewModel MapToViewModel(Order order, Employee employee, Client client, Product product, Protocol protocol, Invoice invoice)
        {
            var orderVm = new OrderViewModel()
            {
                Id                = order.Id,
                Description       = order.Description,
                AcutalFinishDate  = order.AcutalFinishDate,
                OrderPriority     = order.OrderPriority,
                OrderStatus       = order.OrderStatus,
                PlannedFinishDate = order.PlannedFinishDate,
                StartDate         = order.StartDate,
                Title             = order.Title,
                Client            = ClientMapper.MapToViewModel(client),
                Employee          = EmployeeMapper.MapToViewModel(employee),
                Product           = ProductMapper.MapToViewModel(product),
            };

            if (invoice != null)
            {
                orderVm.Invoice = InvoiceMapper.MapToViewModel(invoice);
            }
            if (protocol != null)
            {
                orderVm.Protocol = ProtocolMapper.MapToViewModel(protocol);
            }

            return(orderVm);
        }
コード例 #2
0
        public static ClientViewModel MapToViewModel(Client client, IEnumerable <Order> orders, IEnumerable <Invoice> invoices)
        {
            var mappedOrders   = OrderMapper.MapManyToViewModel(orders);
            var mappedInvoices = InvoiceMapper.MapManyToViewModel(invoices);

            return(new ClientViewModel()
            {
                Id = client.Id,
                City = client.City,
                Email = client.Email,
                Name = client.Name,
                NIP = client.NIP,
                PESEL = client.PESEL,
                PhoneNumber = client.PhoneNumber,
                PostalCode = client.PostalCode,
                REGON = client.REGON,
                Street = client.Street,
                Invoices = mappedInvoices,
                Orders = mappedOrders
            });
        }