public ActionResult SignupAdmin(Usuarios model, string nombreCompleto, string codigo, string cedula) { if (nombreCompleto == null) { nombreCompleto = ""; } if (cedula == null) { cedula = ""; } var empleadoExiste = (from a in context.Empleados.ToList() join b in context.Usuarios.ToList() on a.ID equals b.EmpleadoID where (a.Nombre + " " + a.Apellido).ToLower() == nombreCompleto.ToLower() && a.Cedula == StringExtenssion.SinGuion(cedula) && a.Tipo == "Tecnico" select new { id = a.ID }).FirstOrDefault(); if (model.EmpleadoID == null && empleadoExiste == null) { nombreCompleto = StringExtenssion.SinTildes(nombreCompleto); Empleados empleado = EmpleadoConsulta.FindEmpledoCredenciales(nombreCompleto, codigo, cedula, "Tecnico", context); if (empleado != null) { ViewBag.EmpleadoID = empleado.ID; } else { ModelState.AddModelError("", "Las credenciales son incorrectas"); } } else if (empleadoExiste != null) { ModelState.AddModelError("", "Existe un usuario creado con estas credenciales"); } else { model.Activo = true; context.Usuarios.Add(model); context.SaveChanges(); UsuarioRol usuarioRol = new UsuarioRol(); usuarioRol.Rol = "Admin"; usuarioRol.UsuarioID = context.Usuarios.ToList().Last().ID; context.UsuarioRol.Add(usuarioRol); context.SaveChanges(); FormsAuthentication.SetAuthCookie(model.Email, false); return(RedirectToAction("ListaMedico", "Admin")); } return(View()); }
private void ActualizarEstado(CitasMedicas citaMedica) { CitasMedicas citaUpdate = db.CitasMedicas.Where(x => x.ID == citaMedica.ID).FirstOrDefault(); citaUpdate.Estado = true; db.SaveChanges(); }
public ActionResult CrearHistorialMedico(HistorialMedico historialMedico, string checkAntecedentes) { string creado = "si"; try { List <Antecedente> antecedentes = JsonConvert.DeserializeObject <List <Antecedente> >(checkAntecedentes).ToList(); historialMedico.Pulmonares = antecedentes.Where(x => x.nombre == "PULMONARES").FirstOrDefault().estado; historialMedico.Digestivos = antecedentes.Where(x => x.nombre == "DIGESTIVOS").FirstOrDefault().estado; historialMedico.Diabetes = antecedentes.Where(x => x.nombre == "DIABETES").FirstOrDefault().estado; historialMedico.Renales = antecedentes.Where(x => x.nombre == "RENALES").FirstOrDefault().estado; historialMedico.Quirurjicos = antecedentes.Where(x => x.nombre == "QUIRURJICOS").FirstOrDefault().estado; historialMedico.Alergicos = antecedentes.Where(x => x.nombre == "ALERGICOS").FirstOrDefault().estado; historialMedico.Transfuciones = antecedentes.Where(x => x.nombre == "TRANSFUCIONES").FirstOrDefault().estado; historialMedico.Alcohol = antecedentes.Where(x => x.nombre == "ALCOHOL").FirstOrDefault().estado; historialMedico.Tabaquismo = antecedentes.Where(x => x.nombre == "TABAQUISMO").FirstOrDefault().estado; historialMedico.Drogas = antecedentes.Where(x => x.nombre == "DROGAS").FirstOrDefault().estado; historialMedico.Inmunizaciones = antecedentes.Where(x => x.nombre == "INMUNIZACIONES").FirstOrDefault().estado; historialMedico.Cardiovascular = antecedentes.Where(x => x.nombre == "CARDIOVASCULAR").FirstOrDefault().estado; historialMedico.Fecha = DateTime.Now; historialMedico.MODIFICADO = DateTime.Now; context.HistorialMedico.Add(historialMedico); context.SaveChanges(); } catch (Exception e) { creado = "no"; } TempData["Creado"] = creado; return(RedirectToAction("HistorialMedico")); }
public ActionResult ActualizarPerfil(string email, string passwordN, HttpPostedFileBase file) { var actualizado = "si"; try { int empleadoID = EmpleadoConsulta.FindEmpleadoEmail(User.Identity.Name, "Admin", context).ID; Empleados empleado = context.Empleados.Where(x => x.ID == empleadoID).FirstOrDefault(); if (file != null) { empleado.Foto = new byte[file.ContentLength]; file.InputStream.Read(empleado.Foto, 0, file.ContentLength); context.SaveChanges(); } Usuarios usuario = context.Usuarios.Where(x => x.EmpleadoID == empleadoID).FirstOrDefault(); usuario.Email = email; if (passwordN != "") { usuario.Password = passwordN; } context.SaveChanges(); FormsAuthentication.SetAuthCookie(Convert.ToString(email), false); } catch (Exception) { actualizado = "no"; } TempData["Actualizado"] = actualizado; return(RedirectToAction("Perfil")); }
public ActionResult ActualizarPerfil(Pacientes paciente, string telMovil, string telCasa, string estadoCivil, string sexo, HttpPostedFileBase file, string email, string passwordN) { var actualizado = "si"; try { int pacienteID = PacienteConsulta.FindPacienteEmail(User.Identity.Name, context).ID; Pacientes pacienteDB = context.Pacientes.Where(x => x.ID == pacienteID).FirstOrDefault(); /*--------------------------------Paciente---*/ if (file != null) { pacienteDB.Foto = new byte[file.ContentLength]; file.InputStream.Read(pacienteDB.Foto, 0, file.ContentLength); } pacienteDB.Nombre = paciente.Nombre; pacienteDB.Apellido = paciente.Apellido; pacienteDB.Direccion = paciente.Direccion; pacienteDB.FechaNacimiento = paciente.FechaNacimiento; pacienteDB.Cedula = StringExtenssion.SinGuion(paciente.Cedula); pacienteDB.EstadoCivil = estadoCivil; pacienteDB.Sexo = sexo; context.SaveChanges(); /*--------------------------------Telefono Paciente---*/ TelefonoPaciente telPaciente = context.TelefonoPaciente.Where(x => x.PacienteID == pacienteDB.ID).FirstOrDefault(); if (telMovil == "" || telMovil == null) { telPaciente.TelefonoMovil = null; } else { telPaciente.TelefonoMovil = StringExtenssion.SinGuion(telMovil); } if (telCasa == "" || telCasa == null) { telPaciente.TelefonoCasa = null; } else { telPaciente.TelefonoCasa = StringExtenssion.SinGuion(telCasa); } context.SaveChanges(); /*--------------------------------Usuario---*/ Usuarios usuario = context.Usuarios.Where(x => x.PacienteID == pacienteID).FirstOrDefault(); usuario.Email = email; if (passwordN != "") { usuario.Password = passwordN; } context.SaveChanges(); FormsAuthentication.SetAuthCookie(Convert.ToString(email), false); } catch (Exception) { actualizado = "no"; } TempData["Actualizado"] = actualizado; return(RedirectToAction("Perfil")); }