public async Task <string> Put(int id, object user) { StudentRegisteration studentRegisteration = (StudentRegisteration)user; if (id != studentRegisteration.Id) { return("fail"); } _context.Entry(studentRegisteration).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(id)) { return("fail"); } else { return("fail"); } } return("success"); }
public async Task <IActionResult> PostStudentRegisteration([FromBody] StudentRegisteration studentRegisteration) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _userBl("StudentRegisteration").Post(studentRegisteration); return(CreatedAtAction("GetStudentRegisteration", new { id = studentRegisteration.Id }, studentRegisteration)); }
public async Task <IActionResult> PostStudentRegisteration([FromBody] StudentRegisteration studentRegisteration) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.StudentRegisterations.Add(studentRegisteration); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStudentRegisteration", new { id = studentRegisteration.Id }, studentRegisteration)); }
public async Task <object> Get(int id) { var studentRegisteration = new StudentRegisteration(); try { studentRegisteration = await _context.StudentRegisterations.FindAsync(id); } catch (Exception e) { Console.WriteLine(e); throw; } return(studentRegisteration); }
public async Task <string> Post(object user) { StudentRegisteration studentRegisteration = (StudentRegisteration)user; try { _context.StudentRegisterations.Add(studentRegisteration); await _context.SaveChangesAsync(); } catch (Exception e) { return("fail"); } return("pass"); }
public async Task <IActionResult> PutStudentRegisteration([FromRoute] int id, [FromBody] StudentRegisteration studentRegisteration) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != studentRegisteration.Id) { return(BadRequest()); } _context.Entry(studentRegisteration).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentRegisterationExists(id)) { return(NotFound()); } else { return(NoContent()); } } return(NoContent()); }
public async Task <IActionResult> PutStudentRegisteration([FromRoute] int id, [FromBody] StudentRegisteration studentRegisteration) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != studentRegisteration.Id) { return(BadRequest()); } try { await _userBl("StudentRegisteration").Put(id, studentRegisteration); } catch (DbUpdateConcurrencyException) { if (!StudentRegisterationExists(id)) { return(NotFound()); } else { return(NoContent()); } } return(NoContent()); }