Exemplo n.º 1
0
        public async Task <bool> UserLoggedIn(string email, UserResultListResource user)
        {
            try
            {
                if (_userRepository.Query().Any(x => x.UserEmail == email))
                {
                    var userToUpdate = await _userRepository.FindAsync(x => x.UserEmail == email);

                    userToUpdate.LastLogin = DateTime.Now;
                    await _userRepository.UpdateAsync(userToUpdate);
                }
                else
                {
                    var userToAdd = new User
                    {
                        FullName      = user.FullName,
                        Avatar        = user.Avatar,
                        LastLogin     = DateTime.Now,
                        UserEmail     = user.Email,
                        UserIdentifer = user.UserIdentifier
                    };

                    await _userRepository.UpdateAsync(userToAdd);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UserLoggedIn(string email, [FromBody] UserResultListResource user)
        {
            if (!await _userService.UserLoggedIn(email, user))
            {
                return(BadRequest("Đã xảy ra lỗi."));
            }

            return(Ok("Bạn đã cập nhật người dùng thành công."));
        }