コード例 #1
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public static string GetChannelOwner(int userId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         return proxy.GetUser(userId).Username;
     }
 }
コード例 #2
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public static bool HasChannelTracks(int channelId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         return proxy.GetTrackByChannelId(channelId).Length > 0;
     }
 }
コード例 #3
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public static bool IsChannelPlaying(int channelId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         return proxy.IsChannelPlaying(channelId);
     }
 }
コード例 #4
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public static bool CanStartStopChannels()
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         return proxy.CanStartStopChannels();
     }
 }
コード例 #5
0
ファイル: CommentController.cs プロジェクト: markthor/RentIt
 public static int GetCountChannelComments(int channelId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         return proxy.GetCountChannelComments(channelId);
     }
 }
コード例 #6
0
ファイル: TrackController.cs プロジェクト: markthor/RentIt
 /// <summary>
 /// Adds a track to a channel
 /// </summary>
 /// <param name="file"></param>
 /// <param name="channelId"></param>
 /// <param name="trackName"></param>
 /// <param name="artistName"></param>
 /// <returns></returns>
 public ActionResult AddTrack(HttpPostedFileBase file, int channelId, int? userId, string trackName, string artistName)
 {
     if (userId.HasValue)
     {
         try
         {
             // Verify that the user selected a file
             if (file != null && file.ContentLength > 0)
             {
                 Stream stream = file.InputStream;
                 MemoryStream memory = new MemoryStream();
                 stream.CopyTo(memory);
                 Track track = new Track();
                 track.Artist = artistName;
                 track.Name = trackName;
                 using (RentItServiceClient proxy = new RentItServiceClient())
                 {
                     proxy.AddTrack(userId.Value, channelId, memory);
                 }
             }
         }
         catch (Exception)
         {
         }
         return Redirect(Request.UrlReferrer.PathAndQuery);
     }
     return RedirectToAction("Index", "Home");
 }
コード例 #7
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public static int TotalChannels()
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         ChannelSearchArgs searchArgs = proxy.GetDefaultChannelSearchArgs();
         searchArgs.SortOption = searchArgs.SubscriptionsDesc;
         return proxy.CountAllChannelsWithFilter(searchArgs);
     }
 }
コード例 #8
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public static int TotalChannelsWithFilter(AdvancedSearchModel model)
 {
     int count;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         count = proxy.CountAllChannelsWithFilter((ChannelSearchArgs)model);
     }
     return count;
 }
コード例 #9
0
ファイル: TrackController.cs プロジェクト: markthor/RentIt
 public static int GetUpvotes(int trackId)
 {
     int upvotes;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         upvotes = proxy.CountAllUpvotes(trackId);
     }
     return upvotes;
 }
コード例 #10
0
ファイル: TrackController.cs プロジェクト: markthor/RentIt
 public static int GetDownvotes(int trackId)
 {
     int downvotes;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         downvotes = proxy.CountAllDownvotes(trackId);
     }
     return downvotes;
 }
コード例 #11
0
ファイル: CommentController.cs プロジェクト: markthor/RentIt
 public ActionResult AddComment(Comment comment, int? userId, int? channelId)
 {
     if(userId.HasValue && channelId.HasValue)
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         proxy.CreateComment(comment.Content, userId.Value, channelId.Value);
     }
     return Redirect(Request.UrlReferrer.PathAndQuery);
 }
コード例 #12
0
ファイル: AudioController.cs プロジェクト: markthor/RentIt
 public JsonResult Last5TracksJson(int channelId, int userId)
 {
     List<GuiTrack> guiTracks;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         Track[] tracks = proxy.GetRecentlyPlayedTracks(channelId, 5);
         guiTracks = GuiClassConverter.ConvertTracks(tracks);
     }
     return Json(guiTracks, JsonRequestBehavior.AllowGet);
 }
コード例 #13
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public static List<GuiGenre> GetAllAvailableGenres()
 {
     List<GuiGenre> availableGenres;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         Genre[] allGenres = proxy.GetAllGenres();
         availableGenres = GuiClassConverter.ConvertGenres(allGenres);
     }
     return availableGenres;
 }
コード例 #14
0
ファイル: AudioController.cs プロジェクト: markthor/RentIt
 public PartialViewResult Last5Tracks(int channelId, int userId)
 {
     List<GuiTrack> guiTracks;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         Track[] tracks = proxy.GetRecentlyPlayedTracks(channelId, 5);
         guiTracks = GuiClassConverter.ConvertTracks(tracks);
     }
     return PartialView(new Tuple<List<GuiTrack>, int>(guiTracks, userId));
 }
コード例 #15
0
 public JsonResult IsCurrentPasswordCorrect(string currentPassword, int userId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         if (proxy.IsCorrectPassword(userId, currentPassword))
         {
             return Json(true, JsonRequestBehavior.AllowGet);
         }
         return Json("The current password is wrong.", JsonRequestBehavior.AllowGet);
     }
 }
コード例 #16
0
 public JsonResult IsUsernameAvailable(string newUsername)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         if (proxy.IsUsernameAvailable(newUsername))
         {
             return Json(true, JsonRequestBehavior.AllowGet);
         }
         return Json("Username is already in use.", JsonRequestBehavior.AllowGet);
     }
 }
コード例 #17
0
 public JsonResult IsChannelNameAvailable(string name, int id)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         if (proxy.IsChannelNameAvailable(id, name))
         {
             return Json(true, JsonRequestBehavior.AllowGet);
         }
         return Json("The channel name is already in use.", JsonRequestBehavior.AllowGet);
     }
 }
コード例 #18
0
ファイル: AudioController.cs プロジェクト: markthor/RentIt
 public ActionResult AudioPlayer(int channelId, int userId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         proxy.IncrementChannelPlays(channelId);
     }
     Audio audio = new Audio();
     audio.StreamUri = "http://rentit.itu.dk:27000/" + channelId.ToString();
     audio.ChannelId = channelId;
     return View(new Tuple<Audio, int>(audio, userId));
 }
コード例 #19
0
ファイル: AccountController.cs プロジェクト: markthor/RentIt
 public static int GetVote(int userId, int trackId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         Vote vote = proxy.GetVote(userId, trackId);
         if (vote != null)
         {
             return vote.Value;
         }
         return 0;
     }
 }
コード例 #20
0
ファイル: AccountController.cs プロジェクト: markthor/RentIt
 public ActionResult ChangePassword(Account account, int? userId)
 {
     if (userId.HasValue)
     {
         using (RentItServiceClient proxy = new RentItServiceClient())
         {
             proxy.UpdateUser(userId.Value, null, account.NewPassword, null);
         }
         return Redirect(Request.UrlReferrer.PathAndQuery);
     }
     return RedirectToAction("Index", "Home");
 }
コード例 #21
0
ファイル: GuiClassConverter.cs プロジェクト: markthor/RentIt
 public static GuiComment ConvertComment(Comment c)
 {
     GuiComment comment = new GuiComment()
     {
         UserId = c.UserId,
         Content = c.Content,
         Date = c.PostTime,
         ChannelId = c.ChannelId
     };
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         comment.UserName = proxy.GetUser(comment.UserId).Username;
     }
     return comment;
 }
コード例 #22
0
ファイル: CommentController.cs プロジェクト: markthor/RentIt
        //
        // GET: /Comment/
        public PartialViewResult CommentListRange(int channelId, int startIndex, int endIndex)
        {
            if (startIndex <= 0)
            {
                startIndex = 0;
                endIndex = 10;
            }

            Comment[] comments;
            using (RentItServiceClient proxy = new RentItServiceClient())
            {
                comments = proxy.GetChannelComments(channelId, startIndex, endIndex);
            }
            List<GuiComment> guiComments = GuiClassConverter.ConvertComments(comments);
            ViewBag.ChannelId = channelId;
            return PartialView("CommentList", new Tuple<List<GuiComment>, int, int>(guiComments, startIndex, endIndex));
        }
コード例 #23
0
 public JsonResult IsEmailAvailable(string newEmail)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         try
         {
             if (proxy.IsEmailAvailable(newEmail))
             {
                 return Json(true, JsonRequestBehavior.AllowGet);
             }
         }
         catch
         {
             return Json("Email is already in use.", JsonRequestBehavior.AllowGet);
         }
         return Json("Email is already in use.", JsonRequestBehavior.AllowGet);
     }
 }
コード例 #24
0
ファイル: AccountController.cs プロジェクト: markthor/RentIt
 /// <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;
 }
コード例 #25
0
ファイル: GuiClassConverter.cs プロジェクト: markthor/RentIt
 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;
 }
コード例 #26
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 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");
 }
コード例 #27
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
        public ActionResult SearchAdv(string channelName, int? minAmountOfSubscribers, int? maxAmountOfSubscribers, int? minAmountOfComments,
                                      int? maxAmountOfComments, int? minAmountOfPlays, int? maxAmountOfPlays, int? minAmountOfVotes,
                                      int? maxAmountOfVotes, string sortingKey, string sortingBy, int startIndex, int endIndex, SelectedGenrePostModel genres)
        {
            Channel[] channels;
            ChannelSearchArgs searchArgs;
            using (RentItServiceClient proxy = new RentItServiceClient())
            {
                searchArgs = proxy.GetDefaultChannelSearchArgs();
                if (channelName != null && !channelName.Equals(""))
                    searchArgs.SearchString = channelName;
                searchArgs.StartIndex = startIndex;
                searchArgs.EndIndex = endIndex;
                //Subscribers
                searchArgs.MinNumberOfSubscriptions = minAmountOfSubscribers != null ? minAmountOfSubscribers.Value : -1;
                searchArgs.MaxNumberOfSubscriptions = maxAmountOfSubscribers != null ? maxAmountOfSubscribers.Value : int.MaxValue;
                //Comments
                searchArgs.MinNumberOfComments = minAmountOfComments != null ? minAmountOfComments.Value : -1;
                searchArgs.MaxNumberOfComments = maxAmountOfComments != null ? maxAmountOfComments.Value : int.MaxValue;
                //Plays
                searchArgs.MinAmountPlayed = minAmountOfPlays != null ? minAmountOfPlays.Value : -1;
                searchArgs.MaxAmountPlayed = maxAmountOfPlays != null ? maxAmountOfPlays.Value : int.MaxValue;
                //Votes
                searchArgs.MinTotalVotes = minAmountOfVotes != null ? minAmountOfVotes.Value : -1;
                searchArgs.MaxTotalVotes = maxAmountOfVotes != null ? maxAmountOfVotes.Value : int.MaxValue;
                //Sorting
                searchArgs.SortOption = sortingKey + " " + sortingBy;

                searchArgs.Genres = genres.ChosenGenres != null ? genres.ChosenGenres.ToArray() : null;

                channels = proxy.GetChannels(searchArgs);
            }
            List<GuiChannel> guiChannels = GuiClassConverter.ConvertChannels(channels);
            Tuple<List<GuiChannel>, AdvancedSearchModel> model = new Tuple<List<GuiChannel>, AdvancedSearchModel>(guiChannels, (AdvancedSearchModel)searchArgs);
            return View("SearchResults", model);
        }
コード例 #28
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public ActionResult StopChannel(int channelId)
 {
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         if (proxy.CanStartStopChannels())
         {
             proxy.StopChannelStream(channelId);
         }
     }
     return Redirect(Request.UrlReferrer.PathAndQuery);
 }
コード例 #29
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public ActionResult SearchResult(string searchArgs, int? userId)
 {
     if (userId.HasValue)
     {
         SelectedGenrePostModel model = new SelectedGenrePostModel();
         model.ChosenGenres = null;
         return SearchAdv(searchArgs, null, null, null, null, null, null, null, null, "nam", "asc", 0, 10, model);
         using (RentItServiceClient proxy = new RentItServiceClient())
         {
             ChannelSearchArgs channelSearchArgs = proxy.GetDefaultChannelSearchArgs();
             channelSearchArgs.SearchString = searchArgs;
             Channel[] channels = proxy.GetChannels(channelSearchArgs);
             List<GuiChannel> guiChannels = GuiClassConverter.ConvertChannels(channels);
             ViewBag.Title = "Search results";
             return View("ChannelList", guiChannels);
         }
     }
     return RedirectToAction("Index", "Home");
 }
コード例 #30
0
ファイル: ChannelController.cs プロジェクト: markthor/RentIt
 public PartialViewResult AdvancedSearchWithArgs(AdvancedSearchModel model)
 {
     if (model.StartIndex < 0)
     {
         model.StartIndex = 0;
         model.EndIndex = 10;
     }
     if (model.SearchString == null)
         model.SearchString = "";
     Channel[] channels;
     using (RentItServiceClient proxy = new RentItServiceClient())
     {
         ChannelSearchArgs searchArgs = (ChannelSearchArgs)model;
         channels = proxy.GetChannels(searchArgs);
     }
     Tuple<List<GuiChannel>, AdvancedSearchModel> tuple = new Tuple<List<GuiChannel>, AdvancedSearchModel>(GuiClassConverter.ConvertChannels(channels), model);
     return PartialView("ChannelListForAdvancedSearch", tuple);
 }