public ActionResult UpdateProfessor(Guid id, [FromBody] ProfessorForAddOrUpdate professorForUpdate) { if (!ModelState.IsValid) { return(BadRequest()); } var _ = _professorsBusiness.UpdateProfessor(id, professorForUpdate); return(NoContent()); }
public ActionResult <Professor> AddProfessor([FromBody] ProfessorForAddOrUpdate professorForAdd) { if (!ModelState.IsValid) { return(BadRequest()); } var createdProfessor = _professorsBusiness.AddProfessor(professorForAdd); return(Created(string.Empty, createdProfessor)); }
public Professor AddProfessor(ProfessorForAddOrUpdate professor) { var newProfessor = new Professor { Name = professor.Name, Doj = professor.Doj, Salary = professor.Salary, IsPhd = professor.IsPhd, Teaches = professor.Teaches }; _collegeDbContext.Professors.Add(newProfessor); _collegeDbContext.SaveChanges(); return(newProfessor); }
public Professor UpdateProfessor(Guid id, ProfessorForAddOrUpdate professor) { if (!_collegeDbContext.Professors.Any(record => record.ProfessorId == id)) { return(null); } var retrievedProfessor = _collegeDbContext.Professors.Where(record => record.ProfessorId == id).FirstOrDefault(); // Modifying the data retrievedProfessor.Name = professor.Name; retrievedProfessor.Doj = professor.Doj; retrievedProfessor.Salary = professor.Salary; retrievedProfessor.Teaches = professor.Teaches; retrievedProfessor.IsPhd = professor.IsPhd; _collegeDbContext.SaveChanges(); return(retrievedProfessor); }
public Professor UpdateProfessor(Guid id, ProfessorForAddOrUpdate professor) { return(_professorsData.UpdateProfessor(id, professor)); }
public Professor AddProfessor(ProfessorForAddOrUpdate professor) { return(_professorsData.AddProfessor(professor)); }