Beispiel #1
0
        public async Task <UserCardResponseModel> EditUserInfo(UserCardResponseModel userCardResponseModel)
        {
            var user = await _userRepository.GetByIdAsync(userCardResponseModel.Id);

            if (user == null)
            {
                return(null);
            }

            user.Email    = userCardResponseModel.Email;
            user.Password = userCardResponseModel.Password;
            user.Fullname = userCardResponseModel.Fullname;
            user.Mobileno = userCardResponseModel.Mobileno;

            await _userRepository.UpdateAsync(user);

            return(userCardResponseModel);
        }
Beispiel #2
0
        public async Task <UserCardResponseModel> GetUserById(int id)
        {
            var user = await _userRepository.GetByIdAsync(id);

            if (user == null)
            {
                return(null);
            }

            var response = new UserCardResponseModel()
            {
                Id       = user.Id,
                Email    = user.Email,
                Password = user.Password,
                Fullname = user.Fullname,
                Mobileno = user.Mobileno
            };

            return(response);
        }
Beispiel #3
0
        public async Task <ICollection <UserCardResponseModel> > GetAllUsers()
        {
            var users = await _userRepository.ListAllAsync();

            var userCollection = new List <UserCardResponseModel>();

            foreach (var user in users)
            {
                var userCard = new UserCardResponseModel()
                {
                    Id       = user.Id,
                    Email    = user.Email,
                    Password = user.Password,
                    Fullname = user.Fullname,
                    Mobileno = user.Mobileno
                };

                userCollection.Add(userCard);
            }

            return(userCollection);
        }
Beispiel #4
0
        public async Task <UserCardResponseModel> RegisterUser(CreateUserRequestModel createUserRequestModel)
        {
            var user = new User
            {
                Email    = createUserRequestModel.Email,
                Password = createUserRequestModel.Password,
                Fullname = createUserRequestModel.Fullname,
                Mobileno = createUserRequestModel.Mobileno
            };

            var createdUser = await _userRepository.AddAsync(user);

            var response = new UserCardResponseModel
            {
                Id       = createdUser.Id,
                Email    = createdUser.Email,
                Password = createdUser.Password,
                Fullname = createdUser.Fullname,
                Mobileno = createdUser.Mobileno
            };

            return(response);
        }