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);
        }
Exemplo n.º 2
0
        //get specific bootcamp for editing
        public BootcampEditAng Get(int id)
        {
            Bootcamp bootcampByID = _bootcampRepo.GetBootcampByID(id);

            return(new BootcampEditAng
            {
                Name = bootcampByID.Name,
                Price = bootcampByID.Price,
                LengthInWeeks = bootcampByID.LengthInWeeks,
                Website = bootcampByID.Website,
                LogoLink = bootcampByID.LogoLink,
                LocationID = bootcampByID.LocationID,
                PrimaryTechnologyID = bootcampByID.PrimaryTechnologyID,
                BootcampID = bootcampByID.BootcampID
            });
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public ActionResult Index(string id)
        {
            //parse URL to get bootcamp ID
            string bootcampName = id.Replace("-", " ");
            int?   bootcampID   = _bootcampRepo.GetBootcampIDByName(bootcampName);

            //if bootcamp does not exist, redirect to the home page
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            //get bootcampID and locationID
            var bootcampByID = _bootcampRepo.GetBootcampByID((int)bootcampID);
            var locationById = _locationRepo.GetLocationById(bootcampByID.LocationID);

            //insert basic bootcamp info into view model
            var model = new BootcampViewModel
            {
                BootcampID = (int)bootcampID,
                Location   = locationById.City + ", " + locationById.Country,
                Name       = bootcampByID.Name,
                LogoLink   = bootcampByID.LogoLink,
                Url        = bootcampByID.Website,
                Price      = Helper.GetPriceString(bootcampByID.Price, _locationRepo.GetLocationById(bootcampByID.LocationID).Country)
            };


            //get all links info for bootcamp and add to view model
            foreach (var link in _linkRepo.GetAllLinksByBootcampId((int)bootcampID))
            {
                Site   siteById = _siteRepo.GetSiteById((int)link.SiteID);
                string linkText = link.LinkText;
                if (linkText.Length > 60)
                {
                    linkText = linkText.Substring(0, 60) + "...";
                }
                FutureCodr.UI.Models.Bootcamp.Link item = new FutureCodr.UI.Models.Bootcamp.Link
                {
                    URL         = link.URL,
                    SiteName    = siteById.SiteName,
                    SiteLogoURL = siteById.SiteLogoURL,
                    Title       = linkText,
                    Date        = link.Date
                };
                model.Links.Add(item);
            }

            //order links by most recent
            model.Links = (from m in model.Links
                           orderby m.Date descending
                           select m).ToList();

            //add bootcamp locations to view model
            foreach (var location2 in _bootcampLocationsRepo.GetAllBootcampLocationsByBootcampId((int)bootcampID))
            {
                FutureCodr.Models.Location             location3 = _locationRepo.GetLocationById(location2.LocationID);
                FutureCodr.UI.Models.Bootcamp.Location location4 = new FutureCodr.UI.Models.Bootcamp.Location
                {
                    City = location3.City,
                    Name = location3.City + ", " + location3.Country,
                    Id   = location2.LocationID
                };
                model.Locations.Add(location4);
            }

            //add bootcamp sessions to view model if they start in the future
            foreach (var session in _sessionRepo.GetBootcampSessionsByBootcampId((int)bootcampID))
            {
                if (session.StartDate > DateTime.Now)
                {
                    Session session2 = new Session
                    {
                        Technology = _technologyRepo.GetTechnologyById(session.TechnologyID.Value).Name,
                        Location   = _locationRepo.GetLocationById((int)session.LocationID).City +
                                     ", " +
                                     _locationRepo.GetLocationById(session.LocationID.Value).Country,
                        StartDate = session.StartDate,
                        EndDate   = session.EndDate
                    };
                    model.Sessions.Add(session2);
                }
            }

            //order sessions by soonest to start
            model.Sessions = (from m in model.Sessions
                              orderby m.StartDate
                              select m).ToList();

            //add bootcamp technologies to the view model
            foreach (var technology in _bootcampTechnologyRepo.GetAllBootcampTechnologiesByBootcampId((int)bootcampID))
            {
                FutureCodr.UI.Models.Bootcamp.Technology technology2 = new FutureCodr.UI.Models.Bootcamp.Technology
                {
                    Name = _technologyRepo.GetTechnologyById(technology.TechnologyID.Value).Name,
                    Id   = technology.TechnologyID.Value
                };
                model.Technologies.Add(technology2);
            }

            //return the strongly typed view with the view model passed in
            return(View(model));
        }
        public void GetBootcampById()
        {
            var result = repo.GetBootcampByID(1).Name;

            Assert.AreEqual(result, "Hack Reactor");
        }