public async Task <IActionResult> PutStockageOlive([FromRoute] int id, [FromBody] StockageOlive stockageOlive) { try { if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } if (stockageOlive == null) { return(BadRequest("Stockage Olive object is null")); } if (!_stockageOlivesRepository.StockageOliveExists(id)) { return(NotFound()); } if (!_stockageOlivesRepository.StockageOliveExistsTrituration(id)) { return(BadRequest("Ne peut pas terminer cette action , car Trituration existe en facture")); } await _stockageOlivesRepository.UpdateStockageOliveAsync(stockageOlive); return(NoContent()); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public TriturationsService(DataContext context, IMapper mapper) { _context = context; // _templateGenerator = templateGenerator; _mapper = mapper; triturationNew = new Trituration(); stockageOlivess = new StockageOlive(); }
public FileDto GetUsersAsPdfAsync(StockageOlive stockageOlive) { htmlStockage = GetHTMLString(stockageOlive); HtmlToPdfDocumentStockage = null; ObjectSettingsStockage.PagesCount = true; ObjectSettingsStockage.HtmlContent = htmlStockage; ObjectSettingsStockage.WebSettings.DefaultEncoding = "utf-8"; ObjectSettingsStockage.WebSettings.UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "Assets", "Style.css"); ObjectSettingsStockage.WebSettings.LoadImages = true; HtmlToPdfDocumentStockage = new HtmlToPdfDocument() { GlobalSettings = globalSettings, Objects = { ObjectSettingsStockage } }; return(new FileDto("UserList.pdf", _converter.Convert(HtmlToPdfDocumentStockage))); }
public async Task <IActionResult> PostStockageOlives([FromBody] StockageOlive stockageOlives) { try { if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } if (stockageOlives == null) { return(BadRequest("Stockage Olive object is null")); } await _stockageOlivesRepository.InsertStockOliveAsync(stockageOlives); } catch (Exception ex) { return(StatusCode(500, ex)); } return(CreatedAtAction("GetStockageOlive", new { id = stockageOlives.Id }, stockageOlives)); }
public async Task InsertTriturationAsync(Trituration trituration) { triturationNew.Date = trituration.Date; triturationNew.PrixUnitaire = trituration.PrixUnitaire; triturationNew.Montant = trituration.Montant; triturationNew.Rendement = trituration.Rendement; triturationNew.HuileObtenu = trituration.HuileObtenu; triturationNew.QteLivree = trituration.QteLivree; triturationNew.HuileRestante = trituration.HuileRestante; triturationNew.Poids = trituration.Poids; triturationNew.ClientId = trituration.ClientId; triturationNew.VarieteId = trituration.VarieteId; _context.Triturations.Add(triturationNew); _context.SaveChanges(); // var stockolivesDb = _context.StockageOlives.Where(c => c.TriturationId == trituration.Id) foreach (var stock in trituration.StockageOlives) { StockageOlive stok = new StockageOlive() { Id = stock.Id, Poids = stock.Poids, Chauffeur = stock.Chauffeur, Vehicule = stock.Vehicule, Date = stock.Date, VarieteId = stock.VarieteId, ClientId = stock.ClientId, TriturationId = triturationNew.Id, }; _context.Entry(stok).State = EntityState.Modified; _context.SaveChanges(); } await SaveAsync(); triturationNew = null; }
public string GetHTMLString(StockageOlive stockageOlivea) { StringBuilderStockage.Clear(); //var sb = new StringBuilder(); StringBuilderStockage.Append(@" <html> <head> <title>Trituration 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'>Bon Réception N° 00{4}</div> <div class='date'> Date réception:{5}<br> </div> </div></div>" , stockageOlivea.Client.Nom, stockageOlivea.Client.Gsm, stockageOlivea.Client.Tel, stockageOlivea.Client.Ville, stockageOlivea.Id, stockageOlivea.Date); StringBuilderStockage.Append(@" <table border = '0' cellspacing='0' cellpadding='0'> <thead> <tr> <th class='desc'>Description</th> <th class='qty'>Qte</th> <th class='unit'>Chauffeur</th> <th class='total'>Vehicule</th> </tr> </thead> <tbody> <tr>" ); StringBuilderStockage.AppendFormat(@" <td class='desc'><h3>Stockage Olive : {0}</h3></td> <td class='qty'>{1} Kg</td> <td class='unit'>{2}</td> <td class='total'>{3}</td> </tr> </tbody> </table> <p><br/><br/><br/> <div class='no-break'> <table class='grand-total'> <tbody> <tr> <td class='desc'></td> <td class='unit' colspan='2'>QUANTITÉ TOTALE:</td> <td class='total'>{4} Kg</td> </tr> ", stockageOlivea.Variete.Name, stockageOlivea.Poids, stockageOlivea.Chauffeur, stockageOlivea.Vehicule, stockageOlivea.Poids); StringBuilderStockage.Append(@" </tbody> </table> </div> </div> </section> </body> </html>"); return(StringBuilderStockage.ToString()); }
public async Task UpdateStockageOliveAsync(StockageOlive stockageOlive) { _context.Entry(stockageOlive).State = EntityState.Modified; await SaveAsync(); }
public async Task DeleteStockOliveAsync(StockageOlive stockageOlive) { _context.StockageOlives.Remove(stockageOlive); await SaveAsync(); }
public async Task InsertStockOliveAsync(StockageOlive stockageOlive) { _context.StockageOlives.Add(stockageOlive); await SaveAsync(); }