示例#1
0
        public async Task <int> AddUser(Domain.User.User user)
        {
            var userDAO = new DAO.User {
                Email            = user.Email,
                UserName         = user.UserName,
                Password         = user.Password,
                Gender           = user.Gender,
                BirthDate        = user.BirthDate,
                RegistrationDate = user.CreationDate,
                IsActiveUser     = user.IsActiveUser,
                IsBannedUser     = user.IsBannedUser,
            };
            await _context.AddAsync(userDAO);

            await _context.SaveChangesAsync();

            return(userDAO.UserId);
        }
示例#2
0
        public async Task AddPost_Returns_Correct_Response()
        {
            var post = new Domain.Post.Post(1, "Polska", "Mazury", 2500.00, "Bardzo fajna wycieczka na Mazurach!", "img/offerMazury.jpg");

            var postId = await _postRepository.AddPost(post);

            var createdPost = await _context.Post.FirstOrDefaultAsync(x => x.PostId == postId);

            Assert.NotNull(createdPost);

            _context.Post.Remove(createdPost);
            await _context.SaveChangesAsync();
        }
示例#3
0
        public async Task AddUser_Returns_Correct_Response()
        {
            var user = new Domain.User.User("Name", "Email", "mySecretPassword", Gender.Male, DateTime.UtcNow);

            var userId = await _userRepository.AddUser(user);

            var createdUser = await _context.User.FirstOrDefaultAsync(x => x.UserId == userId);

            Assert.NotNull(createdUser);

            _context.User.Remove(createdUser);
            await _context.SaveChangesAsync();
        }
示例#4
0
        public async Task <int> AddPost(Domain.Post.Post post)
        {
            var postDAO = new DAO.Post {
                UserId           = post.UserId,
                CreationDate     = post.CreationDate,
                OfferCountry     = post.OfferCountry,
                OfferCity        = post.OfferCity,
                OfferDescription = post.OfferDescription,
                OfferCost        = post.OfferCost,
                HotelName        = post.HotelName,
                DeparturePlace   = post.DeparturePlace,
                DateOfDeparture  = post.DateOfDeparture,
                DateOfReturn     = post.DateOfReturn,
                IsActivePost     = post.IsActivePost,
                IsBannedPost     = post.IsBannedPost,
                OfferPhotoHref   = post.OfferPhotoHref
            };
            await _context.AddAsync(postDAO);

            await _context.SaveChangesAsync();

            return(postDAO.PostId);
        }