public async Task <IActionResult> Put(int id, [FromBody] InvoiceBuyDTO dto) { var dbInvoice = new InvoiceBuy(); if (id > 0) { dbInvoice = await this._invoiceService.QueryableInvoiceBuy() .FirstOrDefaultAsync(f => f.InvoiceBuyId == id); if (dbInvoice == null) { return(BadRequest(bp.sharedLocal.ModelStateHelpful.ModelStateHelpful.ModelError("Błąd", $"Nie znaleziono faktury o ID: {id}"))); } } else { //new entity this._db.Entry(dbInvoice).State = EntityState.Added; } await this._invoiceService.MapperInvoiceBuy(dbInvoice, dto, User); try { await this._db.SaveChangesAsync(); } catch (DbException) { throw; } return(Ok(this._invoiceService.EtoDTOInvoiceBuy(dbInvoice))); }
private InvoicePaymentRemindDTO EtoDTOBasicInvoicePaymentRemind(InvoiceBuy db, InvoicePaymentRemindDTO dto) { var res = dto ?? new InvoicePaymentRemindDTO(); res.Company = this._companyService.CompanyCardMapper(db.CompanySeller); res.Currency = this._invoiceService.EtoDTOCurrency(db.Currency); res.InvoiceId = db.InvoiceBuyId; res.InvoiceNo = db.InvoiceNo; //res.InvoiceTotal = this._invoiceService.EtDTOInvoiceTotal(db.InvoiceTotal); return(res); }