public async Task <IActionResult> SinglePassProcessing(int id, int visitorId) { SinglePass singlePass; if (id != 0) { singlePass = await passRepository.GetAll() .Where(v => v.Id == id) .Include(v => v.StationFacilities) .Include(v => v.SinglePassIssued) .ThenInclude(v => v.Department) .FirstAsync(); } else { if (visitorId != 0) { singlePass = new SinglePass(); singlePass.SinglePassIssued = await GetRequestUserAsync(); singlePass.ValidWith = DateTime.Now; singlePass.ValitUntil = DateTime.Now; singlePass.VisitorId = visitorId; } else { return(new BadRequestResult()); } } return(View(new SinglePassVM { ProcessingSinglePass = singlePass, ShowAdvancedFeatures = HttpContext.User.IsInRole("Administrator") || HttpContext.User.IsInRole("Moderator") })); }
private void Button_Click_1(object sender, RoutedEventArgs e) { SinglePass t = (SinglePass)((Button)sender).DataContext; t.OnPropertyChanged(nameof(t.Accompanying.Name)); //t.OnPropertyChanged(nameof(t.Accompanying.Sel)); t.OnPropertyChanged(nameof(t.Accompanying)); }
public async Task <RedirectToActionResult> SinglePassProcessing(SinglePass ProcessingSinglePass, List <int> facilitiesId) { await passRepository.Update(ProcessingSinglePass); passRepository.GetAll().Include(v => v.StationFacilities). Where(v => v.Id == ProcessingSinglePass.Id) .First(); ProcessingSinglePass.StationFacilities = await Task.Run(() => facilitiesId.Select(id => stationFacilitysRepository.GetAll() .Include(v => v.SinglePasses) .Where(v => v.Id == id).First()).ToList()); ProcessingSinglePass.SinglePassIssued = await GetRequestUserAsync(); await passRepository.Update(ProcessingSinglePass); int id = ProcessingSinglePass.Id; return(RedirectToAction("SinglePassProcessing", new { id = id })); }
public async Task <IActionResult> GetAllowedList(int processingPass) { var pass = await passRepository.GetAll() .Where(v => v.Id == processingPass) .Include(v => v.StationFacilities).FirstOrDefaultAsync(); if (pass == null) { pass = new SinglePass(); pass.StationFacilities = new List <StationFacility>(); } var allPass = await stationFacilitysRepository.GetAll().ToListAsync(); var accessPairs = allPass.Select(s => new { Facility = s, Allow = pass.StationFacilities .Where(v => v.Id == s.Id) .Any() }) .ToDictionary(v => v.Facility, i => i.Allow); return(View(accessPairs)); }