public async Task <ActionResult <alumnos> > Postalumnos(alumnos alumnos) { _context.alumnos.Add(alumnos); await _context.SaveChangesAsync(); return(CreatedAtAction("Getalumnos", new { id = alumnos.id_alumnos }, alumnos)); }
public IHttpActionResult Putalumnos(int id, alumnos alumnos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != alumnos.id) { return(BadRequest()); } db.Entry(alumnos).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!alumnosExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult <alumnos> > PostAlumnosItems(alumnos item) { context.alumnos.Add(item); await context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetAlumnosItems), new { id2 = item.id }, item)); }
public Examen(examenes examen, alumnos alumnoLogueado) { InitializeComponent(); this.DataContext = new ExamenVM(examen, alumnoLogueado); AlumnoLogueado = alumnoLogueado; time = TimeSpan.FromMinutes(examen.duracion); timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate { TiempoRestanteTextBlock.Text = time.ToString("c"); if (time == TimeSpan.Zero) { timer.Stop(); MessageBox.Show("Se acabó el tiempo", "Examen terminado", MessageBoxButton.OK, MessageBoxImage.Information); TerminarExamen(); } if (time == TimeSpan.FromMinutes(10)) { MessageBox.Show("Quedan 10 minutos", "Tiempo restante", MessageBoxButton.OK, MessageBoxImage.Information); } time = time.Add(TimeSpan.FromSeconds(-1)); }, Application.Current.Dispatcher); timer.Start(); }
public async Task <IActionResult> Putalumnos(int id, alumnos alumnos) { if (id != alumnos.id_alumnos) { return(BadRequest()); } _context.Entry(alumnos).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(CreatedAtAction("Getalumnos", new { id = alumnos.id_alumnos }, alumnos)); } catch (DbUpdateConcurrencyException) { if (!alumnosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void CorregirExamen(long idExamen, long idAlumno) { examenes examen = BBDDService.getExamenById(idExamen); alumnos alumno = BBDDService.getAlumnoById(idAlumno); CorregirExamen corregirVentana = new CorregirExamen(examen, alumno); corregirVentana.ShowDialog(); }
public ActionResult Editar([Bind(Include = "id,Nombre,Apellido,Edad")] alumnos alumnos) { if (ModelState.IsValid) { db.Entry(alumnos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(alumnos)); }
// // GET: /Alumnos/Edit/5 public ActionResult Edit(int id, string id_alum) { alumnos alumno = db.alumnos.Find(id, id_alum); if (alumno == null) { return(HttpNotFound()); } return(View(alumno)); }
public IHttpActionResult Getalumnos(int id) { alumnos alumnos = db.alumnos.Find(id); if (alumnos == null) { return(NotFound()); } return(Ok(alumnos)); }
// GET api/Default1/5 //[BasicAuthentication] public alumnos Getalumnos(int id) { alumnos alumnos = db.alumnos.Find(id); if (alumnos == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(alumnos); }
public ActionResult Crear([Bind(Include = "id,Nombre,Apellido,Edad")] alumnos alumnos) { if (ModelState.IsValid) { db.alumnos.Add(alumnos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(alumnos)); }
public IHttpActionResult Postalumnos(alumnos alumnos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.alumnos.Add(alumnos); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = alumnos.id }, alumnos)); }
public async Task <IActionResult> PutCuestionarioItem(int id, alumnos item) { if (id != item.id) { return(BadRequest()); } context.Entry(item).State = EntityState.Modified; await context.SaveChangesAsync(); return(NoContent()); }
// GET: alumnos/Edit/5 public ActionResult Editar(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } alumnos alumnos = db.alumnos.Find(id); if (alumnos == null) { return(HttpNotFound()); } return(View(alumnos)); }
public ActionResult EliminarConfirmed(int id) { try { alumnos alumnos = db.alumnos.Find(id); db.alumnos.Remove(alumnos); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception e) { return(RedirectToAction("Eliminar", new { id = id, error = "It can not be deleted because it is being used " })); } }
public IHttpActionResult Deletealumnos(int id) { alumnos alumnos = db.alumnos.Find(id); if (alumnos == null) { return(NotFound()); } db.alumnos.Remove(alumnos); db.SaveChanges(); return(Ok(alumnos)); }
public AlumnoVM(usuarios usuarioLogueado) { if (usuarioLogueado.roles.Contains("ROLE_ADMIN")) { CursosMatriculados = BBDDService.getCursos(); AlumnoLogueado = new alumnos(); AlumnoLogueado.nombre = usuarioLogueado.username; cursos c = new cursos(); } else { AlumnoLogueado = BBDDService.getAlumnoByUsername(usuarioLogueado.username); CursosMatriculados = new ObservableCollection <cursos>(AlumnoLogueado.cursos); } }
// POST api/Default1 public HttpResponseMessage Postalumnos(alumnos alumnos) { if (ModelState.IsValid) { db.alumnos.Add(alumnos); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, alumnos); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = alumnos.id })); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public CorregirExamenVM(examenes examen, alumnos alumno) { Examen = examen; Alumno = alumno; Respuestas = BBDDService.getRespuestasByExamenAndAlumno(examen.id, alumno.id); NotaMaxima = examen.preguntas.Sum(x => x.puntuacion); Nota = BBDDService.GetNotaByExamenAlumno(examen, alumno); if (Nota == null) { Nota = new notas(); Nota.alumnos = Alumno; Nota.examenes = Examen; Nota.nota = Respuestas.Sum(x => x.puntuacion); } }
// GET: alumnos/Delete/5 public ActionResult Eliminar(int?id, string error) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } alumnos alumnos = db.alumnos.Find(id); if (alumnos == null) { return(HttpNotFound()); } string e = ViewBag.error; ViewBag.errorMsj = error; return(View(alumnos)); }
// DELETE api/Default1/5 public HttpResponseMessage Deletealumnos(int id) { alumnos alumnos = db.alumnos.Find(id); if (alumnos == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } db.alumnos.Remove(alumnos); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, alumnos)); }
// PUT api/Default1/5 public HttpResponseMessage Putalumnos(int id, alumnos alumnos) { if (ModelState.IsValid && id == alumnos.id) { db.Entry(alumnos).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public ActionResult Edit(int id, alumnos alumno, HttpPostedFileBase fotografia) { try { if (fotografia != null) { var result = Libraries.File.upload(fotografia, 1); if (result.status) { alumno.fotografia = result.data.id; } } db.Entry(alumno).State = EntityState.Modified; db.SaveChanges(); // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public static void menu2() { bool bandera = true; string op; do { Console.WriteLine("menu--------------[1-2-3-4-5-6]"); switch (Convert.ToInt32(Console.ReadLine())) { case 1: alumnos alumno = new alumnos(); do { Console.WriteLine("carnet: "); op = Console.ReadLine(); if (alum.ContainsKey(op)) { Console.WriteLine("el carnet ya existe"); } else { alumno.carnet = op; break; } } while (true); Console.WriteLine("nombre"); alumno.nombre = Console.ReadLine(); alum.Add(alumno.carnet, alumno); break; case 2: foreach (var a in alum) { Console.WriteLine("carnet: {0}", a.Value.carnet); Console.WriteLine("nombre: {0}", a.Value.nombre); } break; case 3: string op2; Console.WriteLine("ingrese carnet:"); op2 = Console.ReadLine(); if (alum.ContainsKey(op2)) { Console.WriteLine(alum[op2].carnet); Console.WriteLine(alum[op2].nombre); } break; case 4: string op3; Console.WriteLine("ingrese carnet:"); op3 = Console.ReadLine(); if (alum.ContainsKey(op3)) { alum.Remove(op3); } break; case 5: alum.Clear(); Console.WriteLine("diccionario vaciado"); break; case 6: bandera = false; break; default: break; } } while (bandera); Console.ReadKey(); }
public ActionResult RegAl([Bind(Include = "idUsuario,Foto,Nombre,APP,APM,Sexo,Direccion,Correo,Contraseña,Telefono,idSeccion,idPerfil,TokenRecovery")] usuario usuario, alumnos a, HttpPostedFileBase file) { if (file != null) { var filecarga = System.IO.Path.GetFileName(file.FileName); var extension = System.IO.Path.GetExtension(filecarga); if (extension == ".jpg") { //contrato.nombre = filecarga; usuario.Foto = new byte[file.ContentLength]; file.InputStream.Read(usuario.Foto, 0, file.ContentLength); System.Diagnostics.Debug.Write("Extensión..." + extension); try { usuario.idPerfil = 1; usuario.TokenRecovery = ""; db.usuario.Add(usuario); db.SaveChanges(); a.idUsuario = usuario.idUsuario; db.alumnos.Add(a); db.SaveChanges(); //return RedirectToAction("Index", "Home"); return(RedirectToAction("Index", "Home", new { mensaje = 1 })); } catch (Exception e) { System.Diagnostics.Debug.Write(e); System.Diagnostics.Debug.Write(" - Error al actualizar el registro"); } } else { System.Diagnostics.Debug.Write("El archivo no es JPG"); } } else { System.Diagnostics.Debug.Write("No se cargo ningun archivo"); } ViewBag.idPerfil = new SelectList(db.perfil, "idPerfil", "NombreP", usuario.idPerfil); ViewBag.idSeccion = new SelectList(db.seccion, "idSeccion", "Nombre", usuario.idSeccion); return(View(usuario)); }
public void Put(int id, [FromBody] alumnos alumnos) { alumnosService.Save(alumnos); }
public void Post([FromBody] alumnos alumnos) { alumnosService.Save(alumnos); }
public ActionResult FileUpload(HttpPostedFileBase file) { var upload = Libraries.File.upload(file, 1); Object result = new Object(); int adds = 0; int updates = 0; if (upload.status) { List <string> array = new List <string>(); var csv = Libraries.Csv.LoadCsvFile(path + upload.data.filename); if (csv.status == true) { var all = db.alumnos.Where(w => w.activo == 1).ToList(); all.ForEach(w => w.activo = 0); db.SaveChanges(); string message = ""; foreach (Dictionary <string, string> alumno in csv.data) { if (alumno["idalum"] != null) { string id_alum = alumno["idalum"]; alumnos exists = db.alumnos.Where(w => w.id_alum == id_alum).SingleOrDefault(); try { if (exists != null) { exists.matricula = alumno["matricula"]; exists.nombre = alumno["nombre"]; exists.apellido_paterno = alumno["apellido_paterno"]; exists.apellido_materno = alumno["apellido_materno"]; exists.id_peri = alumno["idperi"]; exists.curp = alumno["curp"]; if (alumno["fechanaci"] != null) { exists.fecha_naci = DateTime.Parse(alumno["fechanaci"]); } if (alumno["sexo"] != null) { exists.sexo = Int32.Parse(alumno["sexo"]); } exists.escuela = alumno["escuela"]; exists.grado = alumno["grado"]; exists.grupo = alumno["grupo"]; exists.dom_alum = alumno["domalum"]; exists.tutor = alumno["tutor"]; exists.dom_tutor = alumno["domtutor"]; exists.activo = 1; db.Entry(exists).State = EntityState.Modified; db.SaveChanges(); updates++; } else { alumnos data = new alumnos(); data.id_alum = id_alum; data.matricula = alumno["matricula"]; data.nombre = alumno["nombre"]; data.apellido_paterno = alumno["apellido_paterno"]; data.apellido_materno = alumno["apellido_materno"]; data.id_peri = alumno["idperi"]; data.curp = alumno["curp"]; if (alumno["fechanaci"] != null) { data.fecha_naci = DateTime.Parse(alumno["fechanaci"]); } if (alumno["sexo"] != null) { data.sexo = Int32.Parse(alumno["sexo"]); } data.escuela = alumno["escuela"]; data.grado = alumno["grado"]; data.grupo = alumno["grupo"]; data.dom_alum = alumno["domalum"]; data.tutor = alumno["tutor"]; data.dom_tutor = alumno["domtutor"]; data.activo = 1; db.alumnos.Add(data); db.SaveChanges(); adds++; } } catch (Exception ex) { message += alumno["idalum"] + ":" + ex.Message + "<br/>"; } } } if (message == "") { result = new { status = true, message = "Se han agregado " + adds.ToString() + " y actualizado " + updates.ToString() + " registros." } } ; else { result = new { status = false, message = message } }; } return(Json(result)); } else { return(Json(upload)); } } }
public CorregirExamen(examenes examen, alumnos alumno) { InitializeComponent(); this.DataContext = new CorregirExamenVM(examen, alumno); }
partial void Deletealumnos(alumnos instance);