示例#1
0
 public static AspNetUser GetUser(this object e, string userId)
 {
     using (var db = new EventsDbEntities())
     {
         return db.AspNetUsers.FirstOrDefault(user => user.Id == userId);
     }
 }
示例#2
0
 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();
     }
 }
示例#3
0
 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;
     }
 }
示例#4
0
 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;
     }
 }
示例#5
0
 private static AspNetUser GetUser(string userId)
 {
     using (var db = new EventsDbEntities())
     {
         return db.AspNetUsers.FirstOrDefault(user => user.Id == userId);
     }
 }