public static string Save(int pVideoID = 0, int partID = 0, int vTypeID = 0, string video = "", bool isPrimary = false) { CurtDevDataContext db = new CurtDevDataContext(); PartVideo v = new PartVideo(); try { if(pVideoID > 0) { v = db.PartVideos.Where(x => x.pVideoID == pVideoID).First<PartVideo>(); v.video = video; v.isPrimary = isPrimary; v.vTypeID = vTypeID; v.partID = partID; db.SubmitChanges(); } else { v = new PartVideo { isPrimary = isPrimary, vTypeID = vTypeID, video = video, partID = partID }; db.PartVideos.InsertOnSubmit(v); db.SubmitChanges(); } ProductModels.UpdatePart(partID); } catch { return "error"; } return JsonConvert.SerializeObject(Get(v.pVideoID)); }
public string AddDiscussionAjax(int topicid = 0, string addtitle = "", string post = "", string name = "", string email = "", string company = "", bool notify = false, string recaptcha_challenge_field = "", string recaptcha_response_field = "") { CurtDevDataContext db = new CurtDevDataContext(); JavaScriptSerializer js = new JavaScriptSerializer(); #region trycatch try { string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"]; if (!(Models.ReCaptcha.ValidateCaptcha(recaptcha_challenge_field, recaptcha_response_field, remoteip))) { throw new Exception("The Captcha was incorrect. Try again please!"); } if (topicid == 0) { throw new Exception("The topic was invalid."); } if (addtitle.Trim() == "") { throw new Exception("Title is required."); } if (post.Trim() == "") { throw new Exception("Post is required"); } if (email.Trim() != "" && (!IsValidEmail(email.Trim()))) { throw new Exception("Your email address was not a valid address."); } if (notify == true && email.Trim() == "") { throw new Exception("You cannot be notified by email without an email address."); } if(checkIPAddress(remoteip)) { throw new Exception("You cannot post because your IP Address is blocked by our server."); } bool moderation = Convert.ToBoolean(ConfigurationManager.AppSettings["ForumModeration"]); ForumThread t = new ForumThread { topicID = topicid, active = true, closed = false, createdDate = DateTime.Now, }; db.ForumThreads.InsertOnSubmit(t); db.SubmitChanges(); ForumPost p = new ForumPost { threadID = t.threadID, title = addtitle, post = post, name = name, email = email, notify = notify, approved = !moderation, company = company, createdDate = DateTime.Now, flag = false, active = true, IPAddress = remoteip, parentID = 0, sticky = false }; db.ForumPosts.InsertOnSubmit(p); db.SubmitChanges(); Post newpost = ForumModel.GetPost(p.postID); return js.Serialize(newpost); } catch (Exception e) { return "{\"error\": \"" + e.Message + "\"}"; } #endregion }
public static void DeleteType(int id = 0) { CurtDevDataContext db = new CurtDevDataContext(); IEnumerable<ContactReceiver_ContactType> types = db.ContactReceiver_ContactTypes.Where(x => x.contactTypeID == id).ToList<ContactReceiver_ContactType>(); db.ContactReceiver_ContactTypes.DeleteAllOnSubmit(types); db.SubmitChanges(); ContactType type = db.ContactTypes.Where(x => x.contactTypeID == id).Single<ContactType>(); db.ContactTypes.DeleteOnSubmit(type); db.SubmitChanges(); }
public ActionResult AddReceiver() { string error = ""; CurtDevDataContext db = new CurtDevDataContext(); #region Form Submission try { if (Request.Form.Count > 0) { // Save form values string first_name = (Request.Form["first_name"] != null) ? Request.Form["first_name"] : ""; string last_name = (Request.Form["last_name"] != null) ? Request.Form["last_name"] : ""; string email = (Request.Form["email"] != null) ? Request.Form["email"] : ""; List<string> types = (Request.Form["types"] != null) ? Request.Form["types"].Split(',').ToList<string>() : new List<string>(); // Validate the form fields if (email.Length == 0) throw new Exception("Email is required."); if (types.Count() == 0) throw new Exception("At least one Receiver Type is required."); // Create the new customer and save ContactReceiver new_receiver = new ContactReceiver { first_name = first_name, last_name = last_name, email = email }; db.ContactReceivers.InsertOnSubmit(new_receiver); db.SubmitChanges(); if (types.Count() > 0) { foreach (string type in types) { if (type != "") { try { ContactReceiver_ContactType rectype = new ContactReceiver_ContactType { contactReceiverID = new_receiver.contactReceiverID, contactTypeID = Convert.ToInt32(type) }; db.ContactReceiver_ContactTypes.InsertOnSubmit(rectype); } catch { } } } } db.SubmitChanges(); return RedirectToAction("Receivers"); } } catch (Exception e) { error = e.Message; } #endregion ViewBag.types = ContactModel.GetTypes(); ViewBag.error = error; return View(); }
public static string Add(int partID = 0, int rating = 0, string subject = "", string review_text = "", string name = "", string email = "", int reviewID = 0) { if (partID == 0 || review_text.Length == 0) { return "{\"error\":\"Invalid data.\"}"; } try { CurtDevDataContext db = new CurtDevDataContext(); Review r = new Review(); if (reviewID == 0) { // Create new review r = new Review { partID = partID, rating = rating, subject = subject, review_text = review_text, name = name, email = email, createdDate = DateTime.Now, approved = false, active = true, cust_id = 1 }; db.Reviews.InsertOnSubmit(r); db.SubmitChanges(); } else { r = (from rev in db.Reviews where rev.reviewID.Equals(reviewID) select rev).FirstOrDefault<Review>(); r.name = name; r.review_text = review_text; r.rating = rating; r.subject = subject; r.email = email; db.SubmitChanges(); } r = Get(r.reviewID); try { ProductModels.UpdatePart((int)r.partID); } catch { } JavaScriptSerializer js = new JavaScriptSerializer(); return js.Serialize(r); } catch (Exception e) { return "{\"error\":\"" + e.Message + "\"}"; } }
public ActionResult AddPost(int id = 0, string titlestr = "", string post = "", bool sticky = false) { string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"]; try { if (id == 0) throw new Exception("Topic is required."); if (titlestr.Trim().Length == 0) throw new Exception("Title is required."); if (post.Trim().Length == 0) throw new Exception("Post content is required."); CurtDevDataContext db = new CurtDevDataContext(); ForumThread t = new ForumThread { topicID = id, active = true, closed = false, createdDate = DateTime.Now }; db.ForumThreads.InsertOnSubmit(t); db.SubmitChanges(); user u = Users.GetUser(Convert.ToInt32(Session["userID"])); ForumPost p = new ForumPost { threadID = t.threadID, title = titlestr, post = post, IPAddress = remoteip, createdDate = DateTime.Now, approved = true, active = true, flag = false, notify = false, parentID = 0, name = u.fname + " " + u.lname, company = "CURT Manufacturing", email = u.email, sticky = sticky }; db.ForumPosts.InsertOnSubmit(p); db.SubmitChanges(); return RedirectToAction("threads", new { id = id }); } catch (Exception e) { FullTopic topic = ForumModel.GetTopic(id); ViewBag.topic = topic; ViewBag.error = e.Message; ViewBag.titlestr = titlestr; ViewBag.post = post; ViewBag.sticky = sticky; return View(); } }
public ActionResult Save(int id = 0, string question = "", string answer = "") { try { if (question.Length == 0) { throw new Exception("You must enter a question"); } if (answer.Length == 0) { throw new Exception("You must enter an answer"); } CurtDevDataContext db = new CurtDevDataContext(); if (id == 0) { FAQ faq = new FAQ { answer = answer, question = question }; db.FAQs.InsertOnSubmit(faq); } else { FAQ faq = db.FAQs.Where(x => x.faqID == id).FirstOrDefault<FAQ>(); faq.question = question; faq.answer = answer; } db.SubmitChanges(); return RedirectToAction("Index"); } catch (Exception e) { if (id == 0) { return RedirectToAction("Add", new { err = e.Message, q = question, a = answer }); } else { return RedirectToAction("Edit", new { id = id, err = e.Message, q = question, a = answer }); } } }
public static string AddImage(int partID = 0, int sizeid = 0, string webfile = "", string localfile = "") { try { CurtDevDataContext db = new CurtDevDataContext(); JavaScriptSerializer js = new JavaScriptSerializer(); char sort = 'a'; try { sort = db.PartImages.Where(x => x.partID.Equals(partID)).Where(x => x.sizeID.Equals(sizeid)).OrderByDescending(x => x.sort).Select(x => x.sort).First<char>(); sort = GetNextLetter(sort.ToString()); } catch {}; System.Drawing.Image img = System.Drawing.Image.FromFile(localfile); PartImage image = new PartImage { partID = partID, sizeID = sizeid, path = webfile, height = img.Height, width = img.Width, sort = sort }; img.Dispose(); db.PartImages.InsertOnSubmit(image); db.SubmitChanges(); return js.Serialize(image); } catch { return "error"; } }
public static FullVideo Create(Google.YouTube.Video ytVideo = null) { if (ytVideo == null) { throw new Exception("Invalid link"); } CurtDevDataContext db = new CurtDevDataContext(); Video new_video = new Video { embed_link = ytVideo.VideoId, title = ytVideo.Title, screenshot = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[2].Url : "/Content/img/noimage.jpg", description = ytVideo.Description, watchpage = ytVideo.WatchPage.ToString(), youtubeID = ytVideo.VideoId, dateAdded = DateTime.Now, sort = (db.Videos.Count() == 0) ? 1 : db.Videos.OrderByDescending(x => x.sort).Select(x => x.sort).First() + 1 }; db.Videos.InsertOnSubmit(new_video); db.SubmitChanges(); FullVideo fullvideo = new FullVideo { videoID = new_video.videoID, embed_link = new_video.embed_link, dateAdded = new_video.dateAdded, sort = new_video.sort, videoTitle = new_video.title, thumb = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[0].Url : "/Content/img/noimage.jpg" }; return fullvideo; }
public static string AddCategoryToPart(int catID = 0, int partID = 0) { if (catID == 0 || partID == 0) { return "Invalid parameters."; } try { CurtDevDataContext db = new CurtDevDataContext(); // Make sure this category isn't already tied to this product int existing = (from cp in db.CatParts where cp.catID.Equals(catID) && cp.partID.Equals(partID) select cp).Count(); if (existing > 0) { return "The association exists."; } CatParts cat_part = new CatParts { catID = catID, partID = partID }; db.CatParts.InsertOnSubmit(cat_part); db.SubmitChanges(); UpdatePart(partID); } catch (Exception e) { return e.Message; } return ""; }
public ActionResult AddNews(int displayOrder = 0, string title = "", string pageContent = "", string subTitle = "", string isActive = "", string showDealers = "", string showPublic = "") { try { TechNews item = new TechNews(); Boolean blnIsActive = false; blnIsActive = (isActive == "on") ? true : false; Boolean blnShowPublic = false; blnShowPublic = (showPublic == "on") ? true : false; Boolean blnShowDealers = false; blnShowDealers = (showDealers == "on") ? true : false; item.title = title; item.pageContent = pageContent; item.subTitle = subTitle; item.displayOrder = displayOrder; item.active = blnIsActive; item.showDealers = blnShowDealers; item.showPublic = blnShowPublic; item.dateModified = DateTime.Now; ViewBag.item = item; CurtDevDataContext db = new CurtDevDataContext(); db.TechNews.InsertOnSubmit(item); db.SubmitChanges(); return RedirectToAction("News", new { successMsg = "The news item was successfully added." }); } catch (Exception e) { ViewBag.error = "Could not add news item: " + e.Message; } return View(); }
public ActionResult AddType() { string error = ""; CurtDevDataContext db = new CurtDevDataContext(); #region Form Submission try { if (Request.Form.Count > 0) { // Save form values string fileType = (Request.Form["fileType"] != null) ? Request.Form["fileType"] : ""; // Validate the form fields if (fileType.Length == 0) throw new Exception("Name is required."); // Create the new customer and save FileType new_type = new FileType { fileType1 = fileType }; db.FileTypes.InsertOnSubmit(new_type); db.SubmitChanges(); return RedirectToAction("Types"); } } catch (Exception e) { error = e.Message; } #endregion ViewBag.error = error; return View(); }
/// <summary> /// Delete the given category from the database and break relationship to any parts. /// </summary> /// <param name="catID">ID of the category</param> /// <returns>Error message (string)</returns> public static string DeleteCategory(int catID = 0) { if (catID == 0) { throw new Exception("There was error while processing. Category data is invalid."); } try { CurtDevDataContext db = new CurtDevDataContext(); Categories cat = (from c in db.Categories where c.catID.Equals(catID) select c).FirstOrDefault<Categories>(); db.Categories.DeleteOnSubmit(cat); List<ContentBridge> bridges = db.ContentBridges.Where(x => x.catID.Equals(catID)).ToList<ContentBridge>(); List<int> contentids = bridges.Select(x => x.contentID).ToList(); List<Content> contents = db.Contents.Where(x => contentids.Contains(x.contentID)).ToList<Content>(); db.ContentBridges.DeleteAllOnSubmit(bridges); db.Contents.DeleteAllOnSubmit(contents); // Remove the CatPart relationships for this category List<CatParts> cp = (from cat_parts in db.CatParts where cat_parts.catID.Equals(catID) select cat_parts).ToList<CatParts>(); db.CatParts.DeleteAllOnSubmit<CatParts>(cp); db.SubmitChanges(); } catch (Exception e) { return e.Message; } return ""; }
public static bool Send(Contact contact) { try { CurtDevDataContext db = new CurtDevDataContext(); SmtpClient SmtpServer = new SmtpClient(); List<ContactReceiver> receivers = (from cr in db.ContactReceivers join crt in db.ContactReceiver_ContactTypes on cr.contactReceiverID equals crt.contactReceiverID join ct in db.ContactTypes on crt.contactTypeID equals ct.contactTypeID where ct.name.ToLower().Trim().Equals(contact.type.ToLower().Trim()) select cr).ToList<ContactReceiver>(); if (receivers.Count() == 0) { receivers = db.ContactReceivers.ToList<ContactReceiver>(); } db.Contacts.InsertOnSubmit(contact); db.SubmitChanges(); foreach (ContactReceiver receiver in receivers) { MailMessage mail = new MailMessage(); mail.To.Add(receiver.email); mail.Subject = "New Website Contact: " + contact.subject; mail.IsBodyHtml = true; string mailhtml = contact.first_name + " " + contact.last_name + " said: " + contact.message; string mailto = "mailto" + ":" + contact.email + "?subject=Re: " + contact.subject + "&body=" + mailhtml; string htmlBody = "<p>Hi " + receiver.first_name + ",</p>"; htmlBody += "<p>We've received a new web contact.<br /><a style=\"border: 2px solid #e64d2d; text-transform: uppercase; color: #e64d2d; font-weight: bold; padding: 2px 6px; font-size: 14px; text-decoration: none;\" href=\"" + mailto + "\">Click to Reply</a></p>"; htmlBody += "<table><tr><td style=\"vertical-align: top;\"><strong>Name: </strong></td><td>" + contact.first_name + " " + contact.last_name + "</td></tr>"; htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Reason: </strong></td><td>" + contact.type + "</td></tr>"; htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Email: </strong></td><td>" + contact.email + "</td></tr>"; if (contact.phone != "") { htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Phone: </strong></td><td>" + contact.phone + "</td></tr>"; } if (contact.address1 != "") { htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Address1: </strong></td><td>" + contact.address1 + "</td></tr>"; } if (contact.address2 != "") { htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Address2: </strong></td><td>" + contact.address2 + "</td></tr>"; } if (contact.city != "") { htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>City: </strong></td><td>" + contact.city + "</td></tr>"; } if (contact.state != "") { htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>State / Province: </strong></td><td>" + contact.state + "</td></tr>"; } if (contact.postalcode != "") { htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Postal Code: </strong></td><td>" + contact.postalcode + "</td></tr>"; } if (contact.country != "") { htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Country: </strong></td><td>" + contact.country + "</td></tr>"; } htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Subject: </strong></td><td>" + contact.subject + "</td></tr>"; htmlBody += "<tr><td style=\"vertical-align: top;\"><strong>Message: </strong></td><td>" + contact.message + "</td></tr></table>"; mail.Body = htmlBody; SmtpServer.Send(mail); } return true; } catch { return false; } }
public ActionResult Add(int partID = 0, string shortDesc = "", int status = 0, string oldPartNumber = "", int priceCode = 0, int classID = 0, string btnSubmit = "", string btnContinue = "", string upc = "", bool featured = false, int? ACESPartTypeID = null) { CurtDevDataContext db = new CurtDevDataContext(); List<string> error_messages = new List<string>(); Part new_part = new Part{ partID = partID, shortDesc = shortDesc, status = status, oldPartNumber = oldPartNumber, priceCode = priceCode, classID = classID, dateAdded = DateTime.Now, dateModified = DateTime.Now, featured = featured, ACESPartTypeID = ACESPartTypeID }; // Validate the partID and shortDesc fields if(partID == 0){ error_messages.Add("You must enter a part number."); } if(shortDesc.Length == 0){ error_messages.Add("You must enter a short description."); } if (upc.Trim().Length == 0) { error_messages.Add("You must enter a UPC."); } int existing_part = 0; // Make sure we don't have a product with this partID existing_part = (from p in db.Parts where p.partID.Equals(partID) select p).Count(); if (existing_part != 0) { error_messages.Add("This part number exists."); } if (error_messages.Count == 0) { // No errors, add the part try { db.Parts.InsertOnSubmit(new_part); db.SubmitChanges(); ProductModels.SaveAttribute(0,new_part.partID, "UPC", upc); db.indexPart(new_part.partID); if (btnContinue != "") { // Redirect to add more part information return RedirectToAction("edit", new { partID = new_part.partID }); } else { // Redirect to product index page return RedirectToAction("index"); } } catch (Exception e) { error_messages.Add(e.Message); } } ViewBag.error_messages = error_messages; // Get all the parts in the database :: This will allow the user to create related parts ViewBag.parts = ProductModels.GetAllParts(); // Get the product classes ViewBag.classes = ProductModels.GetClasses(); return View(); }
public static void DeleteVideo(int videoID = 0) { CurtDevDataContext db = new CurtDevDataContext(); PartVideo v = db.PartVideos.Where(x => x.pVideoID.Equals(videoID)).First(); ProductModels.UpdatePart(v.partID); db.PartVideos.DeleteOnSubmit(v); db.SubmitChanges(); }
public void FinishImport() { CurtDevDataContext db = new CurtDevDataContext(); try { ImportProcess currentProcess = db.ImportProcesses.Where(x => x.endTime.Equals(null)).FirstOrDefault<ImportProcess>(); currentProcess.endTime = DateTime.Now; db.SubmitChanges(); } catch { }; }
public static Boolean Remove(int id = 0) { try { CurtDevDataContext db = new CurtDevDataContext(); Testimonial testimonial = db.Testimonials.Where(x => x.testimonialID == id).First<Testimonial>(); testimonial.active = false; db.SubmitChanges(); return true; } catch { return false; } }
public static void DeleteImage(int imageid = 0) { CurtDevDataContext db = new CurtDevDataContext(); PartImage i = db.PartImages.Where(x => x.imageID.Equals(imageid)).First(); List<string> ids = db.PartImages.Where(x => x.sizeID.Equals(i.sizeID)).Where(x => x.partID.Equals(i.partID)).Where(x => x.imageID != i.imageID).OrderBy(x => x.sort).Select(x => x.imageID.ToString()).ToList(); ProductModels.UpdatePart(i.partID); db.PartImages.DeleteOnSubmit(i); db.SubmitChanges(); UpdateSort(ids); }
public static void Delete(int id = 0) { try { CurtDevDataContext db = new CurtDevDataContext(); BlogPost p = db.BlogPosts.Where(x => x.blogPostID == id).FirstOrDefault<BlogPost>(); p.active = false; db.SubmitChanges(); } catch (Exception e) { throw e; } }
public static void Delete(int id = 0) { try { CurtDevDataContext db = new CurtDevDataContext(); NewsItem n = db.NewsItems.Where(x => x.newsItemID == id).FirstOrDefault<NewsItem>(); n.active = false; db.SubmitChanges(); } catch (Exception e) { throw e; } }
public ActionResult AddTask(string name = "", string runfrequency = "", string runday = "", string runtime = "", int interval = 0,string url = "") { try { if (url.Trim() == "") { throw new Exception("Task must have a path."); } if (runfrequency.Trim() == "") { throw new Exception("You must select a frequency for how often the task will run."); } ScheduledTask s = new ScheduledTask { name = name, url = url, runfrequency = runfrequency, }; switch (runfrequency) { case "interval": if (interval < 5) { throw new Exception("Interval tasks must have an interval greater than 5 minutes."); } s.interval = interval; break; case "daily": if (runtime.Trim() == "") { throw new Exception("You must specify a run time for daily tasks."); } s.runtime = Convert.ToDateTime(runtime); break; case "weekly": if (runtime.Trim() == "" || runday.Trim() == "") { throw new Exception("You must specify a run day and run time for weekly tasks."); } s.runtime = Convert.ToDateTime(runtime); DateTime weekdate = Convert.ToDateTime(runday); DayOfWeek weekday = weekdate.DayOfWeek; s.runday = Convert.ToInt32(weekday); break; case "monthly": if (runtime.Trim() == "" || runday.Trim() == "") { throw new Exception("You must specify a run day and run time for monthly tasks."); } s.runtime = Convert.ToDateTime(runtime); s.runday = Convert.ToDateTime(runday).Date.Day; break; } CurtDevDataContext db = new CurtDevDataContext(); db.ScheduledTasks.InsertOnSubmit(s); db.SubmitChanges(); } catch (Exception e) { return RedirectToAction("index", new { error = e.Message }); } return RedirectToAction("index"); }
public static void Delete(int id = 0) { try { CurtDevDataContext db = new CurtDevDataContext(); FAQ f = db.FAQs.Where(x => x.faqID == id).FirstOrDefault<FAQ>(); db.FAQs.DeleteOnSubmit(f); db.SubmitChanges(); } catch (Exception e) { throw e; } }
public string DeleteTask(int id = 0) { try { CurtDevDataContext db = new CurtDevDataContext(); ScheduledTask t = db.ScheduledTasks.Where(x => x.ID.Equals(id)).First<ScheduledTask>(); db.ScheduledTasks.DeleteOnSubmit(t); db.SubmitChanges(); return ""; } catch (Exception e) { return e.Message; } }
public static bool DeleteTopic(int id = 0) { CurtDevDataContext db = new CurtDevDataContext(); try { ForumTopic t = db.ForumTopics.Where(x => x.topicID == id).First<ForumTopic>(); t.active = false; db.SubmitChanges(); return true; } catch { return false; } }
public static bool Delete(int id = 0) { CurtDevDataContext db = new CurtDevDataContext(); try { FileExt extension = db.FileExts.Where(x => x.fileExtID == id).FirstOrDefault<FileExt>(); db.FileExts.DeleteOnSubmit(extension); db.SubmitChanges(); return true; } catch { return false; } }
public static bool DeleteGroup(int id = 0) { CurtDevDataContext db = new CurtDevDataContext(); try { ForumGroup g = db.ForumGroups.Where(x => x.forumGroupID == id).First<ForumGroup>(); db.ForumGroups.DeleteOnSubmit(g); db.SubmitChanges(); return true; } catch { return false; } }
public string DeleteNewsItem(int id) { CurtDevDataContext db = new CurtDevDataContext(); TechNews item = db.TechNews.Where(x => x.id == id).FirstOrDefault<TechNews>(); if (item != null) { db.TechNews.DeleteOnSubmit(item); db.SubmitChanges(); } else { return "Could not find news item."; } return ""; }
public static int DeleteRevision(int id = 0) { try { CurtDevDataContext db = new CurtDevDataContext(); SiteContentRevision revision = db.SiteContentRevisions.Where(x => x.revisionID == id).First<SiteContentRevision>(); int contentID = revision.contentID; if (!(bool)revision.active) { db.SiteContentRevisions.DeleteOnSubmit(revision); db.SubmitChanges(); } return contentID; } catch { return 0; } }
public static Menu_SiteContent AddContent(int menuid, int contentid, int websiteID) { CurtDevDataContext db = new CurtDevDataContext(); Menu_SiteContent menuitem = new Menu_SiteContent { menuID = menuid, contentID = contentid, menuSort = (db.Menu_SiteContents.Where(x => x.menuID == menuid).Where(x => x.parentID == null).Count()) + 1, linkTarget = false }; db.Menu_SiteContents.InsertOnSubmit(menuitem); db.SubmitChanges(); return menuitem; }