From e86fe2e8cf34343cf3ebbf4640b2be5e85899615 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 6 Aug 2019 10:41:16 +0300 Subject: v2 Basic structure. --- .../Attributes/MongoCollectionAttribute.cs | 17 +++++++++++++++ .../Tango.DAL/Entities/OrganizationEntity.cs | 11 ++++++++++ Software/Visual_Studio_v2/Tango.DAL/Entity.cs | 15 ++++++++++++++ Software/Visual_Studio_v2/Tango.DAL/IRepository.cs | 24 ++++++++++++++++++++++ .../Visual_Studio_v2/Tango.DAL/Tango.DAL.csproj | 11 ++++++++++ 5 files changed, 78 insertions(+) create mode 100644 Software/Visual_Studio_v2/Tango.DAL/Attributes/MongoCollectionAttribute.cs create mode 100644 Software/Visual_Studio_v2/Tango.DAL/Entities/OrganizationEntity.cs create mode 100644 Software/Visual_Studio_v2/Tango.DAL/Entity.cs create mode 100644 Software/Visual_Studio_v2/Tango.DAL/IRepository.cs create mode 100644 Software/Visual_Studio_v2/Tango.DAL/Tango.DAL.csproj (limited to 'Software/Visual_Studio_v2/Tango.DAL') 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 : IRepository where T : Entity + { + Task> GetAsync(Expression> filter); + Task> GetAllAsync(); + Task ReplaceAsync(T entity); + Task DeleteAsync(Expression> filter); + Task Insert(T entity); + Task Count(); + Task Count(Expression> 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 @@ + + + + netstandard2.0 + + + + + + + -- cgit v1.3.1