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.TechnicianID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Project.Add(Project); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } Client = await _context.Client.FindAsync(id); if (Client != null) { _context.Client.Remove(Client); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string 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")); }
} // Current Client logged in the app public async Task <IActionResult> OnPostAsync() { try { string userId = User.Identity.Name; // Gets the current logged email currentUser = _context.Client.FirstOrDefault(x => x.Email == userId); // Gets from context the Client with that email } catch (Exception e) { Console.WriteLine("Something went wrong getting the logged user: "******"https://localhost:5001/")); } Project.ClientID = currentUser.ClientID; // Adds the clientID to the Project if (!ModelState.IsValid) { return(RedirectToPage("./MyProjects")); } _context.Project.Add(Project); await _context.SaveChangesAsync(); return(RedirectToPage("./MyProjects")); }