Exemple #1
0
 public AddDoctorResponse add(AddDoctorRequest request)
 {
     try
     {
         var response = new AddDoctorResponse();
         var bc       = new DoctorComponent();
         response.Result = bc.Add(request.Doctor);
         return(response);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
Exemple #2
0
        public AddDoctorResponse AddDoctor(AddDoctorRequest request)
        {
            var response = new AddDoctorResponse();

            using (var doctorContext = new DoctorDbContext())
            {
                doctorContext.Doctors.Add(request.doctor);
                try
                {
                    doctorContext.SaveChanges();
                    response.message = "INSERT SUCCESSFUL";
                }
                catch (Exception)
                {
                    response.message = "INSERT FAILED";
                }
            }
            return(response);
        }
Exemple #3
0
        public AddDoctorResponse AddDoctor(AddDoctorRequest request)
        {
            var d = new Doctor
            {
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email
            };

            _context.Doctor.Add(d);
            _context.SaveChanges();

            var res = new AddDoctorResponse
            {
                IdDoctor  = d.IdDoctor,
                FirstName = d.FirstName,
                LastName  = d.LastName,
                Email     = d.Email
            };

            return(res);
        }