public RespuestaActivacion Activate(string codigoStr, string pais) { var _context = new PruebaEntities(); RespuestaActivacion respuesta = new RespuestaActivacion() { Activated = false, Message = "" }; ; int paisId = 0; Int32.TryParse(pais, out paisId); codigo codigo = (from c in _context.codigo where c.codigo1 == codigoStr && c.pais_id == paisId && c.habilitado == 0 select c).FirstOrDefault(); if (codigo != null) { try { codigo.habilitado = 1; _context.SaveChanges(); respuesta.Activated = true; respuesta.Message = "Activacion exitosa"; } catch (Exception ex) { respuesta.Message = ex.Message; } } else { respuesta.Message = "Activación fallida"; } return respuesta; }
public int ActualizaContacto(Paciente paciente) { var _context = new PruebaEntities(); paciente pacienteOld = (from p in _context.paciente where p.id == paciente.id select p).SingleOrDefault(); pacienteOld.calle = paciente.calle; return _context.SaveChanges(); }
public RespuestaRegistroContacto AgregaContacto(Paciente paciente) { var pacienteEntity = PacienteEntityFromPaciente(paciente); var _context = new PruebaEntities(); RespuestaRegistroContacto respuesta = new RespuestaRegistroContacto() { ContactId = -1, Status = 0, Message = "" }; try { _context.paciente.AddObject(pacienteEntity); _context.SaveChanges(); respuesta.ContactId = pacienteEntity.id; respuesta.Message = "Registro de contacto exitoso"; respuesta.Status = 1; } catch (Exception ex) { respuesta.Message = ex.Message; } return respuesta; }
public RespuestaRegistro Update(Doctor doctor) { var _context = new PruebaEntities(); string error = "No se encontró el doctor"; try { var doctorExistente = _context.doctor.FirstOrDefault(d=>d.id == doctor.id); if (doctorExistente != null) { doctorExistente.anio_residencia = doctor.anio_residencia; doctorExistente.nombre = doctor.nombre; doctorExistente.apellido = doctor.apellido; doctorExistente.fecha_nac = Convert.ToDateTime(doctor.fecha_nac); doctorExistente.anio_residencia = doctor.anio_residencia; doctorExistente.pais_id = doctor.pais_id; doctorExistente.estado_id = doctor.estado_id; doctorExistente.ciudad_id = doctor.ciudad_id; doctorExistente.consulta_institucion = doctor.consulta_institucion; doctorExistente.consulta_privada = doctor.consulta_privada; doctorExistente.especialidad_id = doctor.especialidad_id; doctorExistente.genero = doctor.genero; doctorExistente.institucion = doctor.institucion; doctorExistente.residente = doctor.residente; doctorExistente.subespecialidad_id = doctor.subespecialidad_id; doctorExistente.telefono = doctor.telefono; _context.SaveChanges(); return new RespuestaRegistro() { DoctorId = doctor.id, Message = "Actualizacion correcta", Status = 1 }; } } catch (Exception ex) { error = ex.Message; } return new RespuestaRegistro() { DoctorId = doctor.id, Message = error, Status = 0 }; }
public RespuestaRegistro Register(Doctor doctor) { var _context = new PruebaEntities(); var doctorExistente = (from d in _context.doctor where d.usuario.usuario1 == doctor.usuario select d).FirstOrDefault(); if (doctorExistente != null) { return new RespuestaRegistro() { Status = 0, DoctorId = -1, Message=String.Format("El usuario '{0}' ya se encuentra registrado",doctor.usuario)}; } doctor doctorEntity = DoctorEntityFromDoctor(doctor); RespuestaRegistro respuesta = new RespuestaRegistro() { Status = 0, DoctorId = -1 }; try { _context.doctor.AddObject(doctorEntity); _context.SaveChanges(); respuesta.DoctorId = doctorEntity.id; respuesta.Status = 200; respuesta.Message = "Registro exitoso"; } catch (Exception ex) { respuesta.Message = ex.Message; } return respuesta; }