public void Execute(UserDto request) { _validator.ValidateAndThrow(request); if (request.Id != _actor.Id) { throw new ForbiddenUseCaseException(_actor, this.Name, request.Id); } byte[] salt = Convert.FromBase64String("olK4MOHPZ8IgkmfD17+oyg=="); // derive a 256-bit subkey (use HMACSHA1 with 10,000 iterations) string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2( password: request.Password, salt: salt, prf: KeyDerivationPrf.HMACSHA1, iterationCount: 10000, numBytesRequested: 256 / 8)); var user = _context.Users.Find(request.Id); user.FirstName = request.FirstName; user.LastName = request.LastName; user.Email = request.Email; user.Password = hashed; _context.SaveChanges(); }
public void Execute(UseCaseDto request) { _validator.ValidateAndThrow(request); var usecase = _context.UseCases.Find(request.Id); usecase.Name = request.Name; _context.SaveChanges(); }
public void Execute(UseCaseDto request) { _validator.ValidateAndThrow(request); var useCase = new UseCase { Name = request.Name }; _context.UseCases.Add(useCase); _context.SaveChanges(); }
public void Log(IUseCase useCase, IApplicationActor actor, object useCaseData) { _context.UseCaseLogs.Add(new Domain.UseCaseLog { Date = DateTime.UtcNow, Data = JsonConvert.SerializeObject(useCaseData), UseCaseId = useCase.Id, UserId = actor.Id }); _context.SaveChanges(); }
public void Execute(CommentDto request) { _validator.ValidateAndThrow(request); var comment = _context.Comments.Find(request.Id); if (comment.UserId != _actor.Id) { throw new ForbiddenUseCaseException(_actor, this.Name, request.Id); } comment.CommentText = request.CommentText; _context.SaveChanges(); }
public void Execute(RatingDto request) { request.UserId = _actor.Id; _validator.ValidateAndThrow(request); var rating = _context.Ratings.Find(request.Id); if (rating.UserId != _actor.Id) { throw new ForbiddenUseCaseException(_actor, this.Name, request.Id); } rating.Value = request.Value; _context.SaveChanges(); }
public void Execute(UserUseCaseDto request) { _validator.ValidateAndThrow(request); var userusecase = new Domain.UserUseCase { UseCaseId = request.UseCaseId, UserId = request.UserId }; _context.UserUseCases.Add(userusecase); _context.SaveChanges(); }
public void Execute(RatingDto request) { request.UserId = _actor.Id; _validator.ValidateAndThrow(request); var rating = new Rating { UserId = _actor.Id, PostId = request.PostId, Value = request.Value }; _context.Ratings.Add(rating); _context.SaveChanges(); }
public void Execute(PostDto request) { _validator.ValidateAndThrow(request); var post = new Post { Title = request.Title, Content = request.Content, PhotoPath = request.PhotoPath, UserId = request.UserId, TopicId = request.TopicId }; _context.Posts.Add(post); _context.SaveChanges(); }
public void Execute(int request) { var user = _context.Users.Find(request); if (user == null) { throw new EntityNotFoundException(request, typeof(User)); } if (user.Id != _actor.Id) { throw new ForbiddenUseCaseException(_actor, this.Name, request); } user.DeletedAt = DateTime.Now; user.Visible = false; _context.SaveChanges(); }