Esempio n. 1
0
        public async Task <Alumno> Modify(Alumno alumno)
        {
            var modelToUpdate = await _alumnoRepository.FindByCondition(x => x.id == alumno.id);

            var model = modelToUpdate.FirstOrDefault();

            model = alumno;
            _alumnoRepository.Update(model);
            return(modelToUpdate.FirstOrDefault());
        }
Esempio n. 2
0
                                                    public async Task <IHttpActionResult> Update([FromBody] Alumno model)
                                                    {
                                                        if (!ModelState.IsValid)
                                                        {
                                                            return(BadRequest(ModelState));
                                                        }

                                                        try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                              await _entityRepo.Update(model);

                                                              return(Ok("Registro actualizado exitosamente!")); }
                                                        catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                              return(InternalServerError(e)); }
                                                    }
Esempio n. 3
0
        // PUT: api/alumno/5
        public JObject Put(int id, [FromBody] Alumno alumno)
        {
            alumno.ID = id;

            JObject response = new JObject
            {
                { "error", false },
                { "msg", "Alumno updated successfully." }
            };

            if (!AlumnoRepository.Update(alumno))
            {
                response["error"] = true;
                response["msg"]   = "Alumno not updated.";
            }
            return(response);
        }
Esempio n. 4
0
        public IActionResult EditarAlumno(Alumno a)
        {
            try
            {
                AlumnoRepository AluRepos = new AlumnoRepository(context);
                var usuario = AluRepos.GetById(a.Id);

                if (usuario != null)
                {
                    usuario.Nombre     = a.Nombre;
                    usuario.NumControl = a.NumControl;
                    // usuario.ClaveMaestro = a.ClaveMaestro;

                    AluRepos.Update(usuario);
                }
                var claveMaestro = usuario.ClaveMaestro;
                return(RedirectToAction("VerAlumnos", new { clave = claveMaestro }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(a));
            }
        }