예제 #1
0
        public IActionResult AddDoctor(DoctorReq newDoctor)
        {
            var resp = doctorService.addDoctor(newDoctor);

            if (resp == null)
            {
                return(BadRequest("problem z dodaniem doktora"));
            }
            return(Ok(resp));
        }
예제 #2
0
        public IActionResult UpdateDoctor(DoctorReq doctorToUpdate)
        {
            var resp = doctorService.updateDoctor(doctorToUpdate);

            if (resp == null)
            {
                return(BadRequest("problem z updejtem doktora"));
            }

            return(Ok(resp));
        }
예제 #3
0
        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");
        }
예제 #4
0
        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");
        }