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); }
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); }
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); }
public static JournalCreateRequest GetJournalCreateRequest() { var request = new JournalCreateRequest(CurrentUserId, StringOne); return(request); }