public async Task <IActionResult> Put([FromRoute] int id, StudentMasters student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != student.StdId) { return(BadRequest()); } _context.Entry(student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch { return(NotFound()); } return(NotFound()); }
public async Task <IActionResult> PostStudentMasters([FromBody] StudentMasters studentMasters) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.StudentMasters.Add(studentMasters); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (StudentMastersExists(studentMasters.StdID)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetStudentMasters", new { id = studentMasters.StdID }, studentMasters)); }
public async Task <IActionResult> PutStudentMasters([FromRoute] int id, [FromBody] StudentMasters studentMasters) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != studentMasters.StdID) { return(BadRequest()); } _context.Entry(studentMasters).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentMastersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//To bind initial Student Information private void InitializeData() { _stdInfo = new List <StudentMasters>(); var studentInfo1 = new StudentMasters { StdName = "Shanu", Phone = "+821039120700", Email = "*****@*****.**", Address = "Seoul,Korea" }; var studentInfo2 = new StudentMasters { StdName = "Afraz", Phone = "+821000000700", Email = "*****@*****.**", Address = "Madurai,India" }; var studentInfo3 = new StudentMasters { StdName = "Afreen", Phone = "+821012340700", Email = "*****@*****.**", Address = "Chennai,India" }; _stdInfo.Add(studentInfo1); _stdInfo.Add(studentInfo2); _stdInfo.Add(studentInfo3); }
public IActionResult PostStudentMasters([FromBody] StudentMasters studentMasters) { if (!ModelState.IsValid) { return(HttpBadRequest(ModelState)); } _context.Students.Add(studentMasters); try { _context.SaveChanges(); } catch (DbUpdateException) { if (StudentMastersExists(studentMasters.StdID)) { return(new HttpStatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtRoute("GetStudentMasters", new { id = studentMasters.StdID }, studentMasters)); }
public IActionResult PutStudentMasters(int id, [FromBody] StudentMasters studentMasters) { if (!ModelState.IsValid) { return(HttpBadRequest(ModelState)); } if (id != studentMasters.StdID) { return(HttpBadRequest()); } _context.Entry(studentMasters).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentMastersExists(id)) { return(HttpNotFound()); } else { throw; } } return(new HttpStatusCodeResult(StatusCodes.Status204NoContent)); }
public async Task <IActionResult> PostStudentMasters([FromBody] StudentMasters studentMasters) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.StudentMasters.Add(studentMasters); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStudentMasters", new { id = studentMasters.StdId }, studentMasters)); }
public IActionResult GetStudentMasters([FromRoute] int id) { if (!ModelState.IsValid) { return(HttpBadRequest(ModelState)); } StudentMasters studentMasters = _context.Students.Single(m => m.StdID == id); if (studentMasters == null) { return(HttpNotFound()); } return(Ok(studentMasters)); }
public async Task <IActionResult> DeleteStudentMasters([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } StudentMasters studentMasters = await _context.StudentMasters.SingleOrDefaultAsync(m => m.StdID == id); if (studentMasters == null) { return(NotFound()); } _context.StudentMasters.Remove(studentMasters); await _context.SaveChangesAsync(); return(Ok(studentMasters)); }
public IActionResult DeleteStudentMasters(int id) { if (!ModelState.IsValid) { return(HttpBadRequest(ModelState)); } StudentMasters studentMasters = _context.Students.Single(m => m.StdID == id); if (studentMasters == null) { return(HttpNotFound()); } _context.Students.Remove(studentMasters); _context.SaveChanges(); return(Ok(studentMasters)); }