public static LinkSuggestion GetOne(int linkSuggestionRef) { LinkSuggestion linkSuggestion = new LinkSuggestion(); using (CLinq.DataContext db = CLinq.DataContext.Create()) { CLinq.LinkSuggestion li = db.LinkSuggestions.Where(l => l.LinkSuggestionRef == linkSuggestionRef).SingleOrDefault(); if (li == null) { return(null); } linkSuggestion.LinkSuggestionRef = li.LinkSuggestionRef; linkSuggestion.CategoryRef = li.CategoryRef; linkSuggestion.Description = li.Description; linkSuggestion.LinkSuggestionDate = li.LinkSuggestionDate; linkSuggestion.LinkUrl = li.LinkUrl; linkSuggestion.UserRef = li.UserRef; } return(linkSuggestion); }
public void Save() { try { using (CLinq.DataContext db = CLinq.DataContext.Create()) { if (this.LinkSuggestionRef == 0) { CLinq.LinkSuggestion link = new CuplexLib.Linq.LinkSuggestion(); link.CategoryRef = this.CategoryRef; link.Description = this.Description; link.LinkUrl = this.LinkUrl; link.UserRef = this.UserRef; link.LinkSuggestionDate = this.LinkSuggestionDate; db.LinkSuggestions.InsertOnSubmit(link); } else { CLinq.LinkSuggestion link = db.LinkSuggestions.Where(l => l.LinkSuggestionRef == this.LinkSuggestionRef).SingleOrDefault(); if (link == null) { return; } link.CategoryRef = this.CategoryRef; link.Description = this.Description; link.LinkUrl = this.LinkUrl; link.UserRef = this.UserRef; link.LinkSuggestionDate = this.LinkSuggestionDate; } db.SubmitChanges(); } } catch { } }