public Resultado DesasignarHijoPadre(Hijo hijo, Padre padre, UsuarioLogueado usuarioLogueado) { Resultado NuevoResultado = new Resultado(); if (usuarioLogueado.RolSeleccionado == Roles.Directora) { var hijosPadre = padre.Hijos != null?padre.Hijos.ToList() : new List <Hijo>(); if (hijosPadre.Any(x => x.Id == hijo.Id) == true) { hijosPadre.Remove(hijo); } else { NuevoResultado.Errores.Add("No se encontro el hijo"); } padre.Hijos = hijosPadre.ToArray(); LeerPadres(); ListaPadres.Find(x => x.Id == padre.Id).Hijos = padre.Hijos; //obtiene el padre y le asigna los hijos que tenga GuardarPadres(ListaPadres); } else { NuevoResultado.Errores.Add("No tiene permiso para desasignar"); } return(NuevoResultado); }
public bool UpdateHijo(int id, Hijo hijo) { try { SqlCommand cmd = new SqlCommand("sp_hijos_update", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdDerHab", hijo.IdDerHab); cmd.Parameters.AddWithValue("@ApPaterno", hijo.ApPaterno); cmd.Parameters.AddWithValue("@ApMaterno", hijo.ApMaterno); cmd.Parameters.AddWithValue("@Nombre1", hijo.Nombre1); cmd.Parameters.AddWithValue("@Nombre2", hijo.Nombre2); cmd.Parameters.AddWithValue("@FchNac", hijo.FchNac); con.Open(); cmd.ExecuteNonQuery(); con.Close(); return(true); } catch (Exception ex) { if (con.State == ConnectionState.Open) { con.Close(); } throw ex; } }
public IHttpActionResult EditChilds(HijoEntity model) { try { using (var ts = new TransactionScope()) { Hijo hijo = new Hijo(); if (model.HijoId.HasValue) { hijo = context.Hijo.FirstOrDefault(x => x.HijoId == model.HijoId); } hijo.NombreCompleto = model.NombreCompleto; hijo.FechaNacimiento = model.FechaNacimiento; context.SaveChanges(); ts.Complete(); } response.Data = "Hijo Actualizada con éxito"; response.Error = false; response.Message = "Success"; return(Ok(response)); } catch (Exception ex) { return(Unauthorized()); } }
public ActionResult Form(int id = 0, bool readOnly = false, bool delete = false) { var usuario = new Hijo(); ViewBag.Title = "Nuevo alumno"; if (id != 0) { usuario = servicio.ObtenerAlumnoPorId(usuarioLogueado, id); if (delete) { ViewBag.Title = "Eliminar alumno"; } else { ViewBag.Title = "Editar alumno"; } } if (usuario == null) { return(RedirectToAction("Index")); } ViewBag.ReadOnly = readOnly; ViewBag.Delete = delete; ViewBag.Salas = new SelectList(servicio.ObtenerSalasPorInstitucion(usuarioLogueado), "Id", "Nombre", usuario?.Sala?.Id); return(View(usuario)); }
public int AddHijo(Hijo hijo) { int lastId = 0; using (SqlConnection connection = GetConnection()) { try { connection.Open(); SqlCommand command = new SqlCommand(@"addHijo", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@IdPersonal", hijo.IdPersonal); command.Parameters.AddWithValue("@ApPaterno", hijo.ApPaterno); command.Parameters.AddWithValue("@ApMaterno", hijo.ApMaterno); command.Parameters.AddWithValue("@Nombre1", hijo.Nombre1); command.Parameters.AddWithValue("@Nombre2", hijo.Nombre2); command.Parameters.AddWithValue("@FchNac", hijo.FchNac); command.Parameters.Add("@IdDerhab", SqlDbType.Int).Direction = ParameterDirection.Output; command.ExecuteNonQuery(); lastId = int.Parse(command.Parameters["@IdDerhab"].Value.ToString()); return(lastId); } catch (Exception ex) { throw new Exception(ex.Message); } finally { connection.Close(); } } }
//Bien resuelto public Resultado AltaNota(Nota nota, Sala[] salas, Hijo[] hijos) { List <Hijo> ListaHijos = Archivos.Instancia.ObtenerHijos(); if (hijos == null || hijos.Length == 0) { hijos = new Hijo[] { }; foreach (var sala in salas) { hijos = ListaHijos.Where(x => x.Sala.Id == sala.Id).ToArray(); } } foreach (int id in hijos.ToList().Select(x => x.Id)) { Hijo hijo = ListaHijos.Single(x => x.Id == id); if (hijo.Notas is null) { hijo.Notas = new Nota[] { nota }; } else { List <Nota> Notas = hijo.Notas.ToList(); nota.Id = hijo.Notas.Length; nota.FechaEventoAsociado = DateTime.Today; Notas.Add(nota); hijo.Notas = Notas.ToArray(); }; } Archivos.Instancia.ModificarArchivoHijos(ListaHijos); return(new Resultado()); }
public Resultado EditarAlumno(int id, Hijo hijo, UsuarioLogueado usuarioLogueado) { _alumnos.RemoveAll(x => x.Id == id); _alumnos.Add(hijo); return(new Resultado()); }
public Resultado BajaAlumno(int id, Hijo hijo) { Resultado Controlador = new Resultado(); int indice = 0; List <HijoJson> listaHijosa = GetHijosJson(); HijoJson usuarioHijo = listaHijosa.Where(x => x.Id == id).FirstOrDefault(); indice = listaHijosa.IndexOf(usuarioHijo); if (usuarioHijo == null) { Controlador.Errores.Add("No existe este Alumno."); return(Controlador); } listaHijosa.RemoveAt(listaHijosa.IndexOf(usuarioHijo)); string outputHijos = JsonConvert.SerializeObject(listaHijosa); using (StreamWriter strWriter = new System.IO.StreamWriter(path + "Hijos.txt", false)) { strWriter.Write(outputHijos); } return(Controlador); }
public IHttpActionResult AddChilds(HijoEntity model) { try { using (var ts = new TransactionScope()) { Hijo hijo = new Hijo(); if (!model.HijoId.HasValue) { context.Hijo.Add(hijo); hijo.Estado = ConstantHelpers.ESTADO.ACTIVO; hijo.FechaRegistro = DateTime.Now; hijo.PadreId = model.PadreId; } hijo.NombreCompleto = model.NombreCompleto; hijo.FechaNacimiento = model.FechaNacimiento; context.SaveChanges(); ts.Complete(); } response.Data = "Hijo agregado con éxito"; response.Error = false; response.Message = "Success"; return(Ok(response)); } catch (Exception ex) { return(Unauthorized()); } }
public static int Main() { Hijo h = new Hijo(); h.Incrementa(1.0); h.print(); return 100; }
public Boolean actualizarHijos(Hijo hijo) { connection.ConnectionString = conexionADO.GetCnx(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "usp_ActualizarHijos"; try { command.Parameters.Clear(); command.Parameters.AddWithValue("@vid_personal", hijo.IdPersonal); command.Parameters.AddWithValue("@vape_pat", hijo.ApPaterno); command.Parameters.AddWithValue("@vape_mat", hijo.ApMaterno); command.Parameters.AddWithValue("@vnom1", hijo.Nombre1); command.Parameters.AddWithValue("@vnom2", hijo.Nombre2); command.Parameters.AddWithValue("@vfec_nac", hijo.FchNac); command.Parameters.AddWithValue("@vid_derhab", hijo.IdDerhab); connection.Open(); command.ExecuteNonQuery(); return(true); } catch (SqlException ex) { throw new Exception(ex.Message); } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } }
public Resultado AltaHijo(Hijo hijo) { Resultado Controlador = new Resultado(); List <HijoJson> hijos = GetHijosJson(); if (hijos.Where(x => x.Email == hijo.Email).FirstOrDefault() != null) { Controlador.Errores.Add("Hijo cargado anteriormente."); return(Controlador); } hijos.Add(new HijoJson() { Id = hijos.Count > 0 ? hijos.Max(x => x.Id) + 1 : 1, Nombre = hijo.Nombre, Apellido = hijo.Apellido, Email = hijo.Email, FechaNacimiento = hijo.FechaNacimiento, ResultadoUltimaEvaluacionAnual = hijo.ResultadoUltimaEvaluacionAnual, idInstitucion = hijo.Institucion != null ? hijo.Institucion.Id : 0, idNotasAlumno = new int[] { }, idSala = hijo.Sala.Id, }); string outputHijos = JsonConvert.SerializeObject(hijos); using (StreamWriter strWriter = new System.IO.StreamWriter(path + "Hijos.txt", false)) { strWriter.Write(outputHijos); } return(Controlador); }
public Resultado DesasignarHijoPadre(Hijo hijo, Padre padre, UsuarioLogueado usuariologueado) { CrearArchivos(); LeerPadres(); var resultado = new Resultado(); if (VerificarUsuarioLogeado(Roles.Directora, usuariologueado).EsValido) { var listahijos = padre.Hijos != null?padre.Hijos.ToList() : new List <Hijo>(); if (listahijos.Any(x => x.Id == hijo.Id) == false) //Verifica que el hijo a agregar no este repetido { listahijos.Add(hijo); } else { resultado.Errores.Add("El hijo ya esta asignado"); } padre.Hijos = listahijos.ToArray(); EditarPadre(padre.Id, padre, usuariologueado); //Modifica el padre asignandole los hijos GuardarPadre(ListaPadres); } return(resultado); }
public async Task <IActionResult> Edit(int id, [Bind("IdHijo,Identificacion,Nombre,Apellido1,Apellido2,FechaDeNac")] Hijo hijo) { if (id != hijo.IdHijo) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hijo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HijoExists(hijo.IdHijo)) { return(NotFound()); } else { throw; } } Thread.Sleep(1000); return(RedirectToAction(nameof(Index))); } return(View(hijo)); }
public Resultado AltaAlumno(Hijo hijo, UsuarioLogueado usuarioLogueado) { hijo.Id = _alumnos.Count + 1; _alumnos.Add(hijo); return(new Resultado()); }
public ActionResult DeleteConAjax(Hijo hijo) { Hijo hijoFind = _context.Hijo.Find(hijo.IdHijo); _context.Hijo.Remove(hijoFind); _context.SaveChanges(); return(Json(new { result = true, })); }
static void Main(string[] args) { Hijo.mensajePadreHeredado(); Hijo.Print(); Console.Read(); }
public ActionResult CreateConAjax(Hijo hijo) { if (ModelState.IsValid) { return(Json(new { result = true })); } return(Json(new { result = false })); }
public ActionResult EditConAjax(Hijo hijo) { if (ModelState.IsValid) { _context.SaveChanges(); return(Json(new { result = true })); } return(Json(new { result = false })); }
static void Main(string[] args) { Hijo herencia = new Hijo(); herencia.Saludar(); herencia.Despedirse(); Console.ReadKey(); }
public void dejarDeApuntar() { anim.SetLayerWeight(1, 0); Hijo.SetActive(false); if (numBolas <= 0) { devolverControl(); Destroy(this.gameObject); } }
public Resultado MarcarNotaComoLeida(Nota nota, UsuarioLogueado usuarioLogueado) { List <Hijo> hijos = Archivos.Instancia.ObtenerHijos(); Hijo hijo = hijos.Find(x => x.Id == ObtenerPersonas(usuarioLogueado).ToList().Single(y => y.Notas.Single(z => z.Id == nota.Id) != null).Id); Nota Nota = hijo.Notas.Single(x => x.Id == nota.Id); Nota.Leida = true; Archivos.Instancia.ModificarArchivoHijos(hijos); return(new Resultado()); }
public Resultado DesasignarHijoPadre(Hijo hijo, Padre padre, UsuarioLogueado usuarioLogueado) { if (!usuarioLogueado.Roles.Contains(Roles.Directora)) { throw new NotImplementedException(); } else { return(Principal.Instancia.DesasignarHijoPadre(hijo, padre)); } }
public Resultado AltaAlumno(Hijo hijo, UsuarioLogueado usuarioLogueado) { if (!usuarioLogueado.Roles.Contains(Roles.Directora)) { throw new NotImplementedException(); } else { return(Principal.Instancia.AltaHijo(hijo)); } }
public Resultado EliminarAlumno(int id, Hijo hijo, UsuarioLogueado usuarioLogueado) { if (!usuarioLogueado.Roles.Contains(Roles.Directora)) { throw new NotImplementedException(); } else { return(Principal.Instancia.EliminarHijo(id)); } }
public Resultado DesasignarHijoPadre(Hijo hijo, Padre padre, UsuarioLogueado usuarioLogueado) { Resultado Controlador = new Resultado(); if (usuarioLogueado.RolSeleccionado != Roles.Directora && usuarioLogueado.RolSeleccionado != Roles.Docente) { Controlador.Errores.Add("No tiene permisos para desasignar una hijo de un padre/madre."); return(Controlador); } return(Principal.Instance.AsignarDesasignarHijo(hijo.Id, padre, false)); }
public Resultado AltaAlumno(Hijo hijo, UsuarioLogueado usuarioLogueado) { Resultado Controlador = new Resultado(); if (usuarioLogueado.RolSeleccionado != Roles.Directora && usuarioLogueado.RolSeleccionado != Roles.Docente) { Controlador.Errores.Add("No tiene permisos para dar de alta un Alumno"); return(Controlador); } return(Principal.Instance.AltaHijo(hijo)); }
public Resultado EditarAlumno(int id, Hijo hijo, UsuarioLogueado usuarioLogueado) { Resultado Controlador = new Resultado(); if (usuarioLogueado.RolSeleccionado != Roles.Directora && usuarioLogueado.RolSeleccionado != Roles.Docente) { Controlador.Errores.Add("No tiene permisos para editar un Alumno"); return(Controlador); } Controlador = Principal.Instance.ModificarAlumno(id, hijo); return(Controlador); }
public void addHijoTest() { Madre isabel = new Madre("Isabel"); Padre paquirri = new Padre("Paquirri"); string nombreHijo = "DJ Kiko"; Hijo kiko = new Hijo(nombreHijo); isabel.addHijo(kiko); Assert.IsTrue(isabel.Hijos.Contains(kiko)); Assert.IsTrue(paquirri.Hijos.Contains(kiko)); }
public IActionResult Hijo(int idDerhab) { try { Hijo hijo = business.Hijo(idDerhab); return(Ok(hijo)); } catch { return(StatusCode(500)); } }