public async Task <Response> Delete(int id) { try { Subject u = await _context.Subjects.FindAsync(id); u.IsActive = false; u.DeletedAt = DateTime.Now; _context.Update(u); await _context.SaveChangesAsync(); return(new Response()); } catch (Exception e) { StringBuilder sb = new StringBuilder(); log.Error(sb.AppendLine(e.Message).AppendLine(e.StackTrace).ToString()); Response r = new Response() { Success = false }; r.ErrorList.Add("Delete Subject error"); return(r); } }
public async Task <IActionResult> Edit(string id, [Bind("AñoCreacion,Pais,Ciudad,TipoEscuela,Direccion,Nombre,Id")] Academy academy) { if (id != academy.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(academy); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AcademyExists(academy.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(academy)); }
public async Task <IActionResult> Edit(string id, [Bind("FechaDeLanzamiento,CursoId,Nombre,Id")] Asignatura asignatura) { if (id != asignatura.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(asignatura); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AsignaturaExists(asignatura.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Id", asignatura.CursoId); return(View(asignatura)); }
public async Task <IActionResult> Edit(string id, [Bind("Nombre,Jornada,Direccion,AcademyId,Id")] Curso curso) { if (id != curso.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(curso); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CursoExists(curso.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AcademyId"] = new SelectList(_context.Academies, "Id", "Id", curso.AcademyId); return(View(curso)); }