本文整理汇总了C#中EcommercePlatformDataContext类的典型用法代码示例。如果您正苦于以下问题:C# EcommercePlatformDataContext类的具体用法?C# EcommercePlatformDataContext怎么用?C# EcommercePlatformDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EcommercePlatformDataContext类属于命名空间,在下文中一共展示了EcommercePlatformDataContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGeoLocation
public static GeocodingResponse GetGeoLocation(string city, int stateID, string zip, string countryCode = "US", string StateProvidence = "") {
try {
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
string abbr = "";
if (stateID != 0) {
State state = db.States.Where(x => x.stateID.Equals(stateID)).FirstOrDefault();
abbr = state.abbr;
countryCode = state.Country.abbr;
} else {
abbr = StateProvidence;
}
string url = "https://maps.googleapis.com/maps/api/geocode/json?address=";
url += HttpUtility.UrlEncode(city + ", " + abbr + " " + zip + " " + countryCode);
url += "&sensor=false";
WebClient wc = new WebClient();
wc.Proxy = null;
string resp = wc.DownloadString(url);
GeocodingResponse geo = new JavaScriptSerializer().Deserialize<GeocodingResponse>(resp);
return geo;
} catch (Exception) {
return new GeocodingResponse();
}
}
示例2: GetAll
public static List<PrettyLocation> GetAll() {
List<PrettyLocation> locs = new List<PrettyLocation>();
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
locs = (from l in db.Locations
join s in db.States on l.stateID equals s.stateID
select new PrettyLocation {
locationID = l.locationID,
name = l.name,
phone = l.phone,
fax = l.fax,
email = l.email,
address = l.address,
city = l.city,
stateID = l.stateID,
zip = l.zip,
isPrimary = l.isPrimary,
latitude = l.latitude,
longitude = l.longitude,
places_id = l.places_id,
places_reference = l.places_reference,
places_status = l.places_status,
foursquare_id = l.foursquare_id,
abbr = s.abbr,
state = s.state1,
Services = (from serv in db.Services
join ls in db.LocationServices on serv.ID equals ls.serviceID
where ls.locationID.Equals(l.locationID)
select serv).ToList<Service>()
}).OrderBy(x => x.locationID).ToList<PrettyLocation>();
return locs;
}
示例3: Get
public static CommentWithPost Get(int id = 0)
{
try
{
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
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 {
return new CommentWithPost();
}
}
示例4: GetAll
public static List<CommentWithPost> GetAll()
{
try
{
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
List<CommentWithPost> comments = new List<CommentWithPost>();
comments = (from c in db.Comments
where c.active.Equals(true)
orderby c.approved, c.createdDate
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>()
}).ToList<CommentWithPost>();
return comments;
}
catch {
return new List<CommentWithPost>();
}
}
示例5: allowConnection
public static bool allowConnection(string ipaddress) {
bool hasPermission = false;
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
hasPermission = db.FTPFirewalls.Where(x => x.ipaddress.Equals(ipaddress.Trim())).Count() > 0;
return hasPermission;
}
示例6: AddTask
public ActionResult AddTask(string name = "", string runtime = "", int interval = 0,string url = "")
{
try {
if (url.Trim() == "") {
throw new Exception("Task must have a path.");
}
if (runtime.Trim() == "" && interval < 1) {
throw new Exception("Task must have a run time or an interval greater than 5 minutes.");
}
ScheduledTask s = new ScheduledTask {
name = name,
url = url
};
if (runtime.Trim() != "") {
DateTime rtime = Convert.ToDateTime(runtime).ToUniversalTime();
s.runtime = rtime;
} else if(interval > 1) {
s.interval = interval;
}
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
db.ScheduledTasks.InsertOnSubmit(s);
db.SubmitChanges();
} catch {}
return RedirectToAction("index");
}
示例7: GetAll
public static List<PostWithCategories> GetAll()
{
try {
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
List<PostWithCategories> posts = new List<PostWithCategories>();
posts = (from p in db.BlogPosts
where p.active.Equals(true)
orderby p.publishedDate, p.createdDate
select new PostWithCategories {
blogPostID = p.blogPostID,
post_title = p.post_title,
slug = p.slug,
profileID = p.profileID,
post_text = p.post_text,
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.profileID),
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.approved.Equals(true) && cm.active.Equals(true) select cm).ToList<Comment>(),
mod_comments = (from cm in db.Comments where cm.blogPostID.Equals(p.blogPostID) && cm.approved.Equals(false) && cm.active.Equals(true) select cm).ToList<Comment>()
}).ToList<PostWithCategories>();
return posts;
} catch (Exception e) {
return new List<PostWithCategories>();
}
}
示例8: Get
public static PostWithCategories Get(string date = "", string title = "")
{
try {
DateTime post_date = Convert.ToDateTime(date);
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
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.profileID),
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();
}
}
示例9: GetAllPublished
public static List<PostWithCategories> GetAllPublished(int page = 1, int pageSize = 5)
{
try
{
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
List<PostWithCategories> posts = new List<PostWithCategories>();
posts = (from p in db.BlogPosts
where p.publishedDate.Value <= DateTime.UtcNow && p.active.Equals(true)
orderby p.publishedDate descending
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,
keywords = p.keywords,
meta_title = p.meta_title,
meta_description = p.meta_description,
active = p.active,
author = GetAuthor(p.profileID),
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>()
}).Skip((page - 1) * pageSize).Take(pageSize).ToList();
return posts;
}
catch {
return new List<PostWithCategories>();
}
}
示例10: GetMonths
public static List<Archive> GetMonths()
{
try {
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
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>();
}
}
示例11: Populate
internal Dictionary<string, string> Populate()
{
Dictionary<string, string> settings = new Dictionary<string, string>();
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
settings = db.Settings.Select(p => new { p.name, p.value }).AsEnumerable().ToDictionary(kvp => kvp.name, kvp => kvp.value);
return settings;
}
示例12: GetAll
internal static List<Newsletter> GetAll() {
try {
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
return db.Newsletters.ToList<Newsletter>();
} catch (Exception) {
return new List<Newsletter>();
}
}
示例13: CountAll
public static int CountAll() {
try {
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
return db.Testimonials.Where(x => x.active == true).Where(x => x.approved == true).Count();
} catch {
return 0;
}
}
示例14: Index
public ActionResult Index()
{
List<FTPFirewall> ipaddresses = new List<FTPFirewall>();
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
ipaddresses = db.FTPFirewalls.ToList<FTPFirewall>();
ViewBag.ipaddresses = ipaddresses;
return View();
}
示例15: GetAll
public static List<Testimonial> GetAll(int page = 1, int pageSize = 10) {
try {
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
return db.Testimonials.Where(x => x.active == true).Where(x => x.approved == true).OrderByDescending(x => x.dateAdded).Skip((page - 1) * pageSize).Take(pageSize).ToList<Testimonial>();
} catch {
return new List<Testimonial>();
}
}