public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Property).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PropertyExists(Property.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Beach.Add(Beach); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Beach = await _context.Beach.FindAsync(id); if (Beach != null) { _context.Beach.Remove(Beach); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Property = await _context.Property.FindAsync(id); if (Property != null) { _context.Property.Remove(Property); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot/uploads", Property.MainImage.FileName); var memory = new MemoryStream(); using (var stream = new FileStream(path, FileMode.Create)) { await Property.MainImage.CopyToAsync(stream); Property.MainImagePath = Property.MainImage.FileName; } _context.Property.Add(Property); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }