public async Task <IActionResult> OnPostAsync(int?id, string[] selectedClasses) { if (id == null) { return(NotFound()); } var studentToUpdate = await _context.Student .Include(i => i.Teacher) .Include(i => i.Classrooms) .ThenInclude(i => i.Class) .FirstOrDefaultAsync(s => s.ID == id); if (studentToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Student>( studentToUpdate, "Student", i => i.Surname, i => i.Name, i => i.Address, i => i.Phone, i => i.EnrollmentDate, i => i.Teacher)) { UpdateClassrooms(_context, selectedClasses, studentToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } UpdateClassrooms(_context, selectedClasses, studentToUpdate); PopulateAssignedClass(_context, studentToUpdate); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id, string[] selectedCategories) { if (id == null) { return(NotFound()); } var produsToUpdate = await _context.Produs .Include(i => i.Producator) .Include(i => i.CategoriiProdus) .ThenInclude(i => i.Categorie) .FirstOrDefaultAsync(s => s.ID == id); if (produsToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Produs>( produsToUpdate, "Produs", i => i.Nume, i => i.Cantitate, i => i.Pret, i => i.Total, i => i.Producator)) { UpdateCategoriiProdus(_context, selectedCategories, produsToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } //Apelam UpdateBookCategories pentru a aplica informatiile din checkboxuri la entitatea Books care //este editata UpdateCategoriiProdus(_context, selectedCategories, produsToUpdate); PopulateAssignedCategoryData(_context, produsToUpdate); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newClothing = new Clothing(); if (selectedCategories != null) { newClothing.ClothingCategories = new List <ClothingCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new ClothingCategory { CategoryID = int.Parse(cat) }; newClothing.ClothingCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Clothing>( newClothing, "Clothing", i => i.Name, i => i.Seller, i => i.Price, i => i.DateAdded, i => i.BrandID)) { _context.Clothing.Add(newClothing); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newClothing); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Doctor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DoctorExists(Doctor.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string[] selectedClasses) { var newStudent = new Student(); if (selectedClasses != null) { newStudent.Classrooms = new List <Classroom>(); foreach (var cat in selectedClasses) { var catToAdd = new Classroom { ClassID = int.Parse(cat) }; newStudent.Classrooms.Add(catToAdd); } } if (await TryUpdateModelAsync <Student>( newStudent, "Student", i => i.Surname, i => i.Name, i => i.Address, i => i.Phone, i => i.EnrollmentDate, i => i.TeacherID)) { _context.Student.Add(newStudent); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedClass(_context, newStudent); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id, string[] selectedCategories) { if (id == null) { return(NotFound()); } var clothingToUpdate = await _context.Clothing .Include(i => i.Brand) .Include(i => i.ClothingCategories) .ThenInclude(i => i.Category) .FirstOrDefaultAsync(s => s.ID == id); if (clothingToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Clothing>( clothingToUpdate, "Book", i => i.Name, i => i.Seller, i => i.Price, i => i.DateAdded, i => i.Brand)) { UpdateBookCategories(_context, selectedCategories, clothingToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } UpdateBookCategories(_context, selectedCategories, clothingToUpdate); PopulateAssignedCategoryData(_context, clothingToUpdate); return(Page()); }
public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newSong = new Song(); if (selectedCategories != null) { newSong.SongCategories = new List <SongCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new SongCategory { CategoryID = int.Parse(cat) }; newSong.SongCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Song>( newSong, "Song", i => i.Title, i => i.Author, i => i.Price, i => i.PublishingDate, i => i.PublisherID)) { _context.Song.Add(newSong); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newSong); return(Page()); }
public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newProdus = new Produs(); if (selectedCategories != null) { newProdus.CategoriiProdus = new List <CategorieProdus>(); foreach (var cat in selectedCategories) { var catToAdd = new CategorieProdus { CategorieID = int.Parse(cat) }; newProdus.CategoriiProdus.Add(catToAdd); } } if (await TryUpdateModelAsync <Produs>( newProdus, "Produs", i => i.Nume, i => i.Cantitate, i => i.Pret, i => i.Total, i => i.ProducatorID)) { _context.Produs.Add(newProdus); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newProdus); return(Page()); }
public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newCar = new Car(); if (selectedCategories != null) { newCar.CarCategories = new List <CarCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new CarCategory { CategoryID = int.Parse(cat) }; newCar.CarCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Car>( newCar, "Car", i => i.Model, i => i.Mark, i => i.Price, i => i.LaunchingDate, i => i.ProducerID)) { _context.Car.Add(newCar); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newCar); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id, string[] selectedCategories) { if (id == null) { return(NotFound()); } var bookToUpdate = await _context.Book .Include(i => i.Publisher) .Include(i => i.BookCategories) .ThenInclude(i => i.Category) .FirstOrDefaultAsync(s => s.ID == id); if (bookToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Book>( bookToUpdate, "Book", i => i.Title, i => i.Author, i => i.Price, i => i.PublishingDate, i => i.Publisher)) { UpdateBookCategories(_context, selectedCategories, bookToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } //Apelam UpdateBookCategories pentru a aplica informatiile din checkboxuri la entitatea Books care //este editata UpdateBookCategories(_context, selectedCategories, bookToUpdate); PopulateAssignedCategoryData(_context, bookToUpdate); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id, string[] selectedCategories) { if (id == null) { return(NotFound()); } var songToUpdate = await _context.Song .Include(i => i.Publisher) .Include(i => i.SongCategories) .ThenInclude(i => i.Category) .FirstOrDefaultAsync(s => s.ID == id); if (songToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Song>( songToUpdate, "Song", i => i.Title, i => i.Author, i => i.Price, i => i.PublishingDate, i => i.Publisher)) { UpdateSongCategories(_context, selectedCategories, songToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } UpdateSongCategories(_context, selectedCategories, songToUpdate); PopulateAssignedCategoryData(_context, songToUpdate); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id, string[] selectedCategories) { if (id == null) { return(NotFound()); } var carToUpdate = await _context.Car.Include(i => i.Producer).Include(i => i.CarCategories).ThenInclude(i => i.Category).FirstOrDefaultAsync(s => s.ID == id); if (carToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Car>(carToUpdate, "Car", i => i.Model, i => i.Mark, i => i.Price, i => i.LaunchingDate, i => i.Producer)) { UpdateCarCategories(_context, selectedCategories, carToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } UpdateCarCategories(_context, selectedCategories, carToUpdate); PopulateAssignedCategoryData(_context, carToUpdate); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Appointment.Add(Appointment); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task<IActionResult> OnPostAsync(int? id) { if (id == null) { return NotFound(); } Producator = await _context.Producator.FindAsync(id); if (Producator != null) { _context.Producator.Remove(Producator); await _context.SaveChangesAsync(); } return RedirectToPage("./Index"); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Publisher = await _context.Publisher.FindAsync(id); if (Publisher != null) { _context.Publisher.Remove(Publisher); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Athlete = await _context.Athlete.FindAsync(id); if (Athlete != null) { _context.Athlete.Remove(Athlete); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Club = await _context.Club.FindAsync(id); if (Club != null) { _context.Club.Remove(Club); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Specialization = await _context.Specialization.FindAsync(id); if (Specialization != null) { _context.Specialization.Remove(Specialization); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }