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;
        }
Esempio n. 2
0
        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 BootcampSessionAddAng Get(int id)
        {
            //create a new view model, passing in the desired
            //session id and name
            BootcampSessionAddAng ang = new BootcampSessionAddAng
            {
                BootcampSessionId = id
            };
            ang.BootcampName = _bootcampRepo.GetBootcampByID(id).Name;

            //add all of the bootcamp's locations to the view model
            foreach (BootcampLocation location in _bootcampLocationsRepo.GetAllBootcampLocationsByBootcampId(id))
            {
                Location locationById = _locationRepo.GetLocationById(location.LocationID);
                LocationAng item = new LocationAng
                {
                    LocationId = location.LocationID,
                    Name = locationById.City + ", " + locationById.Country
                };
                ang.Locations.Add(item);
            }

            //add all of the bootcamp's technologies to the view model
            foreach (BootcampTechnology technology in _bootcampTechRepo.GetAllBootcampTechnologiesByBootcampId(id))
            {
                TechnologyAng ang3 = new TechnologyAng
                {
                    TechnologyId = technology.TechnologyID.Value,
                    Name = _techRepo.GetTechnologyById(technology.TechnologyID.Value).Name
                };
                ang.Technologies.Add(ang3);
            }
            return ang;
        }