diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-08-06 10:41:16 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-08-06 10:41:16 +0300 |
| commit | e86fe2e8cf34343cf3ebbf4640b2be5e85899615 (patch) | |
| tree | dee59a2c43b69b6abe20be24059d42ecabcdfffc /Software/Visual_Studio_v2/Tango.DAL | |
| parent | c1b00ec58a47e504e0247c21c96b55a89e7a95eb (diff) | |
| download | Tango-e86fe2e8cf34343cf3ebbf4640b2be5e85899615.tar.gz Tango-e86fe2e8cf34343cf3ebbf4640b2be5e85899615.zip | |
v2 Basic structure.
Diffstat (limited to 'Software/Visual_Studio_v2/Tango.DAL')
5 files changed, 78 insertions, 0 deletions
diff --git a/Software/Visual_Studio_v2/Tango.DAL/Attributes/MongoCollectionAttribute.cs b/Software/Visual_Studio_v2/Tango.DAL/Attributes/MongoCollectionAttribute.cs new file mode 100644 index 000000000..50b585698 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.DAL/Attributes/MongoCollectionAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.DAL.Attributes +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] + public class MongoCollectionAttribute : Attribute + { + public String Name { get; set; } + + public MongoCollectionAttribute(String name) + { + Name = name; + } + } +} diff --git a/Software/Visual_Studio_v2/Tango.DAL/Entities/OrganizationEntity.cs b/Software/Visual_Studio_v2/Tango.DAL/Entities/OrganizationEntity.cs new file mode 100644 index 000000000..b17cd34c9 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.DAL/Entities/OrganizationEntity.cs @@ -0,0 +1,11 @@ +using System; +using Tango.DAL.Attributes; + +namespace Tango.DAL.Entities +{ + [MongoCollection("Organizations")] + public class OrganizationEntity : Entity + { + public string Name { get; set; } + } +} diff --git a/Software/Visual_Studio_v2/Tango.DAL/Entity.cs b/Software/Visual_Studio_v2/Tango.DAL/Entity.cs new file mode 100644 index 000000000..d299dcc78 --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.DAL/Entity.cs @@ -0,0 +1,15 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tango.DAL +{ + public abstract class Entity + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string ID { get; set; } + } +} diff --git a/Software/Visual_Studio_v2/Tango.DAL/IRepository.cs b/Software/Visual_Studio_v2/Tango.DAL/IRepository.cs new file mode 100644 index 000000000..a6d6989dd --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.DAL/IRepository.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DAL +{ + public interface IRepository : IDisposable + { + + } + + public interface IRepository<T> : IRepository where T : Entity + { + Task<List<T>> GetAsync(Expression<Func<T, bool>> filter); + Task<List<T>> GetAllAsync(); + Task<T> ReplaceAsync(T entity); + Task<long> DeleteAsync(Expression<Func<T, bool>> filter); + Task<T> Insert(T entity); + Task<long> Count(); + Task<long> Count(Expression<Func<T, bool>> filter); + } +} diff --git a/Software/Visual_Studio_v2/Tango.DAL/Tango.DAL.csproj b/Software/Visual_Studio_v2/Tango.DAL/Tango.DAL.csproj new file mode 100644 index 000000000..6fa539f1e --- /dev/null +++ b/Software/Visual_Studio_v2/Tango.DAL/Tango.DAL.csproj @@ -0,0 +1,11 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>netstandard2.0</TargetFramework> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="MongoDB.Driver" Version="2.8.1" /> + </ItemGroup> + +</Project> |
