// 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()); } Product.AddedDate = DateTime.Now; Product.Thumbnail = UploadFile(Product.ThumbnailFile, Product.Thumbnail); _context.Attach(Product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(Product.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.Attach(Category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(Category.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Category.Add(Category); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Product.Thumbnail = UploadFile(Product.ThumbnailFile); Product.AddedDate = DateTime.Now; Product.IsAvailable = true; _context.Category.Where(c => c.ID == Product.CategoryID).FirstOrDefault().Products.Add(Product); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null) { return(NotFound()); } Product = await _context.Product.FindAsync(id); if (Product != null) { _context.Product.Remove(Product); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(Guid?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")); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null || Order.Client.UserName != User.Identity.Name) { return(NotFound()); } Order = await _context.Order.FindAsync(id); if (Order != null) { _context.Order.Remove(Order); await _context.SaveChangesAsync(); } return(RedirectToPage("./Orders")); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null) { return(NotFound()); } Category = await _context.Category.FindAsync(id); if (Category != null) { _context.Category.Remove(Category); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }