public async Task <IActionResult> OnPostAsync(Guid?id, Guid?touroperatorBrandCompanyId) { if (id == null) { return(NotFound()); } TouroperatorCompany = await _context.TouroperatorCompanies.FindAsync(id); if (TouroperatorCompany != null && !TouroperatorCompany.IsOpenData) { TouroperatorCompany.IsDeleted = true; if (touroperatorBrandCompanyId != null) { TouroperatorBrandCompany touroperatorBrandCompany = await _context.TouroperatorBrandCompanies.FindAsync(touroperatorBrandCompanyId); _context.TouroperatorBrandCompanies.Remove(touroperatorBrandCompany); } await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// TODO TouroperatorBrands/Index: раскрыть туропертора из которого удалили юр. лицо, Позиционировать по центру public async Task OnGetDetachAsync(Guid touroperatorCompanyId) { TouroperatorBrandCompany touroperatorBrandCompany = await _context.TouroperatorBrandCompanies.FindAsync(touroperatorCompanyId); _context.TouroperatorBrandCompanies.Remove(touroperatorBrandCompany); _context.SaveChanges(); TouroperatorBrand = await _context.TouroperatorBrands .Include(tb => tb.TouroperatorCompanies).ThenInclude(tc => tc.TouroperatorCompany) .OrderBy(tb => tb.Name).AsNoTracking().ToListAsync(); }
public async Task <IActionResult> OnPostAsync(Guid?touroperatorBrandCompanyId, Guid?touroperatorBrandId) { if (!ModelState.IsValid) { return(Page()); } FillTouroperatorCompanyJasonData(TouroperatorCompany); _context.Attach(TouroperatorCompany).State = EntityState.Modified; if (touroperatorBrandCompanyId != null) { TouroperatorBrandCompany touroperatorBrandCompany = await _context.TouroperatorBrandCompanies.FindAsync(touroperatorBrandCompanyId); if (touroperatorBrandId != null) { touroperatorBrandCompany.TouroperatorBrandId = (Guid)touroperatorBrandId; _context.TouroperatorBrandCompanies.Update(touroperatorBrandCompany); } else { _context.TouroperatorBrandCompanies.Remove(touroperatorBrandCompany); } } else if (touroperatorBrandId != null) { TouroperatorBrandCompany touroperatorBrandCompany = new TouroperatorBrandCompany { TenantId = _tenantProvider.Tenant.Id, TouroperatorBrandId = (Guid)touroperatorBrandId, TouroperatorCompanyId = TouroperatorCompany.Id }; _context.TouroperatorBrandCompanies.Add(touroperatorBrandCompany); } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TouroperatorCompanyExists(TouroperatorCompany.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index", new { currentFilter = CurrentFilter })); }
public async Task <IActionResult> OnPostAttachAsync(Guid touroperatorBrandId, Guid[] touroperatorCompaniesId) { foreach (Guid touroperatorCompanyId in touroperatorCompaniesId) { TouroperatorBrandCompany touroperatorBrandCompany = new TouroperatorBrandCompany { TenantId = _tenantProvider.Tenant.Id, TouroperatorBrandId = touroperatorBrandId, TouroperatorCompanyId = touroperatorCompanyId }; _context.TouroperatorBrandCompanies.Add(touroperatorBrandCompany); } await _context.SaveChangesAsync(); return(RedirectToPage("./Index", new { id = touroperatorBrandId })); }