public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(HomePageData).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HomePageDataExists(HomePageData.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Details")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(AboutUs).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AboutUsExists(AboutUs.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Products.Add(Product); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { Product.AddedDate = DateTime.Now; var file = Path.Combine(_environment.ContentRootPath, "wwwroot\\Images", Product.Pic.FileName.Replace(" ", "")); using (var fileStream = new FileStream(file, FileMode.Create)) { await Product.Pic.CopyToAsync(fileStream); } Product.PicUrl = $"/Images/{Product.Pic.FileName.Replace(" ", "")}"; _context.Products.Add(Product); 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); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }