private async Task SetOrderReceivedDocumentation(InvoiceInInputModel input) { foreach (var orderTo in input.OrderTos) { var receivedDoc = this.mapper.Map <Documentation>(orderTo.DocumentationRecievedDocumentation); this.documentations.All().FirstOrDefault(d => d.OrderToId == orderTo.Id).RecievedDocumentation = receivedDoc; } await this.documentations.SaveChangesAsync(); }
public async Task <IActionResult> Finish(InvoiceInInputModel input) { var invoiceId = await this.ordersService.FinishInvoiceInAsync(input); if (!this.ordersService.ValidateFinishModel(input.OrderTos)) { await this.invoicesService.MarkInvoiceInForApproval(invoiceId); this.notyfService.Warning(this.localizer["Invoice marked for approval."]); } else { await this.invoicesService.UpdateInvoiceInStatusAsync(invoiceId, InvoiceStatusNames.AwaitingPayment.ToString()); this.notyfService.Success(this.localizer["Order finished."]); } return(this.RedirectToAction("Check")); }
public async Task <string> FinishInvoiceInAsync(InvoiceInInputModel input) { await this.SetOrderReceivedDocumentation(input); var invoiceIn = new InvoiceIn(); invoiceIn = this.mapper.Map <InvoiceInModel, InvoiceIn>(input.InvoiceIn, invoiceIn); foreach (var orderToInput in input.OrderTos) { var orderTo = this.orderTos.All().FirstOrDefault(o => o.Id == orderToInput.Id); orderTo.InvoiceIn = invoiceIn; } await this.invoiceIns.AddAsync(invoiceIn); await this.invoiceIns.SaveChangesAsync(); return(invoiceIn.Id); }
public Task ApproveInvoice(InvoiceInInputModel input) { throw new NotImplementedException(); }