// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(ProviderX).State = EntityState.Modified; Log log = new Log(); log.date = DateTime.Now; log.action = "Edição de Fornecedor"; log.log = ProviderX.nomeFantasia; _context.Lista.Add(log); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProviderXExists(ProviderX.id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Products.Add(Product); Log log = new Log(); log.date = DateTime.Now; log.action = "Adição de novo Produto"; log.log = Product.Name; _context.Lista.Add(log); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ProviderX = await _context.Providers.FindAsync(id); if (ProviderX != null) { _context.Providers.Remove(ProviderX); Log log = new Log(); log.date = DateTime.Now; log.action = "Remoção de Fornecedor"; log.log = ProviderX.nomeFantasia; _context.Lista.Add(log); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Product = await _context.Products.FindAsync(id); if (Product != null) { _context.Products.Remove(Product); Log log = new Log(); log.date = DateTime.Now; log.action = "Remoção de Produto"; log.log = Product.Name; _context.Lista.Add(log); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }