Exemplo n.º 1
0
        public IHttpActionResult PutCita(Cita cita)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //validations for dates
            if (isIn24hr(cita.Fecha))
            {
                return(BadRequest("La fecha de la cita no puede estar dentro de las proximas 24 horas."));
            }

            //TODO, citas are atteched, I need to detach the context before update
            //if (IsAnyCitaSameDate(cita))
            //{
            //    return BadRequest("Ya posee una cita para ese dia, por favor seleccione otra fecha");
            //}

            //db.Entry(cita).State = EntityState.Modified;
            citaRepository.UpdateCita(cita);
            try
            {
                //await db.SaveChangesAsync();
                citaRepository.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CitaExists(cita.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(cita));
        }
Exemplo n.º 2
0
 public void Save(Cita entity)
 {
     CitaRepository.Save(entity);
 }