本文整理汇总了C#中CurtDevDataContext类的典型用法代码示例。如果您正苦于以下问题:C# CurtDevDataContext类的具体用法?C# CurtDevDataContext怎么用?C# CurtDevDataContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CurtDevDataContext类属于命名空间,在下文中一共展示了CurtDevDataContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddImage
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";
}
}
示例2: GetCategories
/// <summary>
/// Retrieves a list of DetailedCategories objects
/// </summary>
/// <returns>List of DetailedCategories objects</returns>
public static List<DetailedCategories> GetCategories()
{
List<DetailedCategories> cats = new List<DetailedCategories>();
CurtDevDataContext db = new CurtDevDataContext();
cats = (from c in db.Categories
select new DetailedCategories {
catID = c.catID,
dateAdded = c.dateAdded,
parentID = c.parentID,
parentCat = (from c2 in db.Categories where c2.catID.Equals(c.parentID) select c2.catTitle).FirstOrDefault<string>(),
catTitle = c.catTitle,
shortDesc = c.shortDesc,
longDesc = c.longDesc,
image = c.image,
isLifestyle = c.isLifestyle,
vehicleSpecific = c.vehicleSpecific,
partCount = (from p in db.Parts join cp in db.CatParts on p.partID equals cp.partID where cp.catID.Equals(c.catID) select p).Distinct().Count(),
content = (from cb in db.ContentBridges
join co in db.Contents on cb.contentID equals co.contentID
join ct in db.ContentTypes on co.cTypeID equals ct.cTypeID
where cb.catID.Equals(c.catID)
orderby co.cTypeID
select new FullContent {
content_type_id = co.cTypeID,
content_type = ct.type,
contentID = co.contentID,
content = co.text
}).ToList<FullContent>()
}).Distinct().OrderBy(x => x.catTitle).ToList<DetailedCategories>();
return cats;
}
示例3: AddNews
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();
}
示例4: generateCustomAPIKey
public static void generateCustomAPIKey(Guid userID, List<string> selectedModuleIDs)
{
CurtDevDataContext db = new CurtDevDataContext();
// create API Key with custom type
ApiKey customKey = new ApiKey();
customKey.id = Guid.NewGuid();
customKey.api_key = Guid.NewGuid();
customKey.type_id = db.ApiKeyTypes.Where(x => x.type == "Custom").Select(x => x.id).FirstOrDefault<Guid>();
customKey.user_id = userID;
customKey.date_added = DateTime.Now;
db.ApiKeys.InsertOnSubmit(customKey);
db.SubmitChanges();
// create record for each selected module ID in the APIAcess table
List<ApiAccess> listOfNewAPIAccesses = new List<ApiAccess>();
foreach (string modID in selectedModuleIDs) {
ApiAccess apiAccess = new ApiAccess();
apiAccess.id = Guid.NewGuid();
apiAccess.key_id = customKey.id;
apiAccess.module_id = new Guid(modID);
listOfNewAPIAccesses.Add(apiAccess);
}
db.ApiAccesses.InsertAllOnSubmit(listOfNewAPIAccesses);
db.SubmitChanges();
// submit changes
}
示例5: Get
public static PostWithCategories Get(string date = "", string title = "")
{
try {
DateTime post_date = Convert.ToDateTime(date);
CurtDevDataContext db = new CurtDevDataContext();
PostWithCategories post = new PostWithCategories();
post = (from p in db.BlogPosts
where p.slug.Equals(title) && Convert.ToDateTime(p.publishedDate).Day.Equals(post_date.Day)
&& Convert.ToDateTime(p.publishedDate).Year.Equals(post_date.Year) && Convert.ToDateTime(p.publishedDate).Month.Equals(post_date.Month)
select new PostWithCategories {
blogPostID = p.blogPostID,
post_title = p.post_title,
post_text = p.post_text,
slug = p.slug,
publishedDate = p.publishedDate,
createdDate = p.createdDate,
lastModified = p.lastModified,
meta_title = p.meta_title,
meta_description = p.meta_description,
active = p.active,
author = GetAuthor(p.userID),
categories = (from c in db.BlogCategories join pc in db.BlogPost_BlogCategories on c.blogCategoryID equals pc.blogCategoryID where pc.blogPostID.Equals(p.blogPostID) select c).ToList<BlogCategory>(),
comments = (from cm in db.Comments where cm.blogPostID.Equals(p.blogPostID) && cm.active.Equals(true) && cm.approved.Equals(true) select cm).ToList<Comment>()
}).First<PostWithCategories>();
return post;
} catch (Exception e) {
return new PostWithCategories();
}
}
示例6: FindVehicles
public static List<FullVehicle> FindVehicles(string term = "")
{
List<FullVehicle> vehicles = new List<FullVehicle>();
CurtDevDataContext db = new CurtDevDataContext();
double query_year = 0;
Double.TryParse(term, out query_year);
vehicles = (from v in db.Vehicles
join y in db.Years on v.yearID equals y.yearID
join ma in db.Makes on v.makeID equals ma.makeID
join mo in db.Models on v.modelID equals mo.modelID
join s in db.Styles on v.styleID equals s.styleID
where s.style1.Contains(term) || mo.model1.Contains(term) || ma.make1.Contains(term) || y.year1.Equals(query_year)
orderby v.vehicleID
select new FullVehicle {
vehicleID = v.vehicleID,
yearID = v.yearID,
makeID = v.makeID,
modelID = v.modelID,
styleID = v.styleID,
aaiaID = s.aaiaID,
year = y.year1,
make = ma.make1,
model = mo.model1,
style = s.style1
}).ToList<FullVehicle>();
return vehicles;
}
示例7: Get
public ContentPage Get(string name = "", int menuid = 0, bool authenticated = false)
{
ContentPage content = new ContentPage();
try {
CurtDevDataContext db = new CurtDevDataContext();
content = (from s in db.SiteContents
where s.slug == name && s.published == true && s.active == true && s.websiteID.Equals(this.websiteID)
select new ContentPage {
contentID = s.contentID,
page_title = s.page_title,
content_type = s.content_type,
lastModified = s.lastModified,
createdDate = s.createdDate,
published = s.published,
meta_title = s.meta_title,
meta_description = s.meta_description,
keywords = s.keywords,
canonical = s.canonical,
active = s.active,
isPrimary = s.isPrimary,
slug = s.slug,
requireAuthentication = s.requireAuthentication,
revision = (db.SiteContentRevisions.Where(x => x.contentID == s.contentID).Where(x => x.active == true).First<SiteContentRevision>()),
menu = new MenuModel().GetByContentID(s.contentID, menuid, authenticated)
}).First<ContentPage>();
return content;
} catch (Exception e) { return content; }
}
示例8: GetDealerLocation
public static DealerLocation GetDealerLocation(int locationID = 0)
{
CurtDevDataContext db = new CurtDevDataContext();
DealerLocation location = new DealerLocation();
try {
location = (from cl in db.CustomerLocations
join c in db.Customers on cl.cust_id equals c.cust_id
join dt in db.DealerTypes on c.dealer_type equals dt.dealer_type
join dtr in db.DealerTiers on c.tier equals dtr.ID
where cl.locationID.Equals(locationID)
select new DealerLocation {
State = cl.State,
customername = c.name,
dealerType = dt,
dealerTier = dtr,
locationID = cl.locationID,
name = cl.name,
address = cl.address,
city = cl.city,
stateID = cl.stateID,
postalCode = cl.postalCode,
email = cl.email,
phone = cl.phone,
fax = cl.fax,
latitude = cl.latitude,
longitude = cl.longitude,
cust_id = cl.cust_id,
isprimary = cl.isprimary,
contact_person = cl.contact_person,
websiteurl = (c.eLocalURL == null || c.eLocalURL.Trim() == "") ? ((c.website == null || c.website.Trim() == "") ? "" : c.website) : c.eLocalURL,
showWebsite = c.showWebsite
}).FirstOrDefault<DealerLocation>();
} catch { };
return location;
}
示例9: Get
public static CommentWithPost Get(int id = 0)
{
try
{
CurtDevDataContext db = new CurtDevDataContext();
CommentWithPost comment = new CommentWithPost();
comment = (from c in db.Comments
where c.commentID.Equals(id)
select new CommentWithPost
{
commentID = c.commentID,
blogPostID = c.blogPostID,
name = c.name,
email = c.email,
comment_text = c.comment_text,
createdDate = c.createdDate,
approved = c.approved,
active = c.active,
post = (from p in db.BlogPosts where p.blogPostID.Equals(c.blogPostID) select p).First<BlogPost>()
}).First<CommentWithPost>();
return comment;
}
catch (Exception e)
{
return new CommentWithPost();
}
}
示例10: Get
public static FullFile Get(int id = 0)
{
FullFile file = new FullFile();
try {
CurtDevDataContext db = new CurtDevDataContext();
file = (from f in db.Files
where f.fileID.Equals(id)
orderby f.createdDate descending
select new FullFile {
fileID = f.fileID,
name = f.name,
path = f.path,
height = f.height,
width = f.width,
size = f.size,
createdDate = f.createdDate,
created = String.Format("{0:ddd, dd MMM yyyy HH:mm:ss}", f.createdDate),
fileGalleryID = f.fileGalleryID,
fileExtID = f.fileExtID,
extension = (from fe in db.FileExts
where fe.fileExtID.Equals(f.fileExtID)
select new FileExtension {
fileExtID = fe.fileExtID,
fileExt1 = fe.fileExt1,
fileExtIcon = fe.fileExtIcon,
fileTypeID = fe.fileTypeID,
FileType = db.FileTypes.Where(x => x.fileTypeID.Equals(fe.fileTypeID)).FirstOrDefault<FileType>()
}).First<FileExtension>()
}).FirstOrDefault<FullFile>();
} catch (Exception e) { }
return file;
}
示例11: GetAll
public static List<FullFile> GetAll()
{
List<FullFile> images = new List<FullFile>();
try {
CurtDevDataContext db = new CurtDevDataContext();
images = (from f in db.Files
orderby f.name, f.createdDate descending
select new FullFile {
fileID = f.fileID,
name = f.name,
path = f.path,
height = f.height,
width = f.width,
size = f.size,
createdDate = f.createdDate,
fileGalleryID = f.fileGalleryID,
fileExtID = f.fileExtID,
extension = (from fe in db.FileExts
where fe.fileExtID.Equals(f.fileExtID)
select new FileExtension {
fileExtID = fe.fileExtID,
fileExt1 = fe.fileExt1,
fileExtIcon = fe.fileExtIcon,
fileTypeID = fe.fileTypeID,
FileType = db.FileTypes.Where(x => x.fileTypeID.Equals(fe.fileTypeID)).FirstOrDefault<FileType>()
}).First<FileExtension>()
}).ToList<FullFile>();
} catch (Exception e) { }
return images;
}
示例12: Create
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;
}
示例13: GetMonths
public static List<Archive> GetMonths()
{
try {
CurtDevDataContext db = new CurtDevDataContext();
List<Archive> archives = new List<Archive>();
archives = (from p in db.BlogPosts
where p.publishedDate.Value != null && p.publishedDate.Value <= DateTime.Now && p.active.Equals(true)
orderby p.publishedDate.Value.Year descending, p.publishedDate.Value.Month descending
select new Archive
{
monthnum = Convert.ToInt16(Convert.ToDateTime(p.publishedDate).Month.ToString()),
month = Convert.ToDateTime(p.publishedDate).Month.ToString(),
year = Convert.ToDateTime(p.publishedDate).Year.ToString()
}).Distinct().ToList<Archive>();
archives = (from a in archives
orderby a.year descending, a.monthnum
select a).Distinct().ToList<Archive>();
return archives;
} catch {
return new List<Archive>();
}
}
示例14: Save
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 });
}
}
}
示例15: DeleteCustomer
public static string DeleteCustomer(int id)
{
try {
CurtDevDataContext db = new CurtDevDataContext();
// Delete any pricing entries for this customer
List<CustomerPricing> prices = new List<CustomerPricing>();
prices = (from cp in db.CustomerPricings
where cp.cust_id.Equals(id)
select cp).ToList<CustomerPricing>();
db.CustomerPricings.DeleteAllOnSubmit<CustomerPricing>(prices);
// Delete all locations for this customer
List<CustomerLocation> locations = new List<CustomerLocation>();
locations = (from cl in db.CustomerLocations
where cl.cust_id.Equals(id)
select cl).ToList<CustomerLocation>();
db.CustomerLocations.DeleteAllOnSubmit<CustomerLocation>(locations);
// Delete the customer record
Customer cust = new Customer();
cust = (from c in db.Customers
where c.cust_id.Equals(id)
select c).FirstOrDefault<Customer>();
db.Customers.DeleteOnSubmit(cust);
db.SubmitChanges();
return "";
} catch (Exception e) {
return "Error while deleting.";
}
}