コード例 #1
0
        public List<BannerItem> FbItems()
        {
            Atom10FeedFormatter formatter = new Atom10FeedFormatter();

            using (XmlReader reader = XmlReader.Create(ConfigurationManager.AppSettings["FacebookFeed"]))
            {
                formatter.ReadFrom(reader);
            }

            var bannerItems = new List<BannerItem>();

            foreach (var e in formatter.Feed.Items)
            {
                if (!e.Title.Text.StartsWith("Wallflux"))
                {
                    BannerItem le = new BannerItem();
                    le.title = e.Title.Text;
                    le.content = new entryContent
                    {
                        Value = ((TextSyndicationContent)e.Content).Text
                    };

                    le.link = new entryLink
                    {
                        href = e.Id,
                        target = "_blank"
                    };
                    le.updated = e.LastUpdatedTime.DateTime.ToShortDateString();
                    le.published = "Published on facebook "+e.PublishDate.DateTime.ToShortDateString();
                    le.TypeOfContent = Enum.GetName(typeof(TypeOfContent), TypeOfContent.FacebookPost);
                    bannerItems.Add(le);
                }
            }
            return bannerItems;

            /* sparas, extrahera bilder
            List<RssFeedItem> rssItems = new List<RssFeedItem>();
                    Stream stream = e.Result;
                    XmlReader response = XmlReader.Create(stream);
                    SyndicationFeed feeds = SyndicationFeed.Load(response);
                    foreach (SyndicationItem f in feeds.Items)
                    {
                        RssFeedItem rssItem = new RssFeedItem();

                        rssItem.Description = f.Summary.Text;

             const string rx =  @"(?<=img\s+src\=[\x27\x22])(?<Url>[^\x27\x22]*)(?=[\x27\x22])";
                        foreach (Match m in Regex.Matches(f.Summary.Text, rx, RegexOptions.IgnoreCase | RegexOptions.Multiline))
                        {
                            string src = m.Groups[1].Value;
                            if (src.StartsWith("//")) // Google RSS has it
                            {
                                src = src.Replace("//", "http://");
                            }

                            rssItem.ImageLinks.Add(src);
                        }

            */
        }
コード例 #2
0
        private List<BannerItem> UmbracoEvents()
        {
            var helper = new UmbracoHelper(UmbracoContext.Current);
            List<BannerItem> ue = new List<BannerItem>();
            IPublishedContent root = helper.Content(1068);
            IPublishedContent eventRoot = helper.Content(Convert.ToInt32(root.GetProperty("seminars").Value));
            foreach (var itm in eventRoot.Children.Where("Visible").Where("end >= DateTime.Now.Date").OrderBy("start"))
            {
                string input = itm.GetProperty("end").Value.ToString();
                DateTime dateTime;
                if (DateTime.TryParse(input, out dateTime))
                {
                    if (dateTime > DateTime.Now)
                    {
                        var bi = new BannerItem();
                        bi.title = itm.HasValue("subHeader") ? itm.GetProperty("subHeader").Value.ToString() : itm.Name;
                        if (itm.HasValue("country"))
                            bi.Country = itm.GetProperty("country").ToString();
                        bi.link = new entryLink
                        {
                            href = itm.Url,
                            target = "_self"
                        };
                        bi.published = bi.StartDateTime = "Seminar starts "+itm.GetProperty("start").Value.ToString().ToDate().ToShortDateString();

                        bi.updated = itm.UpdateDate.ToShortDateString();
                        bi.TypeOfContent = Enum.GetName(typeof(TypeOfContent),TypeOfContent.UmbracoEvent);

                        ue.Add(bi);
                    }
                }
            }
            return ue;
        }
コード例 #3
0
 public async Task <bool> Change(BannerItem bannerItem)
 {
     return(await WithConnection(async (connection) =>
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@Id", bannerItem.Id, DbType.String);
         parameters.Add("@BannerItemName", bannerItem.BannerItemName, DbType.String);
         parameters.Add("@BannerId", bannerItem.BannerId, DbType.String);
         parameters.Add("@TargetUrl", bannerItem.TargetUrl, DbType.String);
         parameters.Add("@ImageUrl", bannerItem.ImageUrl, DbType.String);
         parameters.Add("@Status", bannerItem.Status.AsEnumToInt(), DbType.Int16);
         parameters.Add("@StartDateUtc", bannerItem.StartDateUtc, DbType.DateTime);
         parameters.Add("@EndDateUtc", bannerItem.EndDateUtc, DbType.DateTime);
         parameters.Add("@IsDefault", bannerItem.IsDefault, DbType.Boolean);
         parameters.Add("@BackgroundRGB", bannerItem.BackgroundRGB, DbType.String);
         parameters.Add("@UpdatedDateUtc", bannerItem.UpdatedDateUtc, DbType.DateTime);
         parameters.Add("@UpdatedUid", bannerItem.UpdatedUid, DbType.String);
         var rowCount = 0;
         rowCount = await connection.ExecuteAsync(ProcName.BannerItem_Change, parameters, commandType: CommandType.StoredProcedure);
         if (rowCount > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }));
 }
コード例 #4
0
 public void Display(List <DataItem> _itemList, int _iIndex, string _strButton = "")
 {
     BannerBaseClear();
     foreach (DataItem data in _itemList)
     {
         GameObject objBanner = PrefabManager.Instance.MakeObject("prefab/PrefBannerItem", m_Grid.gameObject);
         BannerItem script    = objBanner.GetComponent <BannerItem> ();
         script.Initialize(data, GameMain.Instance.m_iCostNokori);
         BannerBaseAdd(objBanner);
     }
     setSwitchButton(_strButton, m_goScrollViewParent, m_Grid, _iIndex);
 }
コード例 #5
0
    public void Initialize(int _iItemId, string _strMessage, bool _bIsYesOnly = false)
    {
        base.Initialize(_strMessage, _bIsYesOnly);

        string strSpriteName = BannerItem.GetItemSpriteName(_iItemId);

        UIAtlas useatlas = AtlasManager.Instance.GetAtlas(strSpriteName);

        m_sprItem.atlas      = useatlas;
        m_sprItem.spriteName = strSpriteName;
        return;
    }
コード例 #6
0
        public ActionResult AjaxForm()
        {
            var model = new BannerItem();

            if (DoAction == ActionType.Edit)
            {
                model = da.GetItemById(ArrId.FirstOrDefault());
            }

            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            return(View(model));
        }
コード例 #7
0
        void Layout()
        {
            if (banner == null)
            {
                banner = new BannerItem(this);
            }

            items.Clear();
            items.Add(banner);
            Item item = new LabelItem(this, "Common Actions:", 0, banner.Bounds.Bottom + 3 * padding);

            items.Add(item);
            item = new LinkItem(this, "Create New Profile", StartEventType.Create, null, 0, item.Bounds.Bottom + text_padding);
            items.Add(item);
            item = new LinkItem(this, "Open Profile Log File", StartEventType.Open, null, 0, item.Bounds.Bottom);
            items.Add(item);

            int y = item.Bounds.Bottom + 3 * padding;

            if (history.LogFiles.Count > 0)
            {
                item = new LabelItem(this, "Recent Logs:", 0, y);
                y    = item.Bounds.Bottom + text_padding;
                items.Add(item);
                foreach (LogInfo info in history.LogFiles)
                {
                    item = new LinkItem(this, info.Caption, info.Detail, StartEventType.Open, info.Filename, 0, y);
                    items.Add(item);
                    y = item.Bounds.Bottom;
                }
            }

            int x = Allocation.Width / 2;

            if (history.Configs.Count > 0)
            {
                item = new LabelItem(this, "Quick Sessions:", x, banner.Bounds.Bottom + 3 * padding);
                items.Add(item);
                y = item.Bounds.Bottom + text_padding;
                foreach (ProfileConfiguration config in history.Configs)
                {
                    string text = config.ToString();
                    int    idx  = text.IndexOf(":");
                    item = new QuickStartItem(this, config, text.Substring(0, idx), text.Substring(idx + 1), x, y);
                    items.Add(item);
                    y = item.Bounds.Bottom;
                }
            }
        }
コード例 #8
0
ファイル: ManagerController.cs プロジェクト: fion45/FCStore
 public ActionResult SaveBannerManager(List <BannerItem> AddArr, List <BannerItem> EditArr, List <BannerItem> DelArr)
 {
     if (AddArr != null)
     {
         foreach (BannerItem item in AddArr)
         {
             BannerItem tmpObj = item;
             PubFunction.NotNullObj(ref tmpObj);
             db.BannerItems.Add(tmpObj);
         }
     }
     if (EditArr != null)
     {
         foreach (BannerItem item in EditArr)
         {
             BannerItem tmpObj = item;
             //奇怪,传进来的明明是""但是在后台获取就是null,只能做转换了
             PubFunction.NotNullObj(ref tmpObj);
             BannerItem tmpItem = db.BannerItems.FirstOrDefault(r => r.BIID == tmpObj.BIID);
             //tmpItem.Description = tmpObj.Description;
             //tmpItem.HrefPath = tmpObj.HrefPath;
             //tmpItem.ImgPath = tmpObj.ImgPath;
             //tmpItem.Index = tmpObj.Index;
             //tmpItem.Title = tmpObj.Title;
             PubFunction.CopyObj(tmpObj, ref tmpItem);
         }
     }
     if (DelArr != null)
     {
         foreach (BannerItem item in DelArr)
         {
             BannerItem tmpItem = db.BannerItems.FirstOrDefault(r => r.BIID == item.BIID);
             if (tmpItem != null)
             {
                 db.BannerItems.Remove(tmpItem);
             }
         }
     }
     db.SaveChanges();
     if (Request.IsAjaxRequest())
     {
         string jsonStr = PubFunction.BuildResult("OK");
         return(Content(jsonStr));
     }
     else
     {
         return(View());
     }
 }
コード例 #9
0
        public async Task <ICommandResult> Handle(BannerItemChangeCommand mesage)
        {
            try
            {
                ICommandResult result;
                var            rBanner = await _bannerService.GetBannerById(mesage.BannerId);

                if (rBanner == null)
                {
                    result = new CommandResult()
                    {
                        Message      = "Banner not found",
                        ObjectId     = "",
                        Status       = CommandResult.StatusEnum.Fail,
                        ResourceName = ResourceKey.Banner_NotFound
                    };
                    return(result);
                }
                RBannerItem[] rBannerItems = await _bannerService.GetBannerItemByBannerId(rBanner.Id);

                SystemDomains.Banner.Banner banner = new SystemDomains.Banner.Banner(rBanner, rBannerItems);

                BannerItem bannerItem = banner.ChangeItem(mesage);
                await _bannerService.ChangeBannerItem(bannerItem);

                await _eventSender.Notify(banner.Events);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = bannerItem.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = mesage;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
コード例 #10
0
        public async Task <ActionResult> Actions()
        {
            var msg   = new JsonMessage(false, "");
            var model = new BannerItem();

            switch (DoAction)
            {
            case ActionType.Add:
                UpdateModel(model);
                var objBanner = new Banner
                {
                    Name      = model.Name,
                    UrlView   = model.UrlView,
                    PictureID = model.PictureID,
                    //Datas =model.Datas,
                    Sort       = model.Sort,
                    UserId     = UserId,
                    DateCreate = DateTime.Now.TotalSeconds(),
                };
                da.Add(objBanner);
                da.Save();
                break;

            case ActionType.Edit:
                UpdateModel(model);
                var modelDb = da.GetById(ArrId.FirstOrDefault());
                modelDb.Name    = model.Name;
                modelDb.UrlView = model.UrlView;
                //modelDb.Datas = model.Datas;
                modelDb.Description = model.Description;
                modelDb.Details     = model.Details;
                modelDb.Sort        = model.Sort;
                da.Save();
                break;

            default:
                msg.Message = "Bạn chưa được phân quyền cho chức năng này.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
コード例 #11
0
        protected override void DrawItems()
        {
            StackLayout st = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };

            if (ItemSource == null)
            {
                return;
            }
            foreach (var item in ItemSource)
            {
                var add = new BannerItem()
                {
                    BindingContext = item
                };
                st.Children.Add(add);
            }
            Content = st;
        }
コード例 #12
0
 public void Display(List <DataItemMaster> _itemMasterList, int _iIndex, string _strButton = "")
 {
     BannerBaseClear();
     foreach (DataItemMaster data in _itemMasterList)
     {
         GameObject objBanner = PrefabManager.Instance.MakeObject("prefab/PrefBannerItem", gameObject);
         BannerItem script    = objBanner.GetComponent <BannerItem> ();
         if (script.Initialize(data, GameMain.Instance.m_iCostNokori))
         {
             BannerBaseAdd(objBanner);
             objBanner.transform.parent = m_Grid.transform;
             //Debug.Log ("insert");
         }
         else
         {
             //Debug.LogError ( string.Format( "nokemono:{0}" , data.item_id));
             Destroy(objBanner);
         }
     }
     setSwitchButton(_strButton, m_goScrollViewParent, m_Grid, _iIndex);
     m_Grid.enabled = true;
 }
コード例 #13
0
    public IEnumerator ShowList(int _iCategory)
    {
        ClearList();
        List <DataItemParam> item_param_list;

        if (_iCategory == 0)
        {
            item_param_list = DataManager.Instance.dataItem.list.FindAll(p => 0 < p.num);
        }
        else
        {
            item_param_list = DataManager.Instance.dataItem.list.FindAll(p => 0 < p.num && p.item_id / MasterItem.LargeCategory == _iCategory);
        }

        foreach (DataItemParam param in item_param_list)
        {
            BannerItem      script = PrefabManager.Instance.MakeScript <BannerItem>(m_prefItemBanner, m_goItemListContents);
            MasterItemParam master = DataManager.Instance.masterItem.list.Find(p => p.item_id == param.item_id);
            script.Initialize(param, master);
            script.HandleBannerEvent.AddListener(OnBannerEvent);
            yield return(null);
        }
    }
コード例 #14
0
    public void Show(List <DataItemParam> _data_list, List <MasterItemParam> _master_list)
    {
        m_prefBannerItem.SetActive(false);
        BannerItem[] arr = m_goContentRoot.GetComponentsInChildren <BannerItem>();
        foreach (BannerItem c in arr)
        {
            if (m_prefBannerItem != c.gameObject)
            {
                GameObject.Destroy(c.gameObject);
            }
        }

        foreach (DataItemParam data in _data_list)
        {
            BannerItem banner = PrefabManager.Instance.MakeScript <BannerItem>(m_prefBannerItem, m_goContentRoot);

            banner.Initialize(data, _master_list.Find(p => p.item_id == data.item_id));

            banner.OnClickBanner.AddListener((int _iSerial) =>
            {
                OnSelectItem.Invoke(_iSerial);
            });
        }
    }
コード例 #15
0
        public async Task <ActionResultResponse> Update(string tenantId, string bannerId, BannerMeta bannerMeta)
        {
            var bannerInfo = await _bannerRepository.GetInfo(bannerId);

            if (bannerInfo == null)
            {
                return(new ActionResultResponse(-1, _resourceService.GetString("Banner does not exists.")));
            }

            if (bannerInfo.TenantId != tenantId)
            {
                return(new ActionResultResponse(-2, _sharedResourceService.GetString("You do not have permission to to this action.")));
            }

            if (bannerInfo.ConcurrencyStamp != bannerMeta.ConcurrencyStamp)
            {
                return(new ActionResultResponse(-3, _resourceService.GetString("The Banner already updated by other people. You can not update this Banner.")));
            }

            //if (bannerInfo.Position != bannerMeta.Position)
            //{
            //    var isExistsInPosition = await _bannerRepository.CheckExistsByPosition(tenantId, bannerMeta.Position);
            //    if (isExistsInPosition)
            //        return new ActionResultResponse(-1, _resourceService.GetString("Banner already exists in position"));
            //}

            bannerInfo.LastUpdate       = DateTime.Now;
            bannerInfo.ConcurrencyStamp = Guid.NewGuid().ToString();
            bannerInfo.Name             = bannerMeta.Name;
            bannerInfo.Type             = bannerMeta.Type;
            bannerInfo.Description      = bannerMeta.Description;
            bannerInfo.UnsignName       = bannerMeta.Name.StripVietnameseChars().ToUpper();
            bannerInfo.DisplayType      = bannerMeta.DisplayType;
            bannerInfo.EffectType       = bannerMeta.EffectType;
            bannerInfo.IsActive         = bannerMeta.IsActive;
            bannerInfo.IsPopUp          = bannerMeta.IsPopUp;
            bannerInfo.Position         = bannerMeta.Position;

            var result = await _bannerRepository.Update(bannerInfo);

            if (result < 0)
            {
                return(new ActionResultResponse(result, _sharedResourceService.GetString("Something went wrong. Please contact with administrator.")));
            }

            var listBannerItem = await _bannerItemRepository.GetByBanner(bannerInfo.Id);

            if (listBannerItem != null && listBannerItem.Any())
            {
                foreach (var bannerItem in listBannerItem)
                {
                    var bannerItemExists = bannerMeta.BannerItems.Where(x => x.Id == bannerItem.Id).ToList();
                    if (bannerItemExists == null || bannerItemExists.Count() == 0)
                    {
                        await _bannerItemRepository.ForceDelete(bannerItem.Id);
                    }
                }
            }

            foreach (var bannerItemMeta in bannerMeta.BannerItems)
            {
                var bannerItem = await _bannerItemRepository.GetInfo(bannerItemMeta.Id);

                if (bannerItem != null)
                {
                    bannerItem.Name        = bannerItemMeta.Name;
                    bannerItem.Url         = bannerItemMeta.Url;
                    bannerItem.Image       = bannerItemMeta.Image;
                    bannerItem.Order       = bannerItemMeta.Order;
                    bannerItem.Alt         = bannerItemMeta.Alt;
                    bannerItem.Description = bannerItemMeta.Description;
                    await _bannerItemRepository.Update(bannerItem);
                }
                else
                {
                    bannerItem = new BannerItem()
                    {
                        Id          = Guid.NewGuid().ToString(),
                        BannerId    = bannerId,
                        Name        = bannerItemMeta.Name,
                        Url         = bannerItemMeta.Url,
                        Image       = bannerItemMeta.Image,
                        Order       = bannerItemMeta.Order,
                        Alt         = bannerItemMeta.Alt,
                        Description = bannerItemMeta.Description
                    };

                    await _bannerItemRepository.Insert(bannerItem);
                }
            }

            return(new ActionResultResponse(result, _resourceService.GetString("Update Banner successful.")));
        }
コード例 #16
0
        private void BannerTappedMethod(BannerItem bannerItem)
        {
            if (bannerItem == null || MainStatus == null)
            {
                return;
            }

            var collectionTag = "collections";
            var roundTableTag = "roundtable";
            var articleTag    = "articles";

            if (bannerItem.Url.Contains(collectionTag))
            {
                var collectionIdString =
                    bannerItem.Url.Substring(bannerItem.Url.IndexOf(collectionTag, StringComparison.Ordinal) +
                                             collectionTag.Length + 1);
                var collectionId = 0;

                Int32.TryParse(collectionIdString, out collectionId);

                NavHelper.NavToCollectionPage(collectionId, AppShellPage.AppFrame);

                SystemNavigationManager.GetForCurrentView().BackRequested -= FindPage_BackRequested;
            }
            else if (bannerItem.Url.Contains(roundTableTag))
            {
                var tableIdString =
                    bannerItem.Url.Substring(bannerItem.Url.IndexOf(roundTableTag, StringComparison.Ordinal) +
                                             roundTableTag.Length + 1);

                NavHelper.NavToTablePage(tableIdString, AppShellPage.AppFrame);

                SystemNavigationManager.GetForCurrentView().BackRequested -= FindPage_BackRequested;
            }
            else if (bannerItem.Url.Contains(articleTag))
            {
                var articleIdString =
                    bannerItem.Url.Substring(bannerItem.Url.IndexOf(articleTag, StringComparison.Ordinal) +
                                             articleTag.Length + 1);
                var articleId = 0;

                Int32.TryParse(articleIdString, out articleId);

                if (MainStatus.IsWide)
                {
                    SystemNavigationManager.GetForCurrentView().BackRequested -= FindPage_BackRequested;
                }
                else
                {
                    if (this.MainStatus.NavFrame.CanGoBack)
                    {
                        this.MainStatus.NavFrame.GoBack();
                    }
                }

                NavHelper.NavToArticlePage(articleId, MainStatus.NavFrame);
            }
            else
            {
                if (MainStatus.IsWide)
                {
                    SystemNavigationManager.GetForCurrentView().BackRequested -= FindPage_BackRequested;
                }
                else
                {
                    if (this.MainStatus.NavFrame.CanGoBack)
                    {
                        this.MainStatus.NavFrame.GoBack();
                    }
                }
                //NavHelper.NavToTablePage("rationalize", AppShellPage.AppFrame);
                NavHelper.HyperLinkClicked(bannerItem.Url, MainStatus.NavFrame);
            }
        }
コード例 #17
0
ファイル: StartPage.cs プロジェクト: mono/emveepee
        void Layout()
        {
            if (banner == null)
                banner = new BannerItem (this);

            items.Clear ();
            items.Add (banner);
            Item item = new LabelItem (this, "Common Actions:", 0, banner.Bounds.Bottom + 3 * padding);
            items.Add (item);
            item = new LinkItem (this, "Create New Profile", StartEventType.Create, null, 0, item.Bounds.Bottom + text_padding);
            items.Add (item);
            item = new LinkItem (this, "Open Profile Log File", StartEventType.Open, null, 0, item.Bounds.Bottom);
            items.Add (item);

            int y = item.Bounds.Bottom + 3 * padding;
            if (history.LogFiles.Count > 0) {
                item = new LabelItem (this, "Recent Logs:", 0, y);
                y = item.Bounds.Bottom + text_padding;
                items.Add (item);
                foreach (LogInfo info in history.LogFiles) {
                    item = new LinkItem (this, info.Caption, info.Detail, StartEventType.Open, info.Filename, 0, y);
                    items.Add (item);
                    y = item.Bounds.Bottom;
                }
            }

            int x = Allocation.Width / 2;
            if (history.Configs.Count > 0) {
                item = new LabelItem (this, "Quick Sessions:", x, banner.Bounds.Bottom + 3 * padding);
                items.Add (item);
                y = item.Bounds.Bottom + text_padding;
                foreach (ProfileConfiguration config in history.Configs) {
                    string text = config.ToString ();
                    int idx = text.IndexOf (":");
                    item = new QuickStartItem (this, config, text.Substring (0, idx), text.Substring (idx + 1), x, y);
                    items.Add (item);
                    y = item.Bounds.Bottom;
                }
            }
        }
コード例 #18
0
 public async Task <bool> AddBannerItem(BannerItem bannerItem)
 {
     return(await _bannerItemRepository.Add(bannerItem));
 }
コード例 #19
0
        public async Task <ActionResultResponse> Insert(string tenantId, BannerMeta bannerMeta)
        {
            var bannerId = Guid.NewGuid().ToString();

            //var isExistsInPosition = await _bannerRepository.CheckExistsByPosition(tenantId, bannerMeta.Position);
            //if (isExistsInPosition)
            //    return new ActionResultResponse(-1, _resourceService.GetString("Banner already exists in position"));

            var banner = new Banner
            {
                Id = bannerId,
                ConcurrencyStamp = bannerId,
                TenantId         = tenantId,
                Name             = bannerMeta.Name,
                Type             = bannerMeta.Type,
                Description      = bannerMeta.Description,
                UnsignName       = bannerMeta.Name.StripVietnameseChars().ToUpper(),
                DisplayType      = bannerMeta.DisplayType,
                EffectType       = bannerMeta.EffectType,
                IsActive         = bannerMeta.IsActive,
                IsPopUp          = bannerMeta.IsPopUp,
                Position         = bannerMeta.Position,
            };

            var result = await _bannerRepository.Insert(banner);

            if (result <= 0)
            {
                return(new ActionResultResponse(result, _sharedResourceService.GetString("Something went wrong. Please contact with administrator.")));
            }

            if (!bannerMeta.BannerItems.Any() || bannerMeta.BannerItems == null)
            {
                await RollbackInsert(bannerId);

                return(new ActionResultResponse(-4, _resourceService.GetString("Please inser banner item")));
            }

            var lstBannerItem = new List <BannerItem>();

            foreach (var bannerItemMeta in bannerMeta.BannerItems)
            {
                var pannerItem = new BannerItem
                {
                    Id          = Guid.NewGuid().ToString(),
                    BannerId    = banner.Id,
                    Name        = bannerItemMeta.Name,
                    Url         = bannerItemMeta.Url,
                    Image       = bannerItemMeta.Image,
                    Order       = bannerItemMeta.Order,
                    Alt         = bannerItemMeta.Alt,
                    Description = bannerItemMeta.Description
                };
                lstBannerItem.Add(pannerItem);
            }

            var resultBannerItem = await _bannerItemRepository.Inserts(lstBannerItem);

            if (resultBannerItem <= 0)
            {
                await RollbackInsert(bannerId);

                return(new ActionResultResponse(-5, _resourceService.GetString("Can not insert new Banner. Please contact with administrator.")));
            }

            return(new ActionResultResponse(1, _resourceService.GetString("Add new new banner successful.")));
        }
コード例 #20
0
 public async Task <bool> ChangeBannerItem(BannerItem bannerItem)
 {
     return(await _bannerItemRepository.Change(bannerItem));
 }
コード例 #21
0
        public List<BannerItem> YoutubeItems()
        {
            XElement feedXML = XElement.Load(ConfigurationManager.AppSettings["YoutubeFeed"]);
            XNamespace atom = "http://www.w3.org/2005/Atom";
            XNamespace media = "http://search.yahoo.com/mrss/";

            var bannerItems = new List<BannerItem>();

            var feeds = feedXML.Elements().Where(element => element.Name == atom + "entry");

            foreach (var feed in feeds)
            {
                var bi= new BannerItem();
                bi.title = feed.Element(media+"group").Element(media + "title").Value+" - Video";
                bi.MediaUrl =
                    feed.Element(media + "group").Element(media + "thumbnail") != null
                        ? feed.Element(media + "group").Element(media + "thumbnail").Attribute("url").Value
                        : "";
                bi.link = new entryLink()
                {
                    href = feed.Element(atom + "link").Attribute("href").Value,
                    target = "_blank"
                };
                bi.TypeOfContent = Enum.GetName(typeof(TypeOfContent), TypeOfContent.YoutubeMedia);
                bi.published = feed.Element(media + "group").Element(media + "community").Element(media + "statistics").
                    Attribute("views").Value+ " views on Youtube";
                bannerItems.Add(bi);
            }
            return bannerItems;
        }