// retourne tous les applications public IList <ApplicationDisplayViewModel> ApplicationDisplay(WebSiteDBContext context) { var data = context.Set <Application>().Include("Operations").ToList(); IList <ApplicationDisplayViewModel> Display = new List <ApplicationDisplayViewModel>(); foreach (Application a in data) { ApplicationDisplayViewModel aux = new ApplicationDisplayViewModel(); aux.Id = a.ApplicationId; aux.Name = a.Name; aux.Operations = a.Operations; Display.Add(aux); } return(Display); }
public IList <ApplicationDisplayViewModel> getClientApplications(WebSiteDBContext context, string id) { Client client = getClientById(context, id); var data = client.Applications; IList <ApplicationDisplayViewModel> Display = new List <ApplicationDisplayViewModel>(); foreach (Application a in data) { ApplicationDisplayViewModel aux = new ApplicationDisplayViewModel(); aux.Id = a.ApplicationId; aux.Name = a.Name; aux.Operations = a.Operations; Display.Add(aux); } return(Display); }
public async Task <IActionResult> Index(string ApplicationAdress, string SearchString) { // getting Apaartment to list.. calling the class apartment and get the value Adress IQueryable <string> ApartmentAdressQuery = from a in _context.Apply orderby a.Apartment.Adress select a.Apartment.Adress; // getting all applications and including Apartment var applications = from m in _context.Apply.Include(a => a.Apartment) select m; //checking if userinput contains any digits of an adress. if (!string.IsNullOrEmpty(SearchString)) { applications = applications.Where(s => s.Apartment.Adress.Contains(SearchString)); } // checking for application adress in list if (!string.IsNullOrEmpty(ApplicationAdress)) { applications = applications.Where(x => x.Apartment.Adress == ApplicationAdress); } // caling view model var applicationDisplayVM = new ApplicationDisplayViewModel { ApartmentAdress = new SelectList(await ApartmentAdressQuery.Distinct().ToListAsync()), Applications = await applications.ToListAsync() }; return(View(applicationDisplayVM)); // var dataContext_Milad = _context.Apply.Include(a => a.Apartment); // return View(await dataContext_Milad.ToListAsync()); }