public PagedList <CommentPas> GetReply(long uid, int p, int ep) { using (IDbEntities db = DbInstance) { return(GetReplyPrivate(db, uid).Pager(p, ep)); } }
/// <summary> /// Comments the list. /// </summary> /// <param name="showerId"></param> /// <param name="type">The type.</param> /// <param name="p"></param> /// <param name="site"></param> /// <returns></returns> public PagedList <CommentPas> CommentList(long showerId, CommentType type, int p , SiteConfig site) { using (IDbEntities db = DbInstance) { var t = (int)type; IQueryable <CommentPas> ret = (from c in db.Comment join p1 in db.Profile on c.SenderId equals p1.UserId where c.ShowerId == showerId && c.Type == t && !c.IsDel orderby c.Id select new CommentPas { Comment = new CommentItemPas { ID = c.Id, OwnerID = c.OwnerId, Body = c.Body, AddTime = c.AddTime, IsDel = c.IsDel }, Sender = new NameIdPas { Id = p1.UserId, Name = p1.Name } } ); return(ret.Pager(p, site.EveryPage.NoteComment)); //Site.EveryPage.NoteComment } }
internal bool Create(Account account, string name, int initScore) { account.Password = account.Password.ToMd5(); account.Code = DateTime.Now.Ticks; using (IDbEntities db = DbInstance) { db.Account.Add(account); db.SaveChanges(); if (account.UserId < 999) { return(false); } db.Profile.Add(new Profile { UserId = account.UserId, Name = name, ShowScore = initScore, Score = initScore, DelScore = 0, Status = (int)RoleType.General, RegTime = DateTime.Now, LoginTime = DateTime.Now, // MagicBox = "" }); db.BasicInformation.Add( new BasicInformation { UserId = account.UserId, Name = name }); db.SaveChanges(); return(true); } }
public MainWindowImpl(int idEvent) { this._idEvent = idEvent; this._dbEntities = new DbEntities(); this._dbEntities.SetIdEvent(idEvent); EventSet thisEvent = this._dbEntities.GetEventById(idEvent); this.EventTitle = thisEvent.Name + " - " + thisEvent.DateOfEvent.ToString(); }
public void DeleteReply(long id, long userid) { using (IDbEntities db = DbInstance) { Reply obj = db.Reply.FirstOrDefault(c => c.Id == id && c.UserId == userid); db.Reply.Remove(obj); db.SaveChanges(); } }
public bool IsUsernameCanUse(string username) { bool isNotExists; using (IDbEntities db = DbInstance) { isNotExists = db.Account.Where(c => c.UserName == username.Trim()).Count() == 0; } return(username.Trim().Length > 0 && isNotExists); }
public Reply AddReply(Reply r) { r.AddTime = DateTime.Now; using (IDbEntities db = DbInstance) { db.Reply.Add(r); db.SaveChanges(); } return(r); }
public StatVM(int idEvent) { this._dbEntities = new DbEntities(); this._dbEntities.SetIdEvent(idEvent); this._idEvent = idEvent; this._nbrUser = -1; this._nbrUserOnline = -1; this._nbrUserOnsite = -1; this._nbrUniqueAttendance = -1; this._allProfiles = this._dbEntities.GetAllUsers() .Where(e => differentProfiles.Contains(e.EventFieldSet.FieldSet.Name.ToLower())) .Select(f => f.Value).Distinct().ToArray(); this._nbrUserPerProfile = new Dictionary <string, double>(); this._printedBadgePerProfile = new Dictionary <string, double>(); }
public void Add(Comment cmt, CommentType type) { cmt.AddTime = DateTime.Now; using (IDbEntities db = DbInstance) { db.Comment.Add(cmt); switch (type) { case CommentType.Note: Note n = db.Note.FirstOrDefault(c => c.Id == cmt.ShowerId); n.CommentCount++; break; default: break; } db.SaveChanges(); } }
public void InitCreater() { using (IDbEntities db = DbInstance) { Profile p = db.Profile.FirstOrDefault(); if (p == null) { return; } var userrole = new UserRole { RoleId = 1, UserId = p.UserId }; db.UserRole.Add(userrole); db.SaveChanges(); } }
internal WebIdentity GeneralIdentity(String userName, String password, int logOnScore) { using (IDbEntities db = DbInstance) { long userId; long.TryParse(userName.Trim(), out userId); long userid = (from a in db.Account where (a.UserName == userName || a.UserId == userId) && a.Password == password select a.UserId).FirstOrDefault(); if (userid <= 1000) { return(null); } Profile profile = db.Profile.FirstOrDefault(p => p.UserId == userid); List <string> roles = (from ur in db.UserRole join ro in db.Roles on ur.RoleId equals ro.Id where ur.UserId == profile.UserId select ro.RoleName).ToList(); //var retint = profile.Status; // if (retint <= 0) return null; if (profile.LoginTime.Date != DateTime.Now.Date) { profile.Score += logOnScore; profile.ShowScore += logOnScore; profile.LoginTime = DateTime.Now; db.SaveChanges(); } return(new WebIdentity { Name = profile.Name, UserId = profile.UserId, // Email= profile. Roles = roles, Status = profile.Status // AuthenticationType = AccountType.Default.ToString() //Status = retint, //Applications = profile.Applications }); } }
/// <summary> /// 删除回复 /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <returns></returns> public bool Delete(long id, CommentType type) { using (IDbEntities db = DbInstance) { Comment com = db.Comment.FirstOrDefault(c => c.Id == id); if (null == com) { return(false); } com.IsDel = true; if (type == CommentType.Note) { Note n = db.Note.FirstOrDefault(c => c.Id == com.ShowerId && c.CommentCount > 0); if (null != n) { n.CommentCount--; } } db.SaveChanges(); return(true); } }
private static IQueryable <CommentPas> GetReplyPrivate(IDbEntities sqlServer, long uid) { IQueryable <CommentPas> ret = (from r in sqlServer.Reply join p in sqlServer.Profile on r.SenderId equals p.UserId where r.UserId == uid orderby r.Id descending select new CommentPas { Comment = new CommentItemPas { ID = r.Id, OwnerID = r.UserId, Body = r.Body, AddTime = r.AddTime, IsDel = r.IsDel }, Sender = new NameIdPas { Id = p.UserId, Name = p.Name } } ); return(ret); }
public ExportVM(int idEvent) { this._dbEntities = new DbEntities(); this._dbEntities.SetIdEvent(idEvent); this._idEvent = idEvent; }
public UserVM(int idEvent) { this._dbEntities = new DbEntities(); this._idEvent = idEvent; this._dbEntities.SetIdEvent(this._idEvent); }
public EventVM() { this._dbEntities = new DbEntities(); }
public FilterVM(int eventId) { this.eventId = eventId; this.dbEntities = new DbEntities(); this.dbEntities.SetIdEvent(eventId); }
public FieldVM() { this._dbEntities = new DbEntities(); }
public RuleVM(int filterId) { this.filterId = filterId; this.dbEntities = new DbEntities(); }
/// <summary> /// Instantiation /// </summary> /// <param name="dbEntities"></param> public CompaniesController(IDbEntities dbEntities) { _dbEntities = dbEntities; }