Exemplo n.º 1
0
        public ActionResult Create(Models.Channel channel)
        {
            if (ModelState.IsValid)
            {
                var url = ConfigurationManager.AppSettings["domain"] + "/push/channel/" + channel.Path;

                try
                {
                    CronofyHelper.CreateChannel(url, channel.OnlyManaged, channel.CalendarIds);
                }
                catch (CronofyResponseException ex)
                {
                    channel.SetError(ex);
                }

                if (channel.NoErrors())
                {
                    return(new RedirectResult("/channels"));
                }
            }

            ViewData["domain"]    = ConfigurationManager.AppSettings["domain"];
            ViewData["calendars"] = CronofyHelper.GetCalendars();

            return(View("New", channel));
        }
Exemplo n.º 2
0
 public ChattingWindowHeader(
     Models.Channel channel,
     System.Action onBack
     )
 {
     m_Channel = channel;
     m_OnBack  = onBack;
 }
Exemplo n.º 3
0
 public static Repository.Channels.Channel Map(Models.Channel model)
 {
     return(new Repository.Channels.Channel()
     {
         ID = model.ID,
         ChannelName = model.ChannelName,
         ChannelDesc = model.ChannelDesc
     });
 }
Exemplo n.º 4
0
        /// <summary>
        /// 在选中搜索结果时触发的方法
        /// </summary>
        /// <param name="result"></param>
        public void OnChooseSearchResult(Models.SearchResult result)
        {
            if (result == null)
            {
                return;
            }
            var channel = new Models.Channel()
            {
                Id = 0, Name = result.Title, Context = result.Context
            };

            this.CurrentChannel = channel;
        }
Exemplo n.º 5
0
        public ActionResult New()
        {
            var calendars = CronofyHelper.GetCalendars();

            var channel = new Models.Channel
            {
                CalendarIds = calendars.Select(x => x.CalendarId).ToArray(),
            };

            ViewData["domain"]    = ConfigurationManager.AppSettings["domain"];
            ViewData["calendars"] = calendars;

            return(View("New", channel));
        }
Exemplo n.º 6
0
 public ActionResult Post([FromBody] Models.Channel value)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     else if (value == null)
     {
         return(BadRequest());
     }
     else
     {
         _manager.CreateChannel(Mapper.Map(value));
         return(Ok(value));
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 根据频道和歌曲,得到歌曲列表
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="song"></param>
        /// <param name="type">n-New</param>
        /// <returns></returns>
        public List <Models.Song> GetSongList(Models.Channel channel, string type = "n")
        {
            Parameters parameters = new Parameters();

            parameters["channel"]  = channel.ID;
            parameters["from"]     = "mainsite";
            parameters["pt"]       = "0.0";
            parameters["kbps"]     = "128";
            parameters["formats"]  = "aac";
            parameters["alt"]      = "json";
            parameters["app_name"] = "radio_iphone";

            parameters["apikey"]      = "02646d3fb69a52ff072d47bf23cef8fd";
            parameters["client"]      = "s%3Amobile%7Cy%3AiOS%2010.2%7Cf%3A115%7Cd%3Ab88146214e19b8a8244c9bc0e2789da68955234d%7Ce%3AiPhone7%2C1%7Cm%3Aappstore";
            parameters["client_id"]   = "02646d3fb69a52ff072d47bf23cef8fd";
            parameters["icon_cate"]   = "xlarge";
            parameters["udid"]        = "b88146214e19b8a8244c9bc0e2789da68955234d";
            parameters["douban_udid"] = "b635779c65b816b13b330b68921c0f8edc049590";
            parameters["version"]     = "115";
            parameters["type"]        = type;
            parameters["channel"]     = channel.ID;

            string url = ConnectionBase.ConstructUrlWithParameters("https://api.douban.com/v2/fm/playlist", parameters);
            //string url = ConnectionBase.ConstructUrlWithParameters("https://douban.fm/j/v2/user_info?avatar_size=large", null);
            //获取列表
            string json         = new ConnectionBase().Get(url);
            var    playlistInfo = Framework.Common.Helpers.JsonHelper.Deserialize <Models.PlaylistInfo>(json);

            //将小图更换为大图
            foreach (var s in playlistInfo.SongList)
            {
                s.Picture = new Uri(s.Picture.ToString().Replace("/mpic/", "/lpic/").Replace("//otho.", "//img3."));
            }

            //去广告
            playlistInfo.SongList.RemoveAll(s => s.IsAd);

            return(playlistInfo.SongList);
        }
Exemplo n.º 8
0
        public ChannelResponse Create(Guid groupId, string name)
        {
            var channel = new Models.Channel
            {
                Id      = Guid.NewGuid(),
                GroupId = groupId,
                Name    = name
            };

            var channelUser = new ChannelUser(_authorizedUser, channel);

            _channelUserRepository.Add(channelUser);

            var channelUserDocument = new Documents.ChannelUser(_authorizedUser.Id, channel.Id);

            _channelUserStore.AddToBus(channelUserDocument);

            var group = _groupRepository.Get(groupId);

            _channelEventService.AddChannelCreatedEvent(group, _authorizedUser, channel);
            _channelEventService.AddUserAddedToChannelEvent(group, _authorizedUser, _authorizedUser, channel);

            return(_mapper.Map <ChannelResponse>(channel));
        }
Exemplo n.º 9
0
 public static Entities.Channel ToEntity(this Models.Channel model)
 {
     return(mapper.Map <Entities.Channel>(model));
 }
Exemplo n.º 10
0
        public void AddUserRemovedFromChannelEvent(Models.Group group, Models.User authorUser, Models.User user, Models.Channel channel)
        {
            var @event = new Event(EventType.UserRemovedFromChannel, authorUser, group);

            @event.AttachUser(user);
            @event.AttachChannel(channel);

            _eventStore.AddToBus(@event);
        }
Exemplo n.º 11
0
        public void AddChannelRemovedEvent(Models.Group @group, Models.User authorUser, Models.Channel channel)
        {
            var @event = new Event(EventType.ChannelRemoved, authorUser, group);

            @event.AttachChannel(channel);

            _eventStore.AddToBus(@event);
        }