public async Task <IActionResult> PutCodeShare([FromRoute] int id, [FromBody] CodeShare codeShare) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != codeShare.Id) { return(BadRequest()); } _context.Entry(codeShare).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CodeShareExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostCodeShare([FromBody] CodeShare codeShare) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CodeShare.Add(codeShare); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCodeShare", new { id = codeShare.Id }, codeShare)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } CodeShare = await _context.CodeShare.FirstOrDefaultAsync(m => m.Id == id); if (CodeShare == null) { return(NotFound()); } return(Page()); }
public async Task<IActionResult> OnPostAsync(int? id) { if (id == null) { return NotFound(); } CodeShare = await _context.CodeShare.FindAsync(id); if (CodeShare != null) { _context.CodeShare.Remove(CodeShare); await _context.SaveChangesAsync(); } return RedirectToPage("./Index"); }