public AdminBootcampSessionListViewModel Get() { AdminBootcampSessionListViewModel model = new AdminBootcampSessionListViewModel(); //get all bootcamp sessions and convert their format for view model foreach (BootcampSession session in _bootcampSessionRepo.GetAllBootcampSessions()) { BootcampSessionAng item = new BootcampSessionAng { BootcampSessionId = session.BootcampSessionID, BootcampName = _bootcampRepo.GetBootcampByID(session.BootcampID.Value).Name }; Location locationById = _locationRepo.GetLocationById(session.LocationID.Value); item.Location = locationById.City + ", " + locationById.Country; item.Technology = _techRepo.GetTechnologyById(session.TechnologyID.Value).Name; item.StartDate = session.StartDate.ToString("d"); item.EndDate = session.EndDate.ToString("d"); //add converted bootcamp session to model model.Sessions.Add(item); } //get a list of all bootcamps (in converted format) for drop down list foreach (Bootcamp bootcamp in _bootcampRepo.GetAllBootcamps()) { BootcampAng ang2 = new BootcampAng { BootcampID = bootcamp.BootcampID, Name = bootcamp.Name }; model.Bootcamps.Add(ang2); } return(model); }
//filters bootcamps when user searches on home page public List<Bootcamp> FilterBootcamps(SearchParams searchParams) { //get all the bootcamps var allBootcamps = _bootcampRepo.GetAllBootcamps(); //create empty list of bootcamps to which the ones which //pass the filter test will be added var filteredBootcamps = new List<Bootcamp>(); //get the price range based on user selection PriceRange priceRange = new PriceRange(); if (searchParams.SelectedPriceRange.HasValue) { priceRange = GetPriceRange(searchParams.SelectedPriceRange.Value); } //loop through each bootcamp and check each user selection against it foreach (FutureCodr.Models.Bootcamp bootcamp in allBootcamps) { //first get all of the bootcamp's location and technology IDs //to compare to the user's selection List<int> bootcampLocationIds = _bootcampLocationsRepo .GetAllBootcampLocationsByBootcampId(bootcamp.BootcampID) .Select(m => m.LocationID).ToList(); List<int> bootcampTechnologyIds = _bootcampTechnologyRepo .GetAllBootcampTechnologiesByBootcampId(bootcamp.BootcampID) .Select(m => m.TechnologyID).ToList(); //then check each bootcamp against price, location and technology if ((!searchParams.SelectedPriceRange.HasValue || ((bootcamp.Price >= priceRange.Min) && (bootcamp.Price <= priceRange.Max))) && (!searchParams.SelectedLocationId.HasValue || !bootcampLocationIds.Contains(searchParams.SelectedLocationId)) && (!searchParams.SelectedTechnologyId.HasValue || !bootcampTechnologyIds.Contains(searchParams.SelectedTechnologyId)) { filteredBootcamps.Add(bootcamp); } } //convert all of the bootcamps that passed the filter into the //correct format and return the list var filteredAndConvertedBootcampList = new List<FutureCodr.UI.Models.Home.Bootcamp>(); foreach (FutureCodr.Models.Bootcamp bootcamp in list2) { filteredAndConvertedBootcampList.Add(ConvertBootcampFormat(bootcamp)); } return filteredAndConvertedBootcampList; }
public BootcampLocationViewModel Get() { BootcampLocationViewModel model = new BootcampLocationViewModel(); //get all bootcamp locations to be displayed in overview table foreach (BootcampLocation location in _bootcampLocationsRepo.GetAllBootcampLocations()) { //for each bootcamp location, convert format and add to view model Location locationById = _locationRepo.GetLocationById(location.LocationID); BootcampLocationAng item = new BootcampLocationAng { Id = location.BootcampLocationID, Bootcamp = _bootcampRepo.GetBootcampByID(location.BootcampID).Name, Location = locationById.City + ", " + locationById.Country }; model.BootcampLocations.Add(item); } //get all bootcamps with their Ids for drop down list foreach (Bootcamp bootcamp in _bootcampRepo.GetAllBootcamps()) { //convert format BootcampAng ang2 = new BootcampAng { BootcampID = bootcamp.BootcampID, Name = bootcamp.Name }; //add converted technology to the list model.Bootcamps.Add(ang2); } //get all locations with their Ids for drop down list foreach (Location location3 in _locationRepo.GetAllLocations()) { //convert format LocationAng ang3 = new LocationAng { LocationId = location3.LocationID, Name = location3.City + ", " + location3.Country }; //add converted location to list model.Locations.Add(ang3); } return(model); }
public AdminBootcampListViewModel Get() { AdminBootcampListViewModel model = new AdminBootcampListViewModel(); //loop through each bootcamp and convert format for view model foreach (Bootcamp bootcamp in _bootcampRepo.GetAllBootcamps()) { BootcampListAng item = new BootcampListAng { BootcampID = bootcamp.BootcampID, Name = bootcamp.Name, LengthInWeeks = bootcamp.LengthInWeeks, PriceString = Helper.GetPriceString(bootcamp.Price, _locationRepo.GetLocationById(bootcamp.LocationID).Country) }; Location locationById = _locationRepo.GetLocationById(bootcamp.LocationID); item.Location = locationById.City + ", " + locationById.Country; item.Technology = _techRepo.GetTechnologyById(bootcamp.PrimaryTechnologyID).Name; //add each converted bootcamp object to the view model model.Bootcamps.Add(item); } //get each location and convert format for view model (drop down list) foreach (Location location2 in _locationRepo.GetAllLocations()) { LocationAng ang2 = new LocationAng { LocationId = location2.LocationID, Name = location2.City + ", " + location2.Country }; model.Locations.Add(ang2); } //get each technology and convert format for view model (drop down list) foreach (Technology technology in _techRepo.GetAllTechnologies()) { TechnologyAng ang3 = new TechnologyAng { TechnologyId = technology.TechnologyID, Name = technology.Name }; model.Technologies.Add(ang3); } return(model); }
public LinksAng Get() { LinksAng ang = new LinksAng(); //get all links from db and loop through them foreach (Link link in _linkRepo.GetAllLinks()) { //convert to correct format for the angular view model LinkAng item = new LinkAng { LinkID = link.LinkID, URL = link.URL, LinkText = link.LinkText, LinkSiteName = _siteRepo.GetSiteById(link.SiteID.Value).SiteName, Date = link.Date.ToString("d") }; item.BootcampName = _bootcampRepo.GetBootcampByID(link.BootcampID.Value).Name; //add each converted object to the view model ang.Links.Add(item); } //get all sites in correct format and add to model foreach (Site site in _siteRepo.GetAllSites()) { SiteAng ang4 = new SiteAng { SiteId = site.SiteID, SiteName = site.SiteName }; ang.Sites.Add(ang4); } //get all bootcamps in correct format and add to view model foreach (Bootcamp bootcamp in _bootcampRepo.GetAllBootcamps()) { BootcampAng ang5 = new BootcampAng { BootcampID = bootcamp.BootcampID, Name = bootcamp.Name }; ang.Bootcamps.Add(ang5); } return(ang); }
public AdminBootcampTechnologyViewModel Get() { AdminBootcampTechnologyViewModel model = new AdminBootcampTechnologyViewModel(); //get all bootcamp technologies, and convert each to correct format //before adding each to the angular view model foreach (BootcampTechnology technology in _bootcampTechRepo.GetAllBootcampTechnologies()) { BootcampTechnologyAng item = new BootcampTechnologyAng { BootcampTechnologyId = technology.BootcampTechnologyID, BootcampName = _bootcampRepo.GetBootcampByID(technology.BootcampID.Value).Name, Technology = _techRepo.GetTechnologyById(technology.TechnologyID.Value).Name }; model.BootcampTechnologies.Add(item); } //get all bootcamps (name and id) and add to the model foreach (Bootcamp bootcamp in _bootcampRepo.GetAllBootcamps()) { BootcampAng ang2 = new BootcampAng { BootcampID = bootcamp.BootcampID, Name = bootcamp.Name }; model.Bootcamps.Add(ang2); } //get all technologies (name and id) and add to the view model foreach (Technology technology2 in _techRepo.GetAllTechnologies()) { TechnologyAng ang3 = new TechnologyAng { TechnologyId = technology2.TechnologyID, Name = technology2.Name }; model.Technologies.Add(ang3); } return(model); }
public void GetAllBootcampsTest() { var result = repo.GetAllBootcamps(); Assert.AreEqual(4, result.Count); }
public ActionResult Links() { List <Bootcamp> allBootcamps = _bootcampRepo.GetAllBootcamps(); return(View(allBootcamps)); }