public bool Update(User user)
        {
            using (var connection = OpenConnection())
            {
                const string sql = "UPDATE [Users] SET Email = @Email, Password = @Password, Name = @Name, Surname = @Surname, PhotoUrl = @PhotoUrl, ThumbnailUrl = @ThumbnailUrl WHERE Id = @Id";

                return connection.Execute(sql, new { user.Id, user.Email, user.Name, user.Password, user.PhotoUrl, user.Surname, user.ThumbnailUrl }) == 1;
            }
        }
        public long Save(User user)
        {
            using (IDbConnection connection = OpenConnection())
            {
                // TODO: check if user already exist

                const string query =
                    "INSERT INTO [Users] (Email, Name, Password, PhotoUrl, Surname, ThumbnailUrl)" +
                    "VALUES (@Email, @Name, @Password, @PhotoUrl, @Surname, @ThumbnailUrl);" +
                    "SELECT cast(scope_identity() as int)";

                return connection.Query<int>(query, new
                {
                    user.Email,
                    user.Name,
                    user.Password,
                    user.PhotoUrl,
                    user.Surname,
                    user.ThumbnailUrl
                }).First();
            }
        }
Exemplo n.º 3
0
 public void Save(User user)
 {
     _userRepository.Save(user);
 }
Exemplo n.º 4
0
 public bool Update(User member)
 {
     return _userRepository.Update(member);
 }
        public void UpdateUser_ReturnTrueWhenUserExists()
        {
            var user = new User
                {
                    Email = Email,
                    Name = "Name",
                    Password = "******",
                    PhotoUrl = "ThumbnailUrl",
                    Surname = "Surname"
                };
            user.Id = _userRepository.Save(user);

            bool result = _userRepository.Update(user);

            Assert.AreEqual(true, result);
        }