public async Task <IActionResult> PutDiversTransaction([FromRoute] int id, [FromBody] DiversTransaction diversTransaction) { try { if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } if (diversTransaction == null) { return(BadRequest("Client object is null")); } if (!_diversRepository.DiversTransactionExists(id)) { return(NotFound()); } await _diversRepository.UpdateDiversTransactionAsync(diversTransaction); return(NoContent()); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public FileDto GetUsersAsPdfAsync(DiversTransaction diversTransaction) { htmlStockage = GetHTMLString(diversTransaction); ObjectSettingsDivers.PagesCount = true; ObjectSettingsDivers.HtmlContent = htmlStockage; ObjectSettingsDivers.WebSettings.DefaultEncoding = "utf-8"; ObjectSettingsDivers.WebSettings.UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "Assets", "Style.css"); ObjectSettingsDivers.WebSettings.LoadImages = true; HtmlToPdfDocumentDivers = new HtmlToPdfDocument() { GlobalSettings = globalSettings, Objects = { ObjectSettingsDivers } }; return(new FileDto("UserList.pdf", _converter.Convert(HtmlToPdfDocumentDivers))); }
public async Task <IActionResult> PostDiversTransaction([FromBody] DiversTransaction diversTransaction) { try { if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } if (diversTransaction == null) { return(BadRequest("Client object is null")); } await _diversRepository.InsertDiversTransactionAsync(diversTransaction); } catch (Exception ex) { return(StatusCode(500, ex)); } return(CreatedAtAction("GetDiversTransaction", new { id = diversTransaction.Id }, diversTransaction)); }
public async Task UpdateDiversTransactionAsync(DiversTransaction diversTransaction) { _context.Entry(diversTransaction).State = EntityState.Modified; await SaveAsync(); }
public async Task DeleteDiversTransactionAsync(DiversTransaction diversTransaction) { _context.DiversTransactions.Remove(diversTransaction); await SaveAsync(); }
public async Task InsertDiversTransactionAsync(DiversTransaction diversTransaction) { _context.DiversTransactions.Add(diversTransaction); await SaveAsync(); }
public string GetHTMLString(DiversTransaction diversTransactiona) { // var sb = new StringBuilder(); StringBuilderDivers.Clear(); StringBuilderDivers.Append(@" <html> <head> <title>Achat huile PDF</title> </ head > <body > <img src='http://*****:*****@" <p class='name'>{0}</p> <p>Nom : {1}</p> <p>Gsm :{2}</p> <p>Tel : {3}</p> </div> <div class='data right'> <div class='title'>Avance N° 00 {4}</div> <div class='date'> Date :{5}<br> </div> </div></div>" , diversTransactiona.Client.Nom, diversTransactiona.Client.Gsm, diversTransactiona.Client.Tel, diversTransactiona.Client.Ville, diversTransactiona.Id, diversTransactiona.Date); StringBuilderDivers.Append(@" <table border = '0' cellspacing='0' cellpadding='0'> <thead> <tr> <th class='desc'>Description</th> <th class='qty'>Type de paiement</th> <th class='total'>Montant</th> </tr> </thead> <tbody>"); StringBuilderDivers.AppendFormat(@" <tr> <td class='desc'><h3> {0}</h3></td> <td class='qty'>{1} L</td> <td class='total'> --- </td> </tr>" , diversTransactiona.TypeTransaction, diversTransactiona.TypeDePaiement); StringBuilderDivers.Append(@"</tbody></table><p><br/><br/><br/>"); StringBuilderDivers.AppendFormat(@" <div class='no-break'> <table class='grand-total'> <tbody><br/><br/> <tr> <td class='desc'></td> <td class='unit' colspan='2'>TOTAL Montant:</td> <td class='total'>{0} .000 Dt</td> </tr> </tbody> </table> </div>" , diversTransactiona.Montant); StringBuilderDivers.Append(@" </div> </section> </body> </html>"); return(StringBuilderDivers.ToString()); }