Exemple #1
0
 public static GuiChannel ConvertChannel(Channel c)
 {
     GuiChannel chan = new GuiChannel()
     {
         Id = c.Id,
         Description = c.Description,
         Plays = c.Hits != null ? c.Hits.Value : 0,
         Name = c.Name,
         StreamUri = c.StreamUri,
         OwnerId = c.OwnerId,
     };
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         //Get number of subscribers
         chan.Subscribers = proxy.GetSubscriberCount(chan.Id);
         //Get the channels
         chan.Tracks = ConvertTracks(proxy.GetTrackByChannelId(c.Id));
         //Get the genres
         chan.Genres = ConvertGenres(proxy.GetGenresForChannel(c.Id));
     }
     return chan;
 }
Exemple #2
0
 public ActionResult SelectChannel(int channelId, int? userId)
 {
     if (userId.HasValue)
     {
         using (RentItServiceClient proxy = new RentItServiceClient())
         {
             Channel serviceChan = proxy.GetChannel(channelId);
             GuiChannel chan = GuiClassConverter.ConvertChannel(serviceChan);
             chan.Genres = GuiClassConverter.ConvertGenres(proxy.GetGenresForChannel(channelId));
             if (chan != null)
             {
                 Session["channelId"] = chan.Id;
                 return View(chan);
             }
         }
     }
     return RedirectToAction("Index", "Home");
 }
Exemple #3
0
 public SelectGenreModel GetGenreModel(int channelId)
 {
     List<GuiGenre> chosenGenres;
     List<GuiGenre> availableGenres;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         chosenGenres = GuiClassConverter.ConvertGenres(proxy.GetGenresForChannel(channelId));
         Genre[] allGenres = proxy.GetAllGenres();
         availableGenres = GetAllAvailableGenres();
         availableGenres = availableGenres.Except(chosenGenres).ToList();
     }
     SelectGenreModel model = new SelectGenreModel
     {
         AvailableGenres = availableGenres,
         ChosenGenres = chosenGenres,
         ChannelId = channelId,
     };
     return model;
 }