コード例 #1
0
        public async Task <IHttpActionResult> Post(HttpRequestMessage request)
        {
            string body = await request.Content.ReadAsStringAsync();

            if (!String.IsNullOrEmpty(body))
            {
                JObject json = JObject.Parse(body);

                using (var medicalAppointment = new MedicalAppointmentContext())
                {
                    var         appointmentobject = JsonConvert.DeserializeObject <Appointment>(json.ToString());
                    Appointment appointment       = new Appointment();
                    appointment.AppointmentId     = Guid.NewGuid();
                    appointment.AppointmentDate   = appointmentobject.AppointmentDate;
                    appointment.SpecialistId      = appointmentobject.SpecialistId;
                    appointment.AppointmentStatus = appointmentobject.AppointmentStatus;
                    appointment.UserId            = appointmentobject.UserId;
                    var newAppointment = medicalAppointment.Appointments.Add(appointment);

                    medicalAppointment.SaveChanges();

                    return(Ok(newAppointment));
                }
            }

            return(BadRequest());
        }
コード例 #2
0
        public IHttpActionResult Post([FromBody] User user)
        {
            using (var medicalAppointment = new MedicalAppointmentContext())
            {
                var newuser = medicalAppointment.Users.Add(user);

                medicalAppointment.SaveChanges();

                return(Ok(newuser));
            }
        }
コード例 #3
0
        public IHttpActionResult Delete(string Id)
        {
            using (var medicalAppointment = new MedicalAppointmentContext())
            {
                var userid = Guid.Parse(Id);

                var user = medicalAppointment.Users.FirstOrDefault(u => u.UserId == userid);

                medicalAppointment.Users.Remove(user);

                medicalAppointment.SaveChanges();

                return(Ok());
            }
        }
コード例 #4
0
        public IHttpActionResult UpdateStatus(Appointment Appointment, string Id)
        {
            using (var medicalAppointment = new MedicalAppointmentContext())
            {
                var Appointmentid = Guid.Parse(Id);

                var oldAppointment = medicalAppointment.Appointments.FirstOrDefault(u => u.AppointmentId == Appointmentid);

                oldAppointment.AppointmentStatus = Appointment.AppointmentStatus;

                medicalAppointment.SaveChanges();

                return(Ok(Appointment));
            }
        }
コード例 #5
0
        public IHttpActionResult Patch([FromBody] User user, string Id)
        {
            using (var medicalAppointment = new MedicalAppointmentContext())
            {
                var userid = Guid.Parse(Id);

                var oldUser = medicalAppointment.Users.FirstOrDefault(u => u.UserId == userid);

                oldUser.Name     = user.Name;
                oldUser.LastName = user.LastName;
                oldUser.Nit      = user.Nit;
                oldUser.Email    = user.Email;

                medicalAppointment.SaveChanges();

                return(Ok(user));
            }
        }