Exemplo n.º 1
0
 public void Delete(int id = 0)
 {
     try {
         CurtDevDataContext db = new CurtDevDataContext();
         SalesRepresentative rep = db.SalesRepresentatives.Where(x => x.salesRepID.Equals(id)).First<SalesRepresentative>();
         db.SalesRepresentatives.DeleteOnSubmit(rep);
         db.SubmitChanges();
     } catch { }
 }
Exemplo n.º 2
0
 public void Delete()
 {
     try {
         CurtDevDataContext db = new CurtDevDataContext();
         CustomerUser u = db.CustomerUsers.Where(x => x.id == this.id).FirstOrDefault<CustomerUser>();
         db.CustomerUsers.DeleteOnSubmit(u);
         db.SubmitChanges();
     } catch (Exception e) {
         throw e;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// This will update the active/isactive status of the user.
 /// </summary>
 /// <param name="userID">ID of the user.</param>
 /// <returns>True/False</returns>
 public Boolean activate()
 {
     try {
         CurtDevDataContext db = new CurtDevDataContext();
         CustomerUser u = db.CustomerUsers.Where(x => x.id == this.id).FirstOrDefault<CustomerUser>();
         u.active = (u.active) ? false : true;
         db.SubmitChanges();
         return true;
     } catch {
         return false;
     }
 }
Exemplo n.º 4
0
 public SalesRepresentative Save(int id = 0, string name = "", string code = "")
 {
     CurtDevDataContext db = new CurtDevDataContext();
     SalesRepresentative rep = new SalesRepresentative();
     if (id > 0) {
         try {
             rep = db.SalesRepresentatives.Where(x => x.salesRepID.Equals(id)).First<SalesRepresentative>();
             rep.name = name.Trim();
             rep.code = code.Trim();
             db.SubmitChanges();
         } catch {}
     } else {
         rep = new SalesRepresentative {
             name = name.Trim(),
             code = code.Trim()
         };
         db.SalesRepresentatives.InsertOnSubmit(rep);
         db.SubmitChanges();
     }
     return rep;
 }
Exemplo n.º 5
0
        public void Run()
        {
            string url = this.url;
            WebClient wc = new WebClient();
            wc.Proxy = null;
            wc.DownloadString(url);

            CurtDevDataContext db = new CurtDevDataContext();
            ScheduledTask t = db.ScheduledTasks.Where(x => x.ID.Equals(this.ID)).FirstOrDefault<ScheduledTask>();
            t.lastRan = DateTime.Now;
            db.SubmitChanges();
        }
Exemplo n.º 6
0
        public List<LandingPageData> AddData(int pageID, string key, string value)
        {
            CurtDevDataContext db = new CurtDevDataContext();
            try {
                LandingPageData data = new LandingPageData {
                    dataKey = key.Trim(),
                    dataValue = value.Trim(),
                    landingPageID = pageID
                };
                db.LandingPageDatas.InsertOnSubmit(data);
                db.SubmitChanges();
            } catch { }

            return GetData(pageID);
        }
Exemplo n.º 7
0
 public List<LandingPageImage> AddImage(int pageID, string url)
 {
     CurtDevDataContext db = new CurtDevDataContext();
     int sort = 1;
     try {
         sort = db.LandingPageImages.Where(x => x.landingPageID.Equals(pageID)).OrderByDescending(x => x.sort).Select(x => x.sort).First() + 1;
     } catch {}
     LandingPageImage image = new LandingPageImage {
         landingPageID = pageID,
         url = url,
         sort = sort
     };
     db.LandingPageImages.InsertOnSubmit(image);
     db.SubmitChanges();
     return GetImages(pageID);
 }
Exemplo n.º 8
0
 public void Update(Google.YouTube.Video ytvideo)
 {
     CurtDevDataContext db = new CurtDevDataContext();
     Video v = db.Videos.Where(x => x.videoID.Equals(this.videoID)).FirstOrDefault<Video>();
     v.title = ytvideo.Title;
     v.description = ytvideo.Description;
     v.embed_link = ytvideo.VideoId;
     v.youtubeID = ytvideo.VideoId;
     v.watchpage = ytvideo.WatchPage.ToString();
     foreach (Google.GData.Extensions.MediaRss.MediaThumbnail thumb in ytvideo.Thumbnails) {
         if (thumb.Url.Contains("hqdefault")) {
             v.screenshot = thumb.Url;
         }
     }
     db.SubmitChanges();
 }
Exemplo n.º 9
0
 public void Remove(int id)
 {
     CurtDevDataContext db = new CurtDevDataContext();
     LandingPage page = db.LandingPages.Where(x => x.id.Equals(id)).First();
     List<LandingPageData> datas = page.LandingPageDatas.ToList(); ;
     List<LandingPageImage> images = page.LandingPageImages.ToList();
     db.LandingPageDatas.DeleteAllOnSubmit(datas);
     db.LandingPageImages.DeleteAllOnSubmit(images);
     db.LandingPages.DeleteOnSubmit(page);
     db.SubmitChanges();
 }
Exemplo n.º 10
0
 public void UpdateSort(int[] img)
 {
     CurtDevDataContext db = new CurtDevDataContext();
     int sort = 1;
     foreach (int imgID in img) {
         LandingPageImage image = db.LandingPageImages.Where(x => x.id.Equals(imgID)).First();
         image.sort = sort++;
         db.SubmitChanges();
     }
 }
Exemplo n.º 11
0
        public LandingPage Save(int id, string name, int websiteID, DateTime startDate, DateTime endDate, string url = "", string content = null, string linkClasses = null, bool newWindow = false, string conversionID = null, string conversionLabel = null, string menuPosition = "top")
        {
            CurtDevDataContext db = new CurtDevDataContext();
            LandingPage landingPage = new LandingPage();
            try {
                if (id == 0) {
                    landingPage = new LandingPage {
                        name = name,
                        websiteID = websiteID,
                        startDate = startDate,
                        endDate = endDate,
                        url = url.Trim(),
                        pageContent = content,
                        linkClasses = (linkClasses == null) ? linkClasses : linkClasses.Trim(),
                        newWindow = newWindow,
                        conversionID = conversionID,
                        conversionLabel = conversionLabel,
                        menuPosition = menuPosition
                    };
                    db.LandingPages.InsertOnSubmit(landingPage);
                } else {
                    landingPage = db.LandingPages.Where(x => x.id.Equals(id)).First();
                    landingPage.name = name;
                    landingPage.websiteID = websiteID;
                    landingPage.startDate = startDate;
                    landingPage.endDate = endDate;
                    landingPage.url = url.Trim();
                    landingPage.pageContent = content;
                    landingPage.linkClasses = (linkClasses == null) ? linkClasses : linkClasses.Trim();
                    landingPage.newWindow = newWindow;
                    landingPage.conversionID = conversionID;
                    landingPage.conversionLabel = conversionLabel;
                    landingPage.menuPosition = menuPosition;
                }
                db.SubmitChanges();
            } catch {}

            return landingPage;
        }
Exemplo n.º 12
0
        public List<LandingPageImage> RemoveImage(int id)
        {
            CurtDevDataContext db = new CurtDevDataContext();
            int pageID = 0;
            try {
                LandingPageImage image = db.LandingPageImages.Where(x => x.id.Equals(id)).First();
                pageID = image.landingPageID;
                db.LandingPageImages.DeleteOnSubmit(image);
                db.SubmitChanges();

                List<LandingPageImage> images = db.LandingPageImages.Where(x => x.landingPageID.Equals(pageID)).OrderBy(x => x.sort).ToList();
                int sort = 1;
                foreach (LandingPageImage img in images) {
                    img.sort = sort++;
                }
                db.SubmitChanges();
            } catch { }
            return GetImages(pageID);
        }
Exemplo n.º 13
0
        public List<LandingPageData> RemoveData(int id)
        {
            CurtDevDataContext db = new CurtDevDataContext();
            int pageID = 0;
            try {
                LandingPageData data = db.LandingPageDatas.Where(x => x.id.Equals(id)).First();
                pageID = data.landingPageID;
                db.LandingPageDatas.DeleteOnSubmit(data);
                db.SubmitChanges();
            } catch { }

            return GetData(pageID);
        }