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; }
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; }
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; }
public void SetCanceledState(User user, string description = null) => SetState(RemarkState.Canceled(RemarkUser.Create(user), description));
public void SetRenewedState(User user, string description = null, RemarkPhoto photo = null) => SetState(RemarkState.Renewed(RemarkUser.Create(user), description, photo));
public void SetProcessingState(User user, string description = null, RemarkPhoto photo = null) => SetState(RemarkState.Processing(RemarkUser.Create(user), description, photo));