public static string GetBlogCategoryName(string slug) { using (SiteDataContext db = new SiteDataContext()) { return(db.BlogCategories.SingleOrDefault(p => p.Slug == slug).CategoryName); } }
public Blog GetFirstBlog(int categoryID) { using (SiteDataContext db = new SiteDataContext()) { return(db.Blogs.Where(m => m.CategoryID == categoryID && m.IsPublic == true).OrderByDescending(m => m.SortOrder).ThenByDescending(m => m.DateCreated).FirstOrDefault()); } }
public static string GetBlogCategoryName(int categoryID) { using (SiteDataContext db = new SiteDataContext()) { return(db.BlogCategories.SingleOrDefault(p => p.CategoryID == categoryID).CategoryName); } }
public override void OnActionExecuted(ActionExecutedContext filterContext) { if (!filterContext.HttpContext.User.Identity.IsAuthenticated) { return; } var userId = filterContext.HttpContext.User.Identity.GetUserId(); var context = new SiteDataContext(); var notifications = context.Notifications .Where(n => n.UserId == userId) .Where(n => !n.IsDismissed) .GroupBy(n => n.NotificationType) .Select(g => new NotificationViewModel { Count = g.Count(), NotificationType = g.Key.ToString(), BadgeClass = NotificationAlert.NotificationType.Email == g.Key ? "success" : "info" }); filterContext.Controller.ViewBag.Notifications = notifications; }
public string GetBlogCategoryName(int categoryID) { using (SiteDataContext db = new SiteDataContext()) { var category = db.BlogCategories.FirstOrDefault(p => p.CategoryID == categoryID); return(category != null ? category.CategoryName : ""); } }
public static string UserName() { using (SiteDataContext db = new SiteDataContext()) { var user = db.UserProfiles.Find(UserID); return(user.UserName); } }
private static void InitializeDatabaseContext() { SqlConnection connection = new SqlConnection(serviceManager.Get <IAppConfigService>().GetConnectionString("db")); SiteDataContext context = new SiteDataContext(connection); IDbContextService db = serviceManager.Get <IDbContextService>(); db.InitializeContext(context); db.CreateDatabaseAndTablesIfNotExists(); }
public static Wish GetWish(int id) { using (SiteDataContext db = new SiteDataContext()) { var wish = db.Wishes.Find(id); return(wish); } }
public static IEnumerable <Apply> GetApply() { using (SiteDataContext db = new SiteDataContext()) { var applies = from l in db.Applies.AsEnumerable() orderby l.Date descending select l; return(applies.ToList()); } }
public static int GetUserCount() { using (SiteDataContext db = new SiteDataContext()) { var count = (from l in db.Users select l).ToList(); return(count.Count); } }
public static int GetAllActiveCount() { using (SiteDataContext db = new SiteDataContext()) { var count = (from l in db.Activities where l.IsPublic == true select l).ToList(); return(count.Count); } }
public DataAccess(SiteDataContext _db = null) { if (db == null) { db = new SiteDataContext(); } else { db = _db; } }
public static string GetGalleryPhoto(int galleryID) { using (SiteDataContext db = new SiteDataContext()) { var photo = from g in db.GalleryDetails.AsEnumerable() where g.GalleryID == galleryID orderby g.SortOrder select g.PictureFile; return(photo.FirstOrDefault()); } }
public static List <string> GetTags1() { using (SiteDataContext db = new SiteDataContext()) { var tags = from p in db.TagJoins group p by new { p.Tag } into t orderby t.Count() descending select t.Key.Tag; return(tags.Take(8).ToList()); } }
public static IEnumerable <Blog> GetBlogs(int id) { using (SiteDataContext db = new SiteDataContext()) { var list = from l in db.Blogs.AsEnumerable() where l.CategoryID == id orderby l.DateCreated descending select l; return(list.ToList()); } }
/// <summary> /// 结束的活动 /// </summary> /// <returns></returns> public static int GetEndActiveCount() { using (SiteDataContext db = new SiteDataContext()) { var count = (from l in db.Activities where l.EndDate < DateTime.Now && l.IsPublic == true && l.UserID == UserID select l).ToList(); return(count.Count()); } }
/// <summary> /// 审核中的活动 /// </summary> /// <returns></returns> public static int GetDisActiveCount() { using (SiteDataContext db = new SiteDataContext()) { var count = (from l in db.Activities where l.IsPublic == false && l.UserID == UserID select l).ToList(); return(count.Count()); } }
public static IEnumerable <SelectListItem> GetCateGoriesList() { using (SiteDataContext db = new SiteDataContext()) { var list = from l in db.Categories.AsEnumerable() orderby l.SortOrder select new SelectListItem { Value = l.CategoryID.ToString(), Text = l.CategoryName }; return(list.ToList()); } }
public static IEnumerable <SelectListItem> GetRoleList() { using (SiteDataContext db = new SiteDataContext()) { var list = from l in db.UserRoles.AsEnumerable() orderby l.RoleID select new SelectListItem { Value = l.RoleID.ToString(), Text = l.RoleID }; return(list.ToList()); } }
//public static string GetBlogCategoryName(string slug) //{ // using (SiteDataContext db = new SiteDataContext()) // { // return db.BlogCategories.SingleOrDefault(p => p.Slug == slug).CategoryName; // } //} /// <summary> /// 搜索学生 /// </summary> /// <param name="name">学生姓名</param> /// <param name="studentID">准考证号</param> /// <returns></returns> public Student SearchStudent(string name, string studentID) { using (SiteDataContext db = new SiteDataContext()) { var item = (from l in db.Students where l.Name == name && l.StudentID == studentID select l).FirstOrDefault(); if (item != null) { var courseID = Convert.ToInt32(item.Course); var course = db.Blogs.FirstOrDefault(m => m.BlogID == courseID); item.CourseName = course == null ? "" : course.BlogTitle; } return(item); } }
protected static object Cleaner(string userId, int productId, SiteDataContext db) { var inactiveItems = db.booster .Where( p => p.userId == userId && p.finished == false && (p.storeProductId == productId || p.endTime < DateTime.UtcNow)) .Select(p => p); foreach (var item in inactiveItems) { UserChest.SetFinalize(item.user_chestId); item.finished = true; } return(new { Cleaner = "Cleaner true" }); }
public static List <string> GetTags() { using (SiteDataContext db = new SiteDataContext()) { var tags = (from p in db.Tags where p.IsPublic == "Y" select p.Tag).ToList(); if (tags.Count() < 8) { var count = 8 - tags.Count(); var tags1 = GetTags1().Where(m => !tags.Contains(m)).Take(count); tags.AddRange(tags1); } return(tags.ToList()); } }
public string GetCourseName(string courseID) { using (SiteDataContext db = new SiteDataContext()) { if (string.IsNullOrEmpty(courseID) || courseID == "0") { return(""); } var id = ToInt(courseID); var course = db.Blogs.FirstOrDefault(m => m.BlogID == id); if (course == null) { return(""); } return(course.BlogTitle); } }
public ContentRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public SettingRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public void Dispose() { db.Database.Connection.Close(); db.Dispose(); db = null; }
public DocumentRepository(SiteDataContext dataContext, DocumentPersister documentPersister) { _dataContext = dataContext; _documentPersister = documentPersister; }
public WishLogic(SiteDataContext db) : base(db) { }
public ContentRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public TeamRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public ExpertiseRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public TechnologyRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public SponsorRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public CharityRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public JobRoleRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public MenuLogic(SiteDataContext db) : base(db) { }
public VolunteerRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public DocumentRepository(SiteDataContext dataContext, DocumentPersister documentPersister) { _dataContext = dataContext; _documentPersister = documentPersister; }
public TechnologyRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public NonTechVolunteerRepository(SiteDataContext dataContext) { _dataContext = dataContext; }
public ExperienceLevelRepository(SiteDataContext dataContext) { _dataContext = dataContext; }