コード例 #1
0
        private void SetState(RemarkState state)
        {
            if (state == null)
            {
                throw new DomainException(OperationCodes.RemarkStateNotProvided,
                                          "Remark state can not be null.");
            }

            var latestState = _states.LastOrDefault();

            if (latestState == null)
            {
                _states.Add(state);
                State = state;

                return;
            }
            if (latestState.State == RemarkState.Names.Canceled)
            {
                throw new DomainException(OperationCodes.CannotSetState,
                                          $"Can not set state to '{state}' for remark with id: '{Id}'" +
                                          "as it was canceled.");
            }
            if (latestState.State == state.State && latestState.State != RemarkState.Names.Processing)
            {
                throw new DomainException(OperationCodes.CannotSetState,
                                          $"Can not set state to '{state}' for remark with id: '{Id}'" +
                                          "as it's the same as the previous one.");
            }
            _states.Add(state);
            State     = state;
            UpdatedAt = DateTime.UtcNow;
        }
コード例 #2
0
        public void EditFirstState()
        {
            var previousState = _states.First();
            var currentState  = RemarkState.New(previousState.User, Location,
                                                Description, createdAt: previousState.CreatedAt);

            _states.Remove(previousState);
            _states.Add(currentState);
            _states   = new HashSet <RemarkState>(_states.OrderBy(x => x.CreatedAt));
            State     = currentState;
            UpdatedAt = DateTime.UtcNow;
        }
コード例 #3
0
 public Remark(Guid id, User author, Category category, Location location,
               string description = null, Group group = null)
 {
     Id = id;
     SetAuthor(author);
     SetCategory(category);
     SetLocation(location);
     SetDescription(description);
     SetGroup(group);
     SetState(RemarkState.New(Author, location, description));
     CreatedAt = DateTime.UtcNow;
     UpdatedAt = DateTime.UtcNow;
 }
コード例 #4
0
 public void SetCanceledState(User user, string description = null)
 => SetState(RemarkState.Canceled(RemarkUser.Create(user), description));
コード例 #5
0
 public void SetRenewedState(User user, string description = null,
                             RemarkPhoto photo             = null)
 => SetState(RemarkState.Renewed(RemarkUser.Create(user), description, photo));
コード例 #6
0
 public void SetProcessingState(User user, string description = null,
                                RemarkPhoto photo             = null)
 => SetState(RemarkState.Processing(RemarkUser.Create(user), description, photo));