public async Task <IActionResult> PutCompany(int id, Company company) { if (id != company.CompanyId) { return(BadRequest()); } _context.Entry(company).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// To protect from overposting attacks, please 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(Contact).State = EntityState.Modified; // System.Diagnostics.Trace.WriteLine(Request.Headers["Referer"].ToString()); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(Contact.ContactId)) { return(NotFound()); } else { throw; } } // Get the Previous Page Url string prevPage = HttpContext.Session.GetString("PreviousUrl"); if (!String.IsNullOrEmpty(prevPage)) { System.Diagnostics.Trace.WriteLine(this.PreviousPage); return(Redirect(prevPage)); } else { return(RedirectToPage("./Index")); } }
// To protect from overposting attacks, please 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.Contacts.Add(Contact); await _context.SaveChangesAsync(); // Get the Previous Page Url string prevPage = HttpContext.Session.GetString("PreviousUrl"); if (!String.IsNullOrEmpty(prevPage)) { return(Redirect(prevPage)); } else { return(RedirectToPage("./Index")); } }