Example #1
0
 /// <summary>
 /// Method called to determine if a user has subscribed to a given channel
 /// </summary>
 /// <param name="channelId"></param>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static bool IsSubscribed(int channelId, int userId)
 {
     Channel[] channels;
     try
     {
         using (RentItServiceClient proxy = new RentItServiceClient())
         {
             channels = proxy.GetSubscribedChannels(userId);
         }
     }
     catch (Exception)
     {
         return false;
     }
     foreach (Channel c in channels)
     {
         if (c.Id == channelId)
             return true;
     }
     return false;
 }
Example #2
0
 /// <summary>
 /// Returns a view of the subscriptions assosiated with a User
 /// </summary>
 /// <returns></returns>
 public ActionResult MySubscriptions(int? userId)
 {
     if (userId.HasValue)
     {
         Channel[] channels;
         try
         {
             using (RentItServiceClient proxy = new RentItServiceClient())
             {
                 channels = proxy.GetSubscribedChannels(userId.Value);
             }
         }
         catch (Exception)
         {
             channels = new Channel[0];
         }
         List<GuiChannel> guiChannels = GuiClassConverter.ConvertChannels(channels);
         ViewBag.Title = "My subscriptions";
         return View("ChannelList", guiChannels);
     }
     return RedirectToAction("Index", "Home");
 }
Example #3
0
 public JsonResult IsSubscribedJson(int channelId, int userId)
 {
     Channel[] channels;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         channels = proxy.GetSubscribedChannels(userId);
     }
     if (channels != null)
     {
         if (channels.Any(channel => channel.Id == channelId))
         {
             return Json(1, JsonRequestBehavior.AllowGet);
         }
     }
     return Json(0, JsonRequestBehavior.AllowGet);
 }