public IHttpActionResult Put(int id, [FromBody] HorarioConsulta sentHorarioConsulta)
        {
            if (id != sentHorarioConsulta.Id)
            {
                return(BadRequest());
            }

            try {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _unitOfWork.HorariosConsulta.Update(sentHorarioConsulta);
                _unitOfWork.Complete();
            }
            catch (Exception) {
                if (_unitOfWork.HorariosConsulta.GetById(id) == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            HorarioConsulta horarioConsulta = db.HorarioConsultas.Find(id);

            db.HorarioConsultas.Remove(horarioConsulta);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "hor_idHorarioConsulta,hor_idMedico,hor_dia,hor_horario")] HorarioConsulta horarioConsulta)
 {
     if (ModelState.IsValid)
     {
         db.Entry(horarioConsulta).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.hor_idMedico = new SelectList(db.Medicos, "med_idMedico", "med_nombre", horarioConsulta.hor_idMedico);
     return(View(horarioConsulta));
 }
        // GET: HorariosConsultas/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HorarioConsulta horarioConsulta = db.HorarioConsultas.Find(id);

            if (horarioConsulta == null)
            {
                return(HttpNotFound());
            }
            return(View(horarioConsulta));
        }
        // GET: HorariosConsultas/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HorarioConsulta horarioConsulta = db.HorarioConsultas.Find(id);

            if (horarioConsulta == null)
            {
                return(HttpNotFound());
            }
            ViewBag.hor_idMedico = new SelectList(db.Medicos, "med_idMedico", "med_nombre", horarioConsulta.hor_idMedico);
            return(View(horarioConsulta));
        }
        public IHttpActionResult Post([FromBody] HorarioConsulta horarioConsulta)
        {
            try {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _unitOfWork.HorariosConsulta.Insert(horarioConsulta);
                _unitOfWork.Complete();

                return(CreatedAtRoute("PostHorarioConsulta", new { id = horarioConsulta.Id }, horarioConsulta));
            }
            catch (Exception ex) {
                // Send the exception as parameter
                return(BadRequest(ex.ToString()));
            }
        }
Exemple #7
0
        public async Task Post(HorarioConsulta entity, string token)
        {
            using (var response = await _apiHelper.ApiClient.PostAsJsonAsync("api/horariosConsulta", entity, x => x.SetAuthHeaders(token)))
            {
                if (!response.IsSuccessStatusCode)
                {
                    switch (response.StatusCode)
                    {
                    case HttpStatusCode.Unauthorized:
                        throw new UnauthorizedRequestException(response);

                    case HttpStatusCode.BadRequest:
                        throw new BadRequestException(response);

                    default:
                        throw new Exception($"{response.ReasonPhrase}: Contacte a soporte para mas detalles");
                    }
                }
            }
        }