コード例 #1
0
        public void Execute(RegisterUserDto request)
        {
            var cases = new List <int> {
                14, 19, 16
            };

            _validator.ValidateAndThrow(request);
            var user = new User
            {
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email,
                Password  = request.Password,
                Username  = request.Username
            };

            _context.Users.Add(user);
            _context.SaveChanges();
            _sender.Send(new SendEmailDto
            {
                Content = "<h1>Successfuly registration</h1>",
                SendTo  = request.Email,
                Subject = "Registration"
            });
            foreach (var i in cases)
            {
                var userUseCase = new UserUseCase
                {
                    UseCaseId = i,
                    UserId    = user.Id
                };
                _context.Add(userUseCase);
            }
            _context.SaveChanges();
        }
コード例 #2
0
        public void Execute(CommentDto request)
        {
            _validator.ValidateAndThrow(request);
            var comment = new Comment
            {
                TextComment = request.TextComment,
                PostId      = request.PostId,
                UserId      = request.UserId
            };

            _context.Add(comment);
            _context.SaveChanges();
        }