public static string GetChannelOwner(int userId) { using (RentItServiceClient proxy = new RentItServiceClient()) { return proxy.GetUser(userId).Username; } }
public static bool HasChannelTracks(int channelId) { using (RentItServiceClient proxy = new RentItServiceClient()) { return proxy.GetTrackByChannelId(channelId).Length > 0; } }
public static bool IsChannelPlaying(int channelId) { using (RentItServiceClient proxy = new RentItServiceClient()) { return proxy.IsChannelPlaying(channelId); } }
public static bool CanStartStopChannels() { using (RentItServiceClient proxy = new RentItServiceClient()) { return proxy.CanStartStopChannels(); } }
public static int GetCountChannelComments(int channelId) { using (RentItServiceClient proxy = new RentItServiceClient()) { return proxy.GetCountChannelComments(channelId); } }
/// <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"); }
public static int TotalChannels() { using (RentItServiceClient proxy = new RentItServiceClient()) { ChannelSearchArgs searchArgs = proxy.GetDefaultChannelSearchArgs(); searchArgs.SortOption = searchArgs.SubscriptionsDesc; return proxy.CountAllChannelsWithFilter(searchArgs); } }
public static int TotalChannelsWithFilter(AdvancedSearchModel model) { int count; using (RentItServiceClient proxy = new RentItServiceClient()) { count = proxy.CountAllChannelsWithFilter((ChannelSearchArgs)model); } return count; }
public static int GetUpvotes(int trackId) { int upvotes; using (RentItServiceClient proxy = new RentItServiceClient()) { upvotes = proxy.CountAllUpvotes(trackId); } return upvotes; }
public static int GetDownvotes(int trackId) { int downvotes; using (RentItServiceClient proxy = new RentItServiceClient()) { downvotes = proxy.CountAllDownvotes(trackId); } return downvotes; }
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); }
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); }
public static List<GuiGenre> GetAllAvailableGenres() { List<GuiGenre> availableGenres; using (RentItServiceClient proxy = new RentItServiceClient()) { Genre[] allGenres = proxy.GetAllGenres(); availableGenres = GuiClassConverter.ConvertGenres(allGenres); } return availableGenres; }
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)); }
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); } }
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); } }
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); } }
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)); }
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; } }
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"); }
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; }
// // 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)); }
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); } }
/// <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; }
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; }
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"); }
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); }
public ActionResult StopChannel(int channelId) { using (RentItServiceClient proxy = new RentItServiceClient()) { if (proxy.CanStartStopChannels()) { proxy.StopChannelStream(channelId); } } return Redirect(Request.UrlReferrer.PathAndQuery); }
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"); }
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); }