コード例 #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 QualificationViewModel MapToViewModel(Qualification qualification, ICollection <EmployeesQualifications> employeesQualifications)
        {
            var mappedEmployees = new List <EmployeeViewModel>();

            foreach (var employeeQualification in employeesQualifications)
            {
                mappedEmployees.Add(EmployeeMapper.MapToViewModel(employeeQualification.Employee));
            }

            return(new QualificationViewModel()
            {
                Id = qualification.Id,
                Description = qualification.Description,
                Name = qualification.Name,
                QualificationType = qualification.QualificationType,
                Employees = mappedEmployees
            });
        }