public ICommandResult Execute(CreateStoreCommentCommand command) { try { var comment = new StoreComment(); AddStoreComment(command, comment); _storeCommentRepository.Add(comment); _unitOfWork.Commit(); return(new SuccessResult(StoreCommandMessage.CommentCreatedSuccessfully)); } catch (Exception exception) { _logger.Error(exception.Message); return(new FailureResult(StoreCommandMessage.CommentCreationFaild)); } }
private void AssigneCommentToStore(IStoreCommentCommand command, StoreComment comment) { var store = _storeRepository.GetById(command.StoreId); comment.Stores.Add(store); }
private void AssigneCommentToUser(IStoreCommentCommand command, StoreComment comment) { var user = _membershipRepository.GetUserById(command.UserId); comment.Users.Add(user); }
private void AddStoreComment(IStoreCommentCommand command, StoreComment comment) { comment.Body = command.Body; AssigneCommentToStore(command, comment); AssigneCommentToUser(command, comment); }