Пример #1
0
        public User Update(IdentityContext ctx, User user)
        {
            var result = FindById(ctx, user.Id);

            ctx.Entry(result).CurrentValues.SetValues(user);
            ctx.SaveChanges();
            return(result);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <string> UpdateLocationAsync(IdentityContext ctx, User user)
        {
            var result = FindById(ctx, user.Id);

            ctx.Entry(result).CurrentValues.SetValues(user);
            await ctx.SaveChangesAsync();

            return(result.Id);
        }
Пример #3
0
 /// <summary>
 /// return the user the contains the id
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public User FindById(IdentityContext ctx, string id)
 {
     return(ctx.Users.FirstOrDefault(x => x.Id == id));
 }
Пример #4
0
 /// <summary>
 /// Gets all online users that are not the calling user.
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="username"></param>
 /// <returns></returns>
 public async Task <IEnumerable <User> > GetOnlineUsers(IdentityContext ctx, string username)
 {
     return(await ctx.Users
            .Where(x => x.UserName != username && x.Online)
            .ToListAsync());
 }
Пример #5
0
 /// <summary>
 /// Gets all users.
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public async Task <IEnumerable <User> > GetUsers(IdentityContext ctx)
 {
     return(await ctx.Users.ToListAsync());
 }
Пример #6
0
 /// <summary>
 /// returns the user that contails the email parameter
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="email"></param>
 /// <returns></returns>
 public User FindByEmail(IdentityContext ctx, string email)
 {
     return(ctx.Users.FirstOrDefault(x => x.Email == email));
 }