Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented new models and repositories for MongoDB.
- Loading branch information
Showing
33 changed files
with
550 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Text; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver; | ||
using MongoDB.Driver.Linq; | ||
using MongoDB.Driver.Builders; | ||
|
||
using ScrumTime.Foundation.DataAccessLayer; | ||
using ScrumTime.Foundation.Models; | ||
|
||
namespace ScrumTime.Foundation.Test | ||
{ | ||
[TestClass] | ||
public class BugRepositoryTest | ||
{ | ||
[TestMethod] | ||
public void SetDefaultBugInformationTest() | ||
{ | ||
var bugRepository = new BugRepository(); | ||
bugRepository.SetDefaultBugPriorities(); | ||
bugRepository.SetDefaultBugSeverities(); | ||
bugRepository.SetDefaultBugStatuses(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Text; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver; | ||
using MongoDB.Driver.Linq; | ||
using MongoDB.Driver.Builders; | ||
|
||
using ScrumTime.Foundation.DataAccessLayer; | ||
using ScrumTime.Foundation.Models; | ||
|
||
namespace ScrumTime.Foundation.Test | ||
{ | ||
[TestClass] | ||
public class StoryRepositoryTest | ||
{ | ||
[TestMethod] | ||
public void SetDefaultStoryPointsTest() | ||
{ | ||
var storyRepository = new StoryRepository(); | ||
storyRepository.SetDefaultStoryPoints(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
source/ScrumTime.Foundation/DataAccessLayer/BaseRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver; | ||
using MongoDB.Driver.Linq; | ||
using ScrumTime.Foundation.Models; | ||
|
||
namespace ScrumTime.Foundation.DataAccessLayer | ||
{ | ||
public class BaseRepository<T> where T : IScrumTimeModel | ||
{ | ||
protected ScrumTimeContext scrumTimeContext; | ||
|
||
protected String collectionName; | ||
|
||
public BaseRepository(String collectionName) | ||
{ | ||
scrumTimeContext = new ScrumTimeContext(); | ||
this.collectionName = collectionName; | ||
} | ||
|
||
public IQueryable<T> GetCollection() | ||
{ | ||
return scrumTimeContext.Database.GetCollection<T>(collectionName).AsQueryable<T>(); | ||
} | ||
|
||
public T GetById(ObjectId Id) | ||
{ | ||
return GetCollection().Where(m => m.Id == Id).FirstOrDefault(); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
source/ScrumTime.Foundation/DataAccessLayer/BugRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver.Linq; | ||
using ScrumTime.Foundation.Models; | ||
|
||
namespace ScrumTime.Foundation.DataAccessLayer | ||
{ | ||
public class BugRepository : BaseRepository<Bug> | ||
{ | ||
|
||
public BugRepository() | ||
: base("Bugs") | ||
{ | ||
} | ||
|
||
public void SetDefaultBugPriorities() | ||
{ | ||
var priorities = scrumTimeContext.BugPriorities().AsQueryable<BugPriority>(); | ||
if (priorities.SingleOrDefault(m => m.Name == "Low") == null) | ||
scrumTimeContext.BugPriorities().Insert(new BugPriority() { Name = "Low", NumericValue = 100 }); | ||
if (priorities.SingleOrDefault(m => m.Name == "Normal") == null) | ||
scrumTimeContext.BugPriorities().Insert(new BugPriority() { Name = "Normal", NumericValue = 50 }); | ||
if (priorities.SingleOrDefault(m => m.Name == "High") == null) | ||
scrumTimeContext.BugPriorities().Insert(new BugPriority() { Name = "High", NumericValue = 10 }); | ||
if (priorities.SingleOrDefault(m => m.Name == "Urgent") == null) | ||
scrumTimeContext.BugPriorities().Insert(new BugPriority() { Name = "Urgent", NumericValue = 1 }); | ||
} | ||
|
||
public void SetDefaultBugSeverities() | ||
{ | ||
var severities = scrumTimeContext.BugSeverities().AsQueryable<BugSeverity>(); | ||
if (severities.SingleOrDefault(m => m.Name == "Trivial") == null) | ||
scrumTimeContext.BugSeverities().Insert(new BugSeverity() { Name = "Trivial", NumericValue = 100 }); | ||
if (severities.SingleOrDefault(m => m.Name == "Minor") == null) | ||
scrumTimeContext.BugSeverities().Insert(new BugSeverity() { Name = "Minor", NumericValue = 50 }); | ||
if (severities.SingleOrDefault(m => m.Name == "Major") == null) | ||
scrumTimeContext.BugSeverities().Insert(new BugSeverity() { Name = "Major", NumericValue = 10 }); | ||
if (severities.SingleOrDefault(m => m.Name == "Blocking") == null) | ||
scrumTimeContext.BugSeverities().Insert(new BugSeverity() { Name = "Blocking", NumericValue = 1 }); | ||
} | ||
|
||
public void SetDefaultBugStatuses() | ||
{ | ||
var statuses = scrumTimeContext.BugStatuses().AsQueryable<BugStatus>(); | ||
if (statuses.SingleOrDefault(m => m.Name == "New") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "New", NumericValue = 100 }); | ||
if (statuses.SingleOrDefault(m => m.Name == "Feedback") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "Feedback", NumericValue = 95 }); | ||
if (statuses.SingleOrDefault(m => m.Name == "Acknowledged") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "Acknowledged", NumericValue = 90 }); | ||
if (statuses.SingleOrDefault(m => m.Name == "Confirmed") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "Confirmed", NumericValue = 70 }); | ||
if (statuses.SingleOrDefault(m => m.Name == "Assigned") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "Assigned", NumericValue = 50 }); | ||
if (statuses.SingleOrDefault(m => m.Name == "On Hold") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "On Hold", NumericValue = 40 }); | ||
if (statuses.SingleOrDefault(m => m.Name == "Resolved") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "Resolved", NumericValue = 20 }); | ||
if (statuses.SingleOrDefault(m => m.Name == "Closed") == null) | ||
scrumTimeContext.BugStatuses().Insert(new BugStatus() { Name = "Closed", NumericValue = 10 }); | ||
|
||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
source/ScrumTime.Foundation/DataAccessLayer/ProductRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver.Linq; | ||
using ScrumTime.Foundation.Models; | ||
|
||
namespace ScrumTime.Foundation.DataAccessLayer | ||
{ | ||
public class ProductRepository : BaseRepository<Product> | ||
{ | ||
public ProductRepository() | ||
: base("Products") | ||
{ | ||
} | ||
|
||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
source/ScrumTime.Foundation/DataAccessLayer/ReleaseRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver.Linq; | ||
using ScrumTime.Foundation.Models; | ||
|
||
namespace ScrumTime.Foundation.DataAccessLayer | ||
{ | ||
public class ReleaseRepository : BaseRepository<Release> | ||
{ | ||
public ReleaseRepository() | ||
: base("Releases") | ||
{ | ||
} | ||
|
||
} | ||
} |
59 changes: 43 additions & 16 deletions
59
source/ScrumTime.Foundation/DataAccessLayer/ScrumTimeContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,50 @@ | ||
using ScrumTime.Foundation.Models; | ||
|
||
namespace ScrumTime.Foundation.DataAccessLayer | ||
namespace ScrumTime.Foundation.DataAccessLayer | ||
{ | ||
public class ScrumTimeContext // : DbContext | ||
using System.Configuration; | ||
using MongoDB.Driver; | ||
|
||
using ScrumTime.Foundation.Models; | ||
|
||
public class ScrumTimeContext | ||
{ | ||
|
||
//public DbSet<Actor> Actors { get; set; } | ||
//public DbSet<Artifact> Artifacts { get; set; } | ||
//public DbSet<Bug> Bugs { get; set; } | ||
//public DbSet<Feature> Features { get; set; } | ||
//public DbSet<Product> Products { get; set; } | ||
//public DbSet<Release> Releases { get; set; } | ||
////public DbSet<Scrum> Scrums { get; set; } | ||
////public DbSet<ScrumTask> ScrumTasks { get; set; } | ||
//public DbSet<Sprint> Sprints { get; set; } | ||
//public DbSet<Story> Stories { get; set; } | ||
//public DbSet<Task> Tasks { get; set; } | ||
//public DbSet<Team> Teams { get; set; } | ||
public MongoDatabase Database { get; private set; } | ||
|
||
public ScrumTimeContext() | ||
{ | ||
var connectionString = ConfigurationManager.AppSettings["ScrumTimeMongoDBConnection"]; | ||
var server = MongoServer.Create(connectionString); | ||
Database = server.GetDatabase("ScrumTime"); | ||
} | ||
|
||
|
||
|
||
public void DeleteAllCollections() | ||
{ | ||
foreach (var collectionName in Database.GetCollectionNames()) | ||
{ | ||
Database.DropCollection(collectionName); | ||
} | ||
} | ||
|
||
public MongoCollection<StoryPoint> StoryPoints() | ||
{ | ||
return Database.GetCollection<StoryPoint>("StoryPoints"); | ||
} | ||
|
||
public MongoCollection<BugSeverity> BugSeverities() | ||
{ | ||
return Database.GetCollection<BugSeverity>("BugSeverities"); | ||
} | ||
|
||
public MongoCollection<BugPriority> BugPriorities() | ||
{ | ||
return Database.GetCollection<BugPriority>("BugPriorities"); | ||
} | ||
|
||
public MongoCollection<BugStatus> BugStatuses() | ||
{ | ||
return Database.GetCollection<BugStatus>("BugStatuses"); | ||
} | ||
} | ||
} |
Oops, something went wrong.