public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Technician).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TechnicianExists(Technician.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async void OnPostSaveAsync(int id, int TechnicianToUpdateID, int param1, int param2) { if (param2 >= 1 && param2 <= 5) { Projects = await _context.Project.ToListAsync(); Project = await _context.Project .Where(m => m.ID == id) .Include(c => c.Assignments) .ThenInclude(a => a.Technician) .FirstOrDefaultAsync(); this.Technicians = Project.Assignments .Select(a => a.Technician); Technician ProjectToUpdate = await _context.Technician .Include(a => a.Assignments) .ThenInclude(a => a.Technician) .FirstOrDefaultAsync(m => m.ID == TechnicianToUpdateID); await TryUpdateModelAsync <Technician>(ProjectToUpdate); //Por alguna razón el framework en algunos casos modifica el id del técnico a 1 en el //TryUpdateModelAsync haciendo que crashee cuando va a gurdar los cambios, la siguiente //linea puede parecer fuera de lugar pero es la solución que encontramos. ProjectToUpdate.ID = TechnicianToUpdateID; ProjectToUpdate.hours = ProjectToUpdate.hours + param1; if (ProjectToUpdate.score != 0) { ProjectToUpdate.score = (ProjectToUpdate.score + param2) / 2; } else { ProjectToUpdate.score = param2; } await _context.SaveChangesAsync(); } }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Technician.hours = 0; Technician.score = 0; _context.Technician.Add(Technician); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } //La precondicion es que el Project no sea nulo Check.Precondition(Specialization != null); _context.Specialization.Add(Specialization); await _context.SaveChangesAsync(); // La postcondicion es que contenga la especialización luego de agregada Check.Postcondition(_context.Specialization.Contains(Specialization) == false); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Technician = await _context.Technician.FindAsync(id); if (Technician != null) { _context.Technician.Remove(Technician); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } ApplicationUser = await _context.Users.FindAsync(id); if (ApplicationUser != null) { _context.Users.Remove(ApplicationUser); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { Project.Finished = false; if (!ModelState.IsValid) { return(Page()); } //La precondicion es que el Project no sea nulo Check.Precondition(Project != null); _context.Project.Add(Project); await _context.SaveChangesAsync(); // La postcondicion es que se haya agregado el project Check.Postcondition(_context.Project.Contains(Project)); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Project = await _context.Project.FindAsync(id); if (Project != null) { // La precondicion es que _context.Project contenga Project para poder eliminarlo. Check.Precondition(_context.Project.Contains(Project)); _context.Project.Remove(Project); await _context.SaveChangesAsync(); // La postcondicion es que se haya eliminado el Project Check.Postcondition(_context.Project.Contains(Project) == false); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Specialization = await _context.Specialization.FindAsync(id); if (Specialization != null) { // La precondicion es que _context.Specialization contenga Specialization para poder eliminarla. Check.Precondition(_context.Specialization.Contains(Specialization)); _context.Specialization.Remove(Specialization); await _context.SaveChangesAsync(); // La postcondicion es que se haya eliminado la especialización Check.Postcondition(_context.Specialization.Contains(Specialization) == false); } return(RedirectToPage("./Index")); }