public static AspNetUser GetUser(this object e, string userId) { using (var db = new EventsDbEntities()) { return db.AspNetUsers.FirstOrDefault(user => user.Id == userId); } }
public static IEnumerable<Message> GetMessages(this AspNetUser e) { using (var db = new EventsDbEntities()) { var result = db.Messages.Where(x => x.ToUser == e.Id); return result.ToList(); } }
public static bool HasSentRequest(this AspNetUser e, AspNetUser user) { var result = false; using (var db = new EventsDbEntities()) { foreach (var item in db.FollowUsers) { if (item.FromUser == e.Id && item.ToUser == user.Id) result = true; } return result; } }
public static IEnumerable<AspNetUser> FollowRequests(this AspNetUser e) { var result = new List<AspNetUser>(); using (var db = new EventsDbEntities()) { foreach (var item in db.FollowUsers) { if(item.Status == FollowRequestStatus.Pending.ToString() && item.ToUser == e.Id) result.Add(GetUser(item.FromUser)); } return result; } }
private static AspNetUser GetUser(string userId) { using (var db = new EventsDbEntities()) { return db.AspNetUsers.FirstOrDefault(user => user.Id == userId); } }