public IActionResult AddDoctor(DoctorReq newDoctor) { var resp = doctorService.addDoctor(newDoctor); if (resp == null) { return(BadRequest("problem z dodaniem doktora")); } return(Ok(resp)); }
public IActionResult UpdateDoctor(DoctorReq doctorToUpdate) { var resp = doctorService.updateDoctor(doctorToUpdate); if (resp == null) { return(BadRequest("problem z updejtem doktora")); } return(Ok(resp)); }
public String addDoctor(DoctorReq doctor) { Doctor doc = new Doctor { FirstName = doctor.FirstName, LastName = doctor.LastName, Email = doctor.Email }; try { context.Doctors.Add(doc); context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(null); } return("dodano doktora"); }
public String updateDoctor(DoctorReq doctor) { Doctor doctorToUpdate = context.Doctors.Where(d => d.IdDoctor == doctor.IdDoctor).FirstOrDefault(); if (doctorToUpdate == null) { return(null); } doctorToUpdate.FirstName = doctor.FirstName; doctorToUpdate.LastName = doctor.LastName; doctorToUpdate.Email = doctor.Email; try { context.Doctors.Update(doctorToUpdate); context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(null); } return("dodano doktora"); }