Esempio n. 1
0
        public static void CreateLinksFromLinkSuggestionList(List <int> linkSuggestionRefList, bool useLinkSuggestionDate)
        {
            using (CLinq.DataContext db = CLinq.DataContext.Create())
            {
                var linkSuggestionList = db.LinkSuggestions.Where(ls => linkSuggestionRefList.Contains(ls.LinkSuggestionRef)).ToList();

                foreach (var linkSuggestion in linkSuggestionList)
                {
                    CLinq.Link link = new CuplexLib.Linq.Link();
                    link.CategoryRef = linkSuggestion.CategoryRef;
                    if (useLinkSuggestionDate)
                    {
                        link.LinkDate = linkSuggestion.LinkSuggestionDate;
                    }
                    else
                    {
                        link.LinkDate = DateTime.Now;
                    }
                    link.LinkName = linkSuggestion.Description;
                    link.LinkUrl  = linkSuggestion.LinkUrl;
                    link.UserRef  = linkSuggestion.UserRef;

                    db.Links.InsertOnSubmit(link);
                }
                db.SubmitChanges();
            }
        }
Esempio n. 2
0
        public static Link GetOne(int linkRef)
        {
            Link link = new Link();

            using (CLinq.DataContext db = CLinq.DataContext.Create())
            {
                CLinq.Link dbLink = db.Links.Where(l => l.LinkRef == linkRef).SingleOrDefault();
                if (dbLink == null)
                {
                    return(null);
                }

                link.LinkRef     = dbLink.LinkRef;
                link.CategoryRef = dbLink.CategoryRef;
                link.Clicks      = dbLink.Clicks;
                link.LinkDate    = dbLink.LinkDate;
                link.LinkName    = dbLink.LinkName;
                link.LinkUrl     = dbLink.LinkUrl;
                link.Rating      = dbLink.Rating;
                link.UserRef     = dbLink.UserRef;
                if (link.UserRef != null)
                {
                    link.UserName = dbLink.User.UserName;
                }
            }
            return(link);
        }
Esempio n. 3
0
        public void Save()
        {
            using (CLinq.DataContext db = CLinq.DataContext.Create())
            {
                CLinq.Link link;
                if (this.LinkRef > 0)
                {
                    link = db.Links.Where(l => l.LinkRef == this.LinkRef).SingleOrDefault();
                    if (link == null)
                    {
                        return;
                    }

                    link.CategoryRef = this.CategoryRef;
                    link.Clicks      = this.Clicks;
                    link.LinkDate    = this.LinkDate;
                    link.LinkName    = this.LinkName;
                    link.LinkUrl     = this.LinkUrl;
                    link.Rating      = this.Rating;
                    link.UserRef     = this.UserRef;
                }
                else
                {
                    link             = new CuplexLib.Linq.Link();
                    link.CategoryRef = this.CategoryRef;
                    link.Clicks      = this.Clicks;
                    link.LinkDate    = this.LinkDate;
                    link.LinkName    = this.LinkName;
                    link.LinkUrl     = this.LinkUrl;
                    link.Rating      = this.Rating;
                    link.UserRef     = this.UserRef;

                    db.Links.InsertOnSubmit(link);
                }

                db.SubmitChanges();
            }
        }