public async Task <IActionResult> Create(CreateInvoiceViewModel invoiceViewModel) { //var invoice = invoiceViewModel.Invoice; //invoice.SupplierId = invoiceViewModel.SupplierId; //invoice.SubscriberId = invoiceViewModel.SubscriberId; if (ModelState.IsValid) { var invoice = new Invoice() { DateOfIssue = invoiceViewModel.DateOfIssue, DueDate = invoiceViewModel.DueDate, InvoicePayingStatus = InvoicePayingStatus.Unpaid, SubscriberId = invoiceViewModel.SubscriberId, SupplierId = invoiceViewModel.SupplierId }; await _invoicesRepository.AddInvoiceAsync(invoice); return(RedirectToAction(nameof(Index))); } var suppliers = await _invoicesRepository.ListSuppliersAsync(); var subscribers = await _invoicesRepository.ListSubscribersAsync(); //var invoiceViewModel = new InvoiceViewModel //{ // Invoice = invoice, // Suppliers = suppliers.Select(s => new SelectListItem(s.Name, s.Id.ToString())).ToList(), // Subscribers = subscribers.Select(s => new SelectListItem(s.Name, s.Id.ToString())).ToList(), // SupplierId = invoice.SupplierId, // SubscriberId = invoice.SubscriberId //}; return(View(invoiceViewModel)); }