Exemplo n.º 1
0
 //returns all sites from db in correct, converted format
 public IEnumerable<SiteAng> Get()
 {
     List<SiteAng> list = new List<SiteAng>();
     foreach (Site site in _siteRepo.GetAllSites())
     {
         SiteAng item = new SiteAng
         {
             SiteId = site.SiteID,
             SiteName = site.SiteName,
             SiteLogoUrl = site.SiteLogoURL
         };
         list.Add(item);
     }
     return list;
 }
Exemplo n.º 2
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;
        }