public ViewResult StoryPage() { StoryRepository.storyList.Sort((s1, s2) => DateTime.Compare(s1.Date, s2.Date)); //Sort the stories by date on the page when it's called. ViewBag.storyCount = StoryRepository.GetStoryCount(); ViewBag.userCount = StoryRepository.GetUserCount(); return(View("StoryPage", StoryRepository.Stories)); }
public ActionResult Details(int id) { var model = new ProjectFormModel(); var project = ProjectRepository.ProjectFetch(id); model.Title = string.Format("Project {0}", project.Name); model.Project = project; model.Notes = NoteRepository.NoteFetchInfoList(id, SourceType.Project); model.Attachments = AttachmentRepository.AttachmentFetchInfoList( model.Notes.Select(row => row.NoteId).Distinct().ToArray(), SourceType.Note); model.Sprints = SprintRepository.SprintFetchInfoList(project); model.Statuses = StatusRepository.StatusFetchInfoList(id); model.Stories = StoryRepository.StoryFetchInfoList(project, false); model.Users = ProjectUserRepository.ProjectUserFetchInfoList(id); model.TimelineListModel = new TimelineListModel { Timelines = TimelineRepository.TimelineFetchInfoList(project), SourceId = project.SourceId, SourceTypeId = (int)project.SourceType }; model.Actions.Add("Edit this project", Url.Action("Edit", new { id }), "primary"); model.Actions.Add("Add a story", Url.Action("Create", "Story", new { projectId = id })); model.Actions.Add("Add a sprint", Url.Action("Create", "Sprint", new { projectId = id })); model.Actions.Add("Add an email", string.Empty); model.Actions.Add("Add a note", Url.Action("Create", "Note", new { sourceId = id, sourceTypeId = (int)SourceType.Project })); model.Actions.Add("Add a collaborator", Url.Action("Create", "ProjectUser", new { projectId = id })); model.Actions.Add("Add a status", Url.Action("Create", "Status", new { projectId = id })); return(this.View(model)); }
private void favorit_Click(object sender, EventArgs e) { // Add/Remove from favorits. depending on situation and change text on menu item accordinlgy ApplicationBarMenuItem mi = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem; if (mi == null) { return; } if (StoryRepository.CheckStoryTitle(value.post.title)) { if (StoryRepository.RemoveStory(value.post.title)) { mi.Text = AddToFavoritsString; } } else { if (StoryRepository.AddNewStory(value.post.title, DateTime.Parse(value.post.date), value.post.url, value.post.content, null) > 0) { mi.Text = RemoveFromFavoritsString; } } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = null)] HttpRequest req, ExecutionContext executionContext) { try { string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); if (string.IsNullOrEmpty(requestBody)) { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(new RequestBodyEmptyException()))); } Story data = JsonConvert.DeserializeObject <Story>(requestBody); Story results = StoryRepository.CreateNew(executionContext, "StoryUpdate").AddOrUpdate(data); if (results == null || results.PrimaryKey == 0) { return((ActionResult) new OkObjectResult(new InsertRecordException(data.Title))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(results))); } } catch (Exception e) { return((ActionResult) new BadRequestObjectResult(new UpdateRecordException(typeof(Scene).Name))); } }
public ActionResult Edit(int id, FormCollection collection) { var model = new StoryFormModel(); var story = StoryRepository.StoryFetch(id); var project = ProjectRepository.ProjectFetch(story.ProjectId); this.Map(collection, story); story = StoryRepository.StorySave(story); if (story.IsValid) { return(this.RedirectToAction("Details", new { id = story.StoryId })); } model.Title = "Story Edit"; model.Story = story; model.Sprints = SprintRepository.SprintFetchInfoList(project); model.Statuses = StatusRepository.StatusFetchInfoList(story.ProjectId); model.Users = ProjectUserRepository.ProjectUserFetchInfoList(story.ProjectId); ModelHelper.MapBrokenRules(this.ModelState, story); return(this.View(model)); }
public void Story_Create() { var story = StoryRepository.StoryNew(); Assert.IsTrue(story.IsNew, "IsNew should be true"); Assert.IsTrue(story.IsDirty, "IsDirty should be true"); Assert.IsFalse(story.IsValid, "IsValid should be false"); Assert.IsTrue(story.IsSelfDirty, "IsSelfDirty should be true"); Assert.IsFalse(story.IsSelfValid, "IsSelfValid should be false"); Assert.IsTrue( ValidationHelper.ContainsRule(story, DbType.Int32, "CategoryId"), "CategoryId should be required"); Assert.IsTrue( ValidationHelper.ContainsRule(story, DbType.String, "Description"), "Description should be required"); Assert.IsTrue( ValidationHelper.ContainsRule(story, DbType.Int32, "ProjectId"), "ProjectId should be required"); Assert.IsTrue( ValidationHelper.ContainsRule(story, DbType.Int32, "StatusId"), "StatusId should be required"); }
private void favorit_Click(object sender, EventArgs e) { // Add/Remove from favorits. depending on situation and change text on menu item accordinlgy ApplicationBarMenuItem mi = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem; if (mi == null) { return; } if (StoryRepository.CheckStoryTitle(value.post.title, true)) { if (StoryRepository.RemoveStory(value.post.title, true)) { mi.Text = AddToFavoritsString; } } else { StoryRepository.RemoveStory(value.post.title, true); if (StoryRepository.AddNewStory(value.post.title, value.post.date != null ? DateTime.Parse(value.post.date) : DateTime.Now, value.post.url, value.post.content, true, null) > 0) { Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50)); mi.Text = RemoveFromFavoritsString; } } }
public IEnumerable GetStories() { IStoryRepository storyRepository = new StoryRepository(); return(storyRepository.GetStories()); }
static async Task Main(string[] args) { var medium = new Medium(); var pack = await medium.GetPack(MEDIUM_USERS); var contextOptions = new DbContextOptionsBuilder <BlogContext>() .UseNpgsql("Server=localhost;Database=blog;Username=blogadmin;Password=blogadmin") .Options; var blogContext = new BlogContext(contextOptions); var usersRepository = new UserRepository(blogContext); var users = pack.Users.Where(u => usersRepository.IsUsernameUniq(u.Username)).ToList(); users.ForEach(usersRepository.Add); usersRepository.Commit(); Console.WriteLine($"{users.Count} new users added"); var storiesRepository = new StoryRepository(blogContext); var stories = pack.Stories.Where(s => storiesRepository.GetSingle(os => os.Title == s.Title && os.PublishTime == s.PublishTime) == null ).ToList(); stories.ForEach(storiesRepository.Add); storiesRepository.Commit(); Console.WriteLine($"{stories.Count} new stories added"); var likeRepository = new LikeRepository(blogContext); var likes = GenerateLikes(new Pack { Users = pack.Users, Stories = stories }); likes.ForEach(likeRepository.Add); likeRepository.Commit(); Console.WriteLine($"{likes.Count} new likes added"); }
public void GetListByProjectShouldReturnAllStoriesFromProject() { // Arrange var dataList = this.GetMockDataMultiProjectList(); var projectName = "StoryMapper"; // First Project StoryRepository repository; // Act repository = new StoryRepository(dataList); var actual = repository.GetList(story => story.ProjectName == projectName); // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IEnumerable<Story>)); Assert.IsTrue(actual.Count() == 2); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); Assert.AreEqual(projectName, story.ProjectName); } // Arrange dataList = this.GetMockDataMultiProjectList(); projectName = "TestProject1"; // Second Project // Act repository = new StoryRepository(dataList); actual = repository.GetList(story => story.ProjectName == projectName); // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IEnumerable<Story>)); Assert.IsTrue(actual.Count() == 1); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); Assert.AreEqual(projectName, story.ProjectName); } // Arrange dataList = this.GetMockDataMultiProjectList(); projectName = "TestProject2"; // Third Project // Act repository = new StoryRepository(dataList); actual = repository.GetList(story => story.ProjectName == projectName); // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IEnumerable<Story>)); Assert.IsTrue(actual.Count() == 1); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); Assert.AreEqual(projectName, story.ProjectName); } }
public ViewResult Story(string thestory, string username, string email, string title, bool ismember) { Story tale = new Story(); tale.IsMember = ismember; tale.Title = title; tale.TheStory = thestory; tale.Username = username; tale.Email = email; tale.Date = DateTime.Now; User user1 = new User(); user1.IsMember = ismember; user1.UserName = username; user1.EMAIL = email; StoryRepository.AddStory(tale); StoryRepository.AddUser(user1); ViewBag.storyCount = StoryRepository.GetStoryCount(); ViewBag.userCount = StoryRepository.GetUserCount(); return(View("StoryPage", StoryRepository.Stories)); }
public static Story StoryAdd() { var story = StoryTestHelper.StoryNew(); story = StoryRepository.StorySave(story); return(story); }
public void Story_Fetch_Info_List() { StoryTestHelper.StoryAdd(); StoryTestHelper.StoryAdd(); var storys = StoryRepository.StoryFetchInfoList(new StoryDataCriteria()); Assert.IsTrue(storys.Count() > 1, "Row returned should be greater than one"); }
public bool RemoveFavorite(Story story) { if (StoryRepository.RemoveStory(story)) { Favorits.Remove(story); return(true); } return(false); }
public ViewResult UserList(string username) { User Username = new User(); StoryRepository.AddUser(Username); ViewBag.storyCount = StoryRepository.GetStoryCount(); ViewBag.userCount = StoryRepository.GetUserCount(); return(View("UserList", StoryRepository.UserNames)); }
public void Story_Fetch() { var story = StoryTestHelper.StoryNew(); story = StoryRepository.StorySave(story); story = StoryRepository.StoryFetch(story.StoryId); Assert.IsTrue(story != null, "Row returned should not equal null"); }
public ActionResult Edit(int id) { var model = new HourFormModel(); var hour = HourRepository.HourFetch(id); model.Title = "Hour Edit"; model.Hour = hour; model.Story = StoryRepository.StoryFetch(hour.StoryId); return(this.View(model)); }
public void Story_Add() { var story = StoryTestHelper.StoryNew(); Assert.IsTrue(story.IsValid, "IsValid should be true"); story = StoryRepository.StorySave(story); Assert.IsTrue(story.StoryId != 0, "StoryId should be a non-zero value"); StoryRepository.StoryFetch(story.StoryId); }
public ActionResult Create(int storyId) { var model = new HourFormModel(); var hour = HourRepository.HourNew(); hour.StoryId = storyId; model.Title = "Hour Create"; model.Hour = hour; model.Story = StoryRepository.StoryFetch(storyId); return(this.View(model)); }
public T AssignViewData <T>(T data) where T : BaseViewData { data.SiteTitle = Settings.SiteTitle; data.RootUrl = Settings.RootUrl; data.MetaKeywords = Settings.MetaKeywords; data.MetaDescription = Settings.MetaDescription; data.IsCurrentUserAuthenticated = IsCurrentUserAuthenticated; data.CurrentUser = CurrentUser; data.UpcomingStoriesCount = StoryRepository.CountByUpcoming(); data.FacebookAppId = Settings.FacebookAppId; return(data); }
private void AddPublishedPagesInRegularSiteMap(HttpContextBase context, bool forMobile, XContainer target, IFormattable currentDate) { string rootUrl = Settings.RootUrl; int publishPageCount = PageCalculator.TotalPage(StoryRepository.CountByPublished(), Settings.HtmlStoryPerPage); int publishPageCounter = 1; while (publishPageCounter <= publishPageCount) { target.Add(CreateEntry(context, rootUrl, "Published", new { page = publishPageCounter }, currentDate, SiteMapChangeFrequency.Daily, ((publishPageCounter <= CriticalPriorityPageLimit) ? SiteMapUpdatePriority.Critical : SiteMapUpdatePriority.Normal), forMobile)); publishPageCounter += 1; } }
private void AddUpcomingPagesInRegularSiteMap(HttpContextBase context, bool forMobile, XContainer target, IFormattable currentDate) { string rootUrl = Settings.RootUrl; int upcomingPageCount = PageCalculator.TotalPage(StoryRepository.CountByUpcoming(), Settings.HtmlStoryPerPage); int upcomingPageCounter = 1; while (upcomingPageCounter <= upcomingPageCount) { target.Add(CreateEntry(context, rootUrl, "Upcoming", new { page = upcomingPageCounter }, currentDate, SiteMapChangeFrequency.Hourly, ((upcomingPageCounter <= CriticalPriorityPageLimit) ? SiteMapUpdatePriority.High : SiteMapUpdatePriority.Normal), forMobile)); upcomingPageCounter += 1; } }
public static Story StoryNew() { var project = ProjectTestHelper.ProjectAdd(); var status = StatusTestHelper.StatusAdd(); var story = StoryRepository.StoryNew(); story.Description = DataHelper.RandomString(50); story.ProjectId = project.ProjectId; story.StatusId = status.StatusId; return(story); }
public ViewResult StoryForm(Stories storyForm) { if (ModelState.IsValid) { StoryRepository.AddStory(storyForm); return(View("SubmittedStory", storyForm)); } else { // there is a validation error return(View()); } }
public ActionResult Index() { var model = new StoryIndexModel(); var criteria = new StoryDataCriteria { IsArchived = false, }; var stories = StoryRepository.StoryFetchInfoList(criteria); model.Stories = stories; return(this.View(model)); }
public ActionResult Edit(int id) { var model = new StoryFormModel(); var story = StoryRepository.StoryFetch(id); var project = ProjectRepository.ProjectFetch(story.ProjectId); model.Title = "Story Edit"; model.Story = story; model.Sprints = SprintRepository.SprintFetchInfoList(project); model.Statuses = StatusRepository.StatusFetchInfoList(story.ProjectId); model.Users = ProjectUserRepository.ProjectUserFetchInfoList(story.ProjectId); return(this.View(model)); }
public ActionResult Delete(int id) { var model = new DeleteModel(); var story = StoryRepository.StoryFetch(id); model.Title = "Story Delete"; model.Id = story.StoryId; model.Name = "Story"; model.Description = story.Description; model.ControllerName = "Story"; model.BackUrl = Url.Action("Details", "Story", new { id = story.StoryId }); return(this.View(model)); }
public bool AddFavorite(string title, DateTime publishedDate, string link, string details) { try { StoryRepository.AddNewStory(title, publishedDate, link, details, StoreFavorit); return(true); } catch (Exception e) { } return(false); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ExecutionContext executionContext) { IEnumerable <Story> results = StoryRepository.CreateNew(executionContext, "StoryList").GetAll(); if (results == null || results.Count() == 0) { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(new ErrorReadingDataFile(typeof(Story).Name)))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Story>(results))); } }
private void AddTagPagesInRegularSiteMap(HttpContextBase context, bool forMobile, XContainer target, IFormattable currentDate) { int rowPerPage = Settings.HtmlStoryPerPage; string rootUrl = Settings.RootUrl; foreach (ITag tag in TagRepository.FindByUsage(Settings.TopTags)) { int tagPageCount = PageCalculator.TotalPage(StoryRepository.CountByTag(tag.Id), rowPerPage); int tagPageCounter = 1; while (tagPageCounter <= tagPageCount) { target.Add(CreateEntry(context, rootUrl, "Story", "Tags", new { name = tag.UniqueName, page = tagPageCounter }, currentDate, SiteMapChangeFrequency.Daily, ((tagPageCounter <= CriticalPriorityPageLimit) ? SiteMapUpdatePriority.High : SiteMapUpdatePriority.Normal), forMobile)); tagPageCounter += 1; } } }
public ActionResult Create(int projectId, int?sprintId) { var model = new StoryFormModel(); var story = StoryRepository.StoryNew(); var project = ProjectRepository.ProjectFetch(projectId); story.ProjectId = projectId; story.SprintId = sprintId ?? 0; model.Title = "Story Create"; model.Story = story; model.Sprints = SprintRepository.SprintFetchInfoList(project); model.Statuses = StatusRepository.StatusFetchInfoList(story.ProjectId); model.Users = ProjectUserRepository.ProjectUserFetchInfoList(story.ProjectId); return(this.View(model)); }
public ProjectReportViewModel(ObjectId projectId) { //this.projectId = projectId; var projectRepository = new ProjectRepository(); var storyRepository = new StoryRepository(); Project = projectRepository.FindById(projectId); Stories = storyRepository.FindByProjectId(projectId); Stories = Stories.OrderBy(s => s.Name).ThenBy(s => s.Status); Usernames = new List<string>(); foreach (var user in Project.Users) { Usernames.Add(user.UserName); } UsernameList = string.Join(", ", Usernames); }
public void CreateStoryShouldAddNewStory() { // Arrange var repository = new StoryRepository(); var expected = new Story { Name = "Story Test", ProjectName = "StoryMapper" }; // Act var createdActual = repository.Create(expected); var obtainedActual = repository.Single(story => story.Name == expected.Name && story.ProjectName == expected.ProjectName); // Assert Assert.IsNotNull(createdActual); Assert.IsNotNull(obtainedActual); Assert.AreEqual(expected.Name, createdActual.Name); Assert.AreEqual(expected.Name, obtainedActual.Name); Assert.AreEqual(expected.ProjectName, createdActual.ProjectName); Assert.AreEqual(expected.ProjectName, obtainedActual.ProjectName); }
public void DeleteStoryShouldRemoveIt() { // Arrange var dataList = this.GetMockDataList(); var repository = new StoryRepository(dataList); var expectedCount = dataList.Count() - 1; var notExpected = dataList[0]; // Act repository.Delete(notExpected); var actual = repository.GetList(); // Assert Assert.IsNotNull(actual); Assert.AreEqual(expectedCount, actual.Count()); foreach (var story in actual) { if (notExpected.ProjectName == story.ProjectName) { Assert.AreNotEqual(notExpected.Name, story.Name); } } }
public void GetSingleShouldReturnSingleStory() { // Arrange var dataList = this.GetMockDataMultiProjectList(); var expectedStoryName = "Test Story 1"; var expectedProjectName = "StoryMapper"; StoryRepository repository; // Act repository = new StoryRepository(dataList); var actual = repository.Single(story => story.Name == expectedStoryName && story.ProjectName == expectedProjectName); // Assert Assert.IsNotNull(actual); Assert.AreEqual(expectedStoryName, actual.Name); Assert.AreEqual(expectedProjectName, actual.ProjectName); }
public void SetDefaultStoryPointsTest() { var storyRepository = new StoryRepository(); storyRepository.SetDefaultStoryPoints(); }
public void Init() { m_repository = new StoryRepository(DatabaseHelper.GetConnectionString()); m_database = Database.OpenConnection(DatabaseHelper.GetConnectionString()); m_database.Users.Insert(UserName: "******", FirstName: "Some", LastName: "Dude", APIKey: "yuiu-998", Email: "*****@*****.**", Privileges: 2, Password:"******"); m_database.Projects.Insert(Title: "wololo", Description: "blah"); }
public void UpdateStoryShouldModifyValues() { // Arrange var dataList = this.GetMockDataList(); var repository = new StoryRepository(dataList); var expected = dataList[0]; expected.Name = "Updated Name"; expected.ProjectName = "Updated Project"; // Act var updatedActual = repository.Update(expected); var obtainedActual = repository.Single(story => story.Name == expected.Name && story.ProjectName == expected.ProjectName); // Assert Assert.IsNotNull(updatedActual); Assert.IsNotNull(obtainedActual); Assert.AreEqual(expected.Name, updatedActual.Name); Assert.AreEqual(expected.Name, obtainedActual.Name); Assert.AreEqual(expected.ProjectName, updatedActual.ProjectName); Assert.AreEqual(expected.ProjectName, obtainedActual.ProjectName); }
public void UpdateNonExistentStoryShouldThrowException() { // Arrange var dataList = this.GetMockDataList(); var repository = new StoryRepository(dataList); var notExpected = new Story { Name = "Updated Name", ProjectName = "Updated Project" }; // Act repository.Update(notExpected); }
public StoriesController() { _storyRepository = new StoryRepository(SessionUser); _storyRepository.OnChange += SyncManager.OnChange; }
public StoryService(StoryRepository storyRepository) { this.storyRepository = storyRepository; }
public void StoriesShouldReturnCollection() { // Arrange var dataList = this.GetMockDataList(); StoryRepository repository; // Act repository = new StoryRepository(dataList); var actual = repository.Stories; // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IQueryable<Story>)); Assert.IsTrue(actual.Count() == 4); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); } }