Пример #1
0
        static void testRepo()
        {
            CommunicationDbContext ctx = new CommunicationDbContext();
            ReactionRepository     reactionRepository     = new ReactionRepository(ctx);
            UserRepository         userRepository         = new UserRepository(ctx);
            CommentRepository      commentRepository      = new CommentRepository(ctx);
            ContributionRepository contributionRepository = new ContributionRepository(ctx);

            UserModel userModel = new UserModel
            {
                Id              = Guid.NewGuid(),
                Name            = "Pavel",
                Surname         = "Dvorak",
                Email           = "*****@*****.**",
                Password        = "******",
                TelephoneNumber = "+420420420420"
            };

            UserModel userModel2 = new UserModel
            {
                Id              = Guid.NewGuid(),
                Name            = "Petr",
                Surname         = "Novak",
                Email           = "*****@*****.**",
                Password        = "******",
                TelephoneNumber = "+420420420420"
            };

            ContributionModel contribution1 = new ContributionModel
            {
                Id      = Guid.NewGuid(),
                Message = "AhojQy,dneska v druzine byl na obed krtkův dort <3, to byl náhul",
                User    = userModel,
                Time    = DateTime.Now
            };

            CommentModel commentModel1 = new CommentModel
            {
                Id           = Guid.NewGuid(),
                Message      = "No a co",
                Time         = DateTime.Now,
                User         = userModel,
                Contribution = contribution1
            };

            CommentModel commentModel2 = new CommentModel
            {
                Id           = Guid.NewGuid(),
                Message      = "Mnam dopi..",
                Time         = DateTime.Now,
                User         = userModel,
                Contribution = contribution1
            };

            userRepository.Insert(userModel);
            //userRepository.Insert(userModel2);
            contributionRepository.Insert(contribution1);
            commentRepository.Insert(commentModel1);
            commentRepository.Insert(commentModel2);

            var userResponse        = userRepository.GetById(userModel.Id);
            var contributionReponse = contributionRepository.GetById(contribution1.Id);
            var commentResponse     = commentRepository.GetCommentByUserId(userModel.Id);

            Console.Write("ID: " + userResponse.Id);
            Console.Write("\nNAME: " + userResponse.Name);
            Console.Write("\nEmail: " + userResponse.Email);
            Console.Write("\n\tStatus: " + contributionReponse.Message);
            Console.Write("\n\t\tComments: ");
            foreach (var comment in commentResponse)
            {
                Console.Write("\n\t\tMessage: " + comment.Message);
            }

            LoginService loginService = new LoginService();

            loginService.register("Jmeno", "Prijmeni", "*****@*****.**", "heslo123", "123456789", null);

            var userByEmail = loginService.LoadUserByEmail("*****@*****.**", "heslo123");

            Console.Write("\nLoadUserByUsername: "******"*****@*****.**");
            try
            {
                userByEmail = loginService.LoadUserByEmail("*****@*****.**", "heslo123");
                Console.Write("\nChyba ");
            }
            catch (LoginException ex)
            {
                Console.Write("\nLoadUserByUsername: " + ex.Message);
            }

            userRepository.Delete(userByEmail);
            userRepository.Delete(userModel);
            Console.ReadKey();
        }
Пример #2
0
 public ContributionRepository(CommunicationDbContext dbContext) : base(dbContext, new ContributionMapper())
 {
 }
Пример #3
0
 public UserRepository(CommunicationDbContext dbContext) : base(dbContext, new UserMapper())
 {
 }
Пример #4
0
 public GenericRepository(CommunicationDbContext dbContext, IMapper <E, M> mapper)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
     dbSet          = dbContext.Set <E>();
 }
 public GroupMemberRepository(CommunicationDbContext dbContext) : base(dbContext, new GroupMemberMapper())
 {
 }
Пример #6
0
 public ReactionRepository(CommunicationDbContext dbContext) : base(dbContext, new ReactionMapper())
 {
 }
Пример #7
0
 public CommentRepository(CommunicationDbContext dbContext) : base(dbContext, new CommentMapper())
 {
 }