Пример #1
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var controller = context.Controller as IJournalingController;

            if (controller == null)
            {
                return;
            }

            if (Message.IsEmpty())
            {
                return;
            }

            if (!controller.CurrentUser.IsActionSucceed)
            {
                return;
            }

            var request  = new JournalCreateRequest(controller.CurrentUser.Id, Message);
            var response = controller.JournalService.CreateJournal(request);

            if (response.Status.IsNotSuccess)
            {
                throw new JournalException("couldn't write to journal > " + Message);
            }

            base.OnActionExecuted(context);
        }
Пример #2
0
        public JournalCreateResponse CreateJournal(JournalCreateRequest request)
        {
            var currentUser = _cacheManager.GetCachedCurrentUser(request.CurrentUserId);

            var entity = _journalFactory.CreateEntityFromRequest(request, currentUser);

            _journalRepository.Insert(request.CurrentUserId, entity).Wait();

            var response = new JournalCreateResponse {
                Status = ResponseStatus.Success
            };

            return(response);
        }
Пример #3
0
        public Journal CreateEntityFromRequest(JournalCreateRequest request, CurrentUser currentUser)
        {
            var entity = new Journal();

            entity.UserId           = currentUser.Id;
            entity.UserUid          = currentUser.Uid;
            entity.UserName         = currentUser.Name;
            entity.OrganizationId   = currentUser.Organization.Id;
            entity.OrganizationUid  = currentUser.Organization.Uid;
            entity.OrganizationName = currentUser.Organization.Name;

            entity.Message = request.Message;

            return(entity);
        }
Пример #4
0
        public static JournalCreateRequest GetJournalCreateRequest()
        {
            var request = new JournalCreateRequest(CurrentUserId, StringOne);

            return(request);
        }