public JobApplication(JobSearch parentSearch, string organization, string title) { ParentSearchId = parentSearch.Id; ParentSearch = parentSearch; OrganizationName = organization; JobTitle = title; var creation = new StatusTransition(this, ApplicationStatuses.CREATED, ApplicationStatuses.INPROGRESS, DateTime.Now); ((List <StatusTransition>)Transitions).Add(creation); }
/// <summary> /// Transition this application from one status to another. /// </summary> /// <remarks> /// This method is agnostic about workflows, and will only enforce that you cannot transition from one statu to the same status. /// Use an appropriate class that derives from <see cref="StatusWrapper"/> (e.g. <see cref="SubmittedApplication"/>) as helpers to more /// effective manage the status. /// </remarks> /// <param name="transitionTo"></param> /// <param name="effectiveAsOf"></param> /// <param name="resolution"></param> /// <returns></returns> public Result <StatusTransition> Transition(ApplicationStatuses transitionTo, DateTime effectiveAsOf, ApplicationResolution resolution = ApplicationResolution.UNRESOLVED) { // CAUTION: if the inner logic of this method changes, you may have to revisit the first transition created // in the ctor if (CurrentStatus == transitionTo) { return(Result.Fail("Unable to transition to the current status.")); } if (transitionTo != ApplicationStatuses.CLOSED) { resolution = ApplicationResolution.UNRESOLVED; } var transition = new StatusTransition(this, CurrentStatus, transitionTo, effectiveAsOf, resolution); ((List <StatusTransition>)Transitions).Add(transition); return(Result.Ok(transition)); }