// Part 1 public StoryCreatorResult CreateOrEditStory(StoryApplication app) { bool isEdit = app.StoryID != 0; var result = new StoryCreatorResult(); CurrentApplication = app; result.StoryApplication = app; if (isEdit) { result.StoryApplication.Message = "Successfully edited story!"; } else { result.StoryApplication.Message = "Successfully created a new story!"; } if (TitleNotPresent()) { return(InvalidApplication("Title is missing")); } if (TitleIsInvalid()) { return(InvalidApplication("Title is invalid - needs to be 4 or more characters")); } if (TitleAlreadyExists()) { return(InvalidApplication("Title exists already in database")); } // Accept the StoryApplication result.NewStory = AcceptApplication(); return(result); }
public StoryCreatorResult InvalidApplication(string reason) { var result = new StoryCreatorResult(); CurrentApplication.Status = StoryApplicationStatus.Invalid; result.StoryApplication = CurrentApplication; result.StoryApplication.Message = reason; return(result); }