// 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(CategoryToproduct).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryToproductExists(CategoryToproduct.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Slider = await _context.Sliders.FindAsync(id); if (Slider != null) { _context.Sliders.Remove(Slider); await _context.SaveChangesAsync(); } string filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img", "slide", Slider.Name + ".jpg"); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.categories.Add(Categoty); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Categoty = await _context.categories.FindAsync(id); if (Categoty != null) { _context.categories.Remove(Categoty); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Filess = await _context.Filesses.FindAsync(id); if (Filess != null) { _context.Filesses.Remove(Filess); 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()); } _context.Attach(Product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(Product.ProductId)) { return(NotFound()); } else { throw; } } if (Productse.Picture?.Length > 0) { string filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img", Product.Title + Path.GetExtension(Productse.Picture.FileName)); using (var stream = new FileStream(filePath, FileMode.Create)) { Productse.Picture.CopyTo(stream); } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Sliders.Add(Slider); await _context.SaveChangesAsync(); if (Productse.Picture?.Length > 0) { string filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img", "slide", Slider.Name + Path.GetExtension(Productse.Picture.FileName)); using (var stream = new FileStream(filePath, FileMode.Create)) { Productse.Picture.CopyTo(stream); } } return(RedirectToPage("./Index")); }