// 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(Order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(Order.OrderId)) { 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.Order.Add(Order); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Order = await _context.Order.FindAsync(id); if (Order != null) { _context.Order.Remove(Order); await _context.SaveChangesAsync(); } 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()); } if (UploadedImage != null) { var file = "./wwwroot/img/" + UploadedImage.FileName; using (var fileStream = new FileStream(file, FileMode.Create)) { await UploadedImage.CopyToAsync(fileStream); } var imageUrl = "/img/" + UploadedImage.FileName; Clothing.ImageUrl = imageUrl; } _context.Clothing.Add(Clothing); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Clothing = await _context.Clothing.FindAsync(id); if (Clothing != null) { var filePath = "./wwwroot" + Clothing.ImageUrl; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } _context.Clothing.Remove(Clothing); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }