Пример #1
0
        public async Task <SalesOrderOutput> GetSalesOrderForEdit(NullableIdDto input)
        {
            SalesOrder salesOrder        = null;
            var        salesOrderLine    = new SalesOrderLine();
            var        salesOrderLineDto = new SalesOrderLineDto();
            var        salesOrderOutput  = new SalesOrderOutput();
            List <SalesOrderLineDto> salesOrderLineDtoList = new List <SalesOrderLineDto>();


            //Sales Order
            if (input.Id.HasValue)
            {
                salesOrder = await _salesOrderRepository
                             .GetAllIncluding(
                    s => s.SalesOrderLines
                    ).FirstOrDefaultAsync(s => s.Id.Equals(input.Id));

                foreach (var line in salesOrder.SalesOrderLines.ToList())
                {
                    salesOrderLineDto = new SalesOrderLineDto
                    {
                        Id          = line.Id,
                        Name        = line.Name,
                        Description = line.Description,
                        Quantity    = line.Quantity,
                        Price       = line.Price,
                        Amount      = line.Amount
                    };

                    salesOrderLineDtoList.Add(salesOrderLineDto);
                }
                salesOrderOutput.SalesOrder      = ObjectMapper.Map <SalesOrderDto>(salesOrder);
                salesOrderOutput.SalesOrderLines = salesOrderLineDtoList;
            }
            else
            {
                salesOrderLineDto = new SalesOrderLineDto
                {
                    Id          = 0,
                    Name        = "",
                    Description = "",
                    Quantity    = 0,
                    Price       = 0,
                    Amount      = 0
                };

                salesOrderLineDtoList.Add(salesOrderLineDto);
                salesOrderOutput.SalesOrderLines = salesOrderLineDtoList;
            }


            //Sales Order
            salesOrderOutput.SalesOrder = salesOrder != null
                        ? ObjectMapper.Map <SalesOrderDto>(salesOrder)
                        : new SalesOrderDto();



            //salesOrderOutput.Customers

            var customers = _lookup_customerRepository
                            .GetAll()
                            .Select(c => new ComboboxItemDto(c.Id.ToString(), c.Name + " (" + c.Company + ")")
            {
                IsSelected = salesOrderOutput.SalesOrder.CustomerId == c.Id
            })
                            .ToList();

            if (!input.Id.HasValue)
            {
                var def = new ComboboxItemDto("", "Please select ...")
                {
                    IsSelected = true
                };

                customers.Add(def);
            }

            salesOrderOutput.Customers = customers;

            //ProductionStatus
            salesOrderOutput.ProductionStatuses = _lookup_productionStatusRepository
                                                  .GetAll()
                                                  .Select(c => new ComboboxItemDto(c.Id.ToString(), c.Name)
            {
                IsSelected = salesOrderOutput.SalesOrder.ProductionStatusId == c.Id
            })
                                                  .ToList();



            return(salesOrderOutput);
        }
Пример #2
0
 public SalesOrderLineOutput()
 {
     Machines       = new List <ComboboxItemDto>();
     Materials      = new List <ComboboxItemDto>();
     SalesOrderLine = new SalesOrderLineDto();
 }
Пример #3
0
        public async Task <SalesOrderOutput> GetSalesOrderForCreate()
        {
            //VARIABLES
            var output = new SalesOrderOutput();

            var salesOrderDto   = new SalesOrderDto();
            var salesInvoiceDto = new SalesInvoiceDto();

            var salesOrderLineDto     = new SalesOrderLineDto();
            var salesOrderLineDtoList = new List <SalesOrderLineDto>();

            var salesInvoiceAdditionalCostDto     = new SalesInvoiceAdditionalCostDto();
            var salesInvoiceAdditionalCostDtoList = new List <SalesInvoiceAdditionalCostDto>();

            var salesInvoicePaymentDto     = new SalesInvoicePaymentDto();
            var salesInvoicePaymentDtoList = new List <SalesInvoicePaymentDto>();

            //DEFAULT SELECTED COMBOBOX
            var defaultSelectedCombobox = new ComboboxItemDto("0", "Please select ...")
            {
                IsSelected = true
            };


            //CUSTOMER LOOKUP
            var customers = _lookup_customerRepository
                            .GetAll()
                            .Select(c => new ComboboxItemDto(c.Id.ToString(), c.Name + " (" + c.Company + ")"))
                            .ToList();

            customers.Add(defaultSelectedCombobox);
            output.Customers = customers;

            //PRODUCTION STATUS LOOKUP
            var productionStatuses = _lookup_productionStatusRepository
                                     .GetAll()
                                     .Select(s => new ComboboxItemDto(s.Id.ToString(), s.Name))
                                     .ToList();

            output.ProductionStatuses = productionStatuses;

            //EMPTY SALES ORDER
            salesOrderDto.Id       = null;
            salesOrderDto.Number   = "";
            salesOrderDto.Date     = DateTime.Now;
            salesOrderDto.Deadline = DateTime.Now;

            output.SalesOrder = salesOrderDto;

            //EMPTY SALES ORDER LINE
            salesOrderLineDto.Id            = 0;
            salesOrderLineDto.Name          = "";
            salesOrderLineDto.Description   = "";
            salesOrderLineDto.MarkForDelete = false;

            salesOrderLineDtoList.Add(salesOrderLineDto);
            output.SalesOrderLines = salesOrderLineDtoList;

            //EMPTY SALES INVOICE ADDTIONAL COST
            salesInvoiceAdditionalCostDto.Id            = 0;
            salesInvoiceAdditionalCostDto.Name          = "";
            salesInvoiceAdditionalCostDto.Description   = "";
            salesInvoiceAdditionalCostDto.MarkForDelete = false;

            salesInvoiceAdditionalCostDtoList.Add(salesInvoiceAdditionalCostDto);
            output.SalesInvoiceAdditionalCosts = salesInvoiceAdditionalCostDtoList;


            //EMPTY SALES INVOICE PAYMENT
            salesInvoicePaymentDto.Id            = 0;
            salesInvoicePaymentDto.Date          = DateTime.Now;
            salesInvoicePaymentDto.MarkForDelete = false;

            salesInvoicePaymentDtoList.Add(salesInvoicePaymentDto);
            output.SalesInvoicePayments = salesInvoicePaymentDtoList;



            //PAYMENT METHOD LOOKUP
            //var paymentMethod = _lookup_paymentMethodRepository
            //    .GetAll()
            //    .Select(c => new ComboboxItemDto(c.Id.ToString(), c.Name ))
            //    .ToList();

            //paymentMethod.Add(defaultSelectedCombobox);

            // ViewData["PaymentMethod"] = paymentMethod;



            //var paymentMethod = _paymentMethodRepo.GetAll().OrderBy(p => p.Name);
            //ViewData["PaymentMethod"] = new SelectList(paymentMethod, "ID", "Name");


            //RETURN
            return(output);
        }