Пример #1
0
        public async Task <IActionResult> ShareCreate(string id)
        {
            var playlist = new PlaylistData()
            {
                SpotifyUri = id
            };
            //Get cookie
            var token = Request.Cookies["spottoke"];

            //Get userid from spotify with cookie

            //Get the actual user id
            playlist.UserId = await GetUserId(token);

            playlist.Id = Guid.NewGuid().ToString();

            await _dataService.AddData <PlaylistData>("playlistdata", playlist, playlist.Id);

            var link = _linkService.GetLink(playlist);

            //Returns a view with a shareable link
            return(PartialView("CreateShareResult", new Link()
            {
                Url = link
            }));
        }
Пример #2
0
        /// <summary>
        /// ajax保存
        /// </summary>
        protected void SaveData(string act)
        {
            LinkInfo link = new LinkInfo();

            if (act == "update")
            {
                link = LinkService.GetLink(PressRequest.GetFormInt("hidLinkId", 0));
            }
            else
            {
                link.CreateTime = DateTime.Now;
                link.Type       = 0;// (int)LinkType.Custom;
            }
            link.LinkName    = HttpHelper.HtmlEncode(txtName.Text.Trim());
            link.LinkUrl     = HttpHelper.HtmlEncode(txtLinkUrl.Text.Trim());
            link.Description = HttpHelper.HtmlEncode(txtDescription.Text);
            link.SortNum     = TypeConverter.StrToInt(txtDisplayOrder.Text, 1000);
            link.Status      = chkStatus.Checked ? 1 : 0;
            link.Position    = chkPosition.Checked ? (int)LinkPosition.Navigation : (int)LinkPosition.General;
            link.Target      = chkTarget.Checked ? "_blank" : "_self";

            if (link.LinkName == "")
            {
                return;
            }

            Dictionary <string, string> jsondic = new Dictionary <string, string>();

            jsondic.Add("LinkName", link.LinkName);
            jsondic.Add("LinkUrl", link.LinkUrl);
            jsondic.Add("Description", link.Description);
            jsondic.Add("SortNum", link.SortNum.ToString());
            jsondic.Add("Position", link.Position == (int)Jqpress.Blog.Entity.Enum.LinkPosition.Navigation ? "[导航]" : "");
            jsondic.Add("Status", link.Status == 0 ? "[隐藏]" : "");


            if (act == "update")//更新操作
            {
                jsondic.Add("CreateTime", link.CreateTime.ToShortDateString());
                jsondic.Add("LinkId", link.LinkId.ToString());

                LinkService.UpdateLink(link);
                Response.Write(JsonHelper.DictionaryToJson(jsondic));
            }
            else//添加操作
            {
                int LinkId = LinkService.InsertLink(link);
                jsondic.Add("LinkId", LinkId.ToString());
                jsondic.Add("CreateTime", DateTime.Now.ToShortDateString());
                Response.Write(JsonHelper.DictionaryToJson(jsondic));
            }
            Response.End();
        }
Пример #3
0
        public void GetLink_with_invalid_input_returns_null()
        {
            //given
            PetOwner <PetBasicData> input = default(PetOwner <PetBasicData>);
            var sut = new LinkService <PetBasicData>(moqlUrlHelper.Object);

            //when
            var result = sut.GetLink(input);

            //then
            Assert.Null(result);
            moqlUrlHelper.Verify(v => v.Link(It.IsAny <string>(), It.IsAny <object>()), Times.Exactly(0));
        }
Пример #4
0
        public void GetLink_with_valid_input_on_error_returns_null()
        {
            //given
            PetOwner <PetBasicData> input = TestData.Owner;

            moqlUrlHelper.Setup(m => m.Link(It.IsAny <string>(), It.IsAny <object>())).Throws(new Exception());
            var sut = new LinkService <PetBasicData>(moqlUrlHelper.Object);

            //when
            var result = sut.GetLink(input);

            //then
            Assert.Null(result);
            moqlUrlHelper.Verify(v => v.Link(It.IsAny <string>(), It.IsAny <object>()), Times.AtLeast(1));
        }
Пример #5
0
        public void GetLink_with_valid_input_returns_wrapper_links_successfully()
        {
            //given
            var input = TestData.Owner;

            moqlUrlHelper.Setup(m => m.Link(It.IsAny <string>(), It.IsAny <object>())).Returns("TestUrl").Verifiable();
            var sut = new LinkService <PetBasicData>(moqlUrlHelper.Object);

            //when
            var result = sut.GetLink(input);

            //then
            Assert.NotNull(result);
            Assert.IsType <Link <PetOwner <PetBasicData> > >(result);
            moqlUrlHelper.Verify(v => v.Link(It.IsAny <string>(), It.IsAny <object>()), Times.AtLeast(1));
        }
Пример #6
0
        /// <summary>
        /// ajax获取json值
        /// </summary>
        protected void GetLinkJson()
        {
            LinkInfo link = LinkService.GetLink(Convert.ToInt32(Request["id"]));
            Dictionary <string, string> jsondic = new Dictionary <string, string>();

            jsondic.Add("LinkId", link.LinkId.ToString());
            jsondic.Add("LinkName", link.LinkName);
            jsondic.Add("LinkUrl", link.LinkUrl);
            jsondic.Add("Description", link.Description);
            jsondic.Add("SortNum", link.SortNum.ToString());
            chkStatus.Checked   = link.Status == 1 ? true : false;
            chkPosition.Checked = link.Position == (int)LinkPosition.Navigation ? true : false;
            chkTarget.Checked   = link.Target == "_blank" ? true : false;
            Response.Write(JsonHelper.DictionaryToJson(jsondic));
            Response.End();
        }
Пример #7
0
        public void BindData()
        {
            this.rpLink.DataSource = LinkService.GetLink(5);
            this.rpLink.DataBind();

            lbWebName.Text     = SettingManager.WebName;
            lbAddress.Text     = SettingManager.GetSettingValue("Contact.Address");
            lbFax.Text         = SettingManager.GetSettingValue("Contact.Fax");
            lbMobilePhone.Text = SettingManager.GetSettingValue("Contact.MobilePhone");
            lbTePhone.Text     = SettingManager.GetSettingValue("Contact.TelPhone");
            WeiXin             = SettingManager.GetSettingValue("Contact.WeiXin");
            QQ = SettingManager.GetSettingValue("Contact.QQ");


            this.rpZD.DataSource = NewsTypeService.GetChildTypeByParentId(5);
            this.rpZD.DataBind();
        }
Пример #8
0
 public async Task <string> PutLink([FromBody] Link model)
 {
     return(await db.GetLink(model.AbbreviatedTitle));
 }
Пример #9
0
        public ActionResult Edit(int id)
        {
            var link = ls.GetLink(id);

            return(View(link));
        }