├── docs
├── _config.yml
├── app
│ └── logo.png
├── layers
│ ├── green.web.md
│ ├── green.web.framework.md
│ ├── libraries.md
│ ├── green.core.md
│ ├── tests.md
│ ├── green.data.md
│ ├── presentation.md
│ └── green.services.md
├── indev.md
├── SUMMARY.md
├── motivation.md
├── README.md
└── api
│ └── authorization.md
├── _config.yml
├── .github
└── ISSUE_TEMPLATE.md
├── Libraries
├── Green.Core
│ ├── Configuration
│ │ ├── ISettings.cs
│ │ └── GreenConfig.cs
│ ├── Infrastructure
│ │ ├── IStartupTask.cs
│ │ ├── DependencyManagement
│ │ │ └── IDependencyRegistrar.cs
│ │ ├── ITypeFinder.cs
│ │ ├── IGreenStartup.cs
│ │ ├── EngineContext.cs
│ │ ├── WebAppTypeFinder.cs
│ │ ├── IEngine.cs
│ │ └── Singleton.cs
│ ├── Domain
│ │ ├── Security
│ │ │ └── SecuritySettings.cs
│ │ ├── Configuration
│ │ │ └── Setting.cs
│ │ ├── ImageGallery
│ │ │ └── Image.cs
│ │ ├── Circles
│ │ │ ├── UserCircle.cs
│ │ │ └── Circle.cs
│ │ ├── Comments
│ │ │ └── Comment.cs
│ │ ├── Votes
│ │ │ └── Vote.cs
│ │ ├── Notifies
│ │ │ └── Notify.cs
│ │ ├── Tasks
│ │ │ └── ScheduleTask.cs
│ │ └── Posts
│ │ │ └── Post.cs
│ ├── Extensions
│ │ └── CommonExtensions.cs
│ ├── Data
│ │ └── IRepository.cs
│ ├── BaseEntity.cs
│ ├── GreenException.cs
│ ├── Green.Core.csproj
│ └── IWebHelper.cs
├── Green.Services
│ ├── Installation
│ │ ├── IInstallationService.cs
│ │ └── InstallationService.cs
│ ├── Tasks
│ │ ├── ITask.cs
│ │ ├── IScheduleTaskService.cs
│ │ ├── ScheduleTaskService.cs
│ │ ├── TaskManager.cs
│ │ ├── TaskThread.cs
│ │ └── Task.cs
│ ├── Green.Services.csproj
│ ├── Circles
│ │ ├── IUserCircleService.cs
│ │ ├── ICircleService.cs
│ │ ├── UserCircleService.cs
│ │ └── CircleService.cs
│ ├── Authentication
│ │ ├── IAuthenticationService.cs
│ │ ├── GreenCookieAuthenticationDefaults.cs
│ │ └── CookieAuthenticationService.cs
│ ├── Posts
│ │ ├── IPostService.cs
│ │ └── PostService.cs
│ ├── Votes
│ │ ├── IVoteService.cs
│ │ └── VoteService.cs
│ ├── ImageGallery
│ │ ├── IImageService.cs
│ │ └── ImageService.cs
│ ├── Notifies
│ │ ├── INotifyService.cs
│ │ └── NotifyService.cs
│ ├── Comments
│ │ ├── ICommentService.cs
│ │ └── CommentService.cs
│ ├── Configuration
│ │ ├── SettingExtensions.cs
│ │ └── ISettingService.cs
│ ├── Users
│ │ ├── IUserService.cs
│ │ └── UserService.cs
│ └── Security
│ │ └── IEncryptionService.cs
└── Green.Data
│ ├── Mapping
│ ├── Circles
│ │ ├── CircleMap.cs
│ │ └── UserCircleMap.cs
│ ├── Notifies
│ │ └── NotifyMap.cs
│ ├── Commnets
│ │ └── CommentMap.cs
│ ├── ImageGallery
│ │ └── ImageMap.cs
│ ├── Tasks
│ │ └── TaskMap.cs
│ ├── Configuration
│ │ └── SettingMap.cs
│ ├── Posts
│ │ └── PostMap.cs
│ ├── Votes
│ │ └── VoteMap.cs
│ └── Users
│ │ └── UserMap.cs
│ ├── MigrationGreenDbContextFactory.cs
│ ├── Migrations
│ ├── 20170716144213_AddPasswordProperty.cs
│ └── 20170720175504_AddTaskSettingClass.cs
│ ├── Green.Data.csproj
│ ├── GreenObjectContext.cs
│ ├── DataReaderExtensions.cs
│ └── EfRepository.cs
├── Presentation
├── Green.Web
│ ├── appsettings.json
│ ├── Models
│ │ ├── Circles
│ │ │ └── CreateCircleModel.cs
│ │ └── Users
│ │ │ ├── UpdatePasswordModel.cs
│ │ │ ├── LoginResponseModel.cs
│ │ │ ├── LoginModel.cs
│ │ │ └── UserRegisterModel.cs
│ ├── appsettings.Development.json
│ ├── Program.cs
│ ├── Controllers
│ │ ├── InstallController.cs
│ │ ├── UserController.cs
│ │ └── CircleController.cs
│ ├── Green.Web.csproj
│ └── Startup.cs
└── Green.Web.Framework
│ ├── Green.Web.Framework.csproj
│ ├── Helpers
│ └── UnprocessableEntityObjectResult.cs
│ └── Infrastracture
│ ├── GreenMvcStartup.cs
│ ├── AuthenticationStartup.cs
│ ├── GreenCommonStartup.cs
│ ├── DependencyRegistrar.cs
│ └── Extensions
│ └── ApplicationBuilderExtensions.cs
├── book.json
├── LICENSE
├── README.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── GreenSocialNetwork.sln
└── .gitignore
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-slate
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
2 | markdown: kramdown
--------------------------------------------------------------------------------
/docs/app/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Qolzam/aspnet-core-social-network/HEAD/docs/app/logo.png
--------------------------------------------------------------------------------
/docs/layers/green.web.md:
--------------------------------------------------------------------------------
1 | # Green.Web
2 |
3 | This layer provide REST API and transfer information to user interface.
--------------------------------------------------------------------------------
/docs/layers/green.web.framework.md:
--------------------------------------------------------------------------------
1 | # Green.Web.Framework
2 |
3 | This layer provide some utilities for `Green.Web` layer.
--------------------------------------------------------------------------------
/docs/indev.md:
--------------------------------------------------------------------------------
1 | # In Development
2 |
3 | Project is in development so other features will be added and some features will be changed.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Steps
2 |
3 | ### Expected Result
4 |
5 | ### Actual Result
6 |
7 | ### Version
8 | x.y.z
9 |
10 | ### Testcase
--------------------------------------------------------------------------------
/docs/layers/libraries.md:
--------------------------------------------------------------------------------
1 | # Libraries
2 |
3 | This layer is responsible for working with IO, providing utilities, working with database and processing information.
--------------------------------------------------------------------------------
/docs/layers/green.core.md:
--------------------------------------------------------------------------------
1 | # Green.Core
2 |
3 | Core layer provides `Domain` and some utilities for all layers. This layer has common tools for all layers and it's completely independent of other layers.
--------------------------------------------------------------------------------
/docs/layers/tests.md:
--------------------------------------------------------------------------------
1 | # Tests
2 |
3 | We write test for each layer to know everything works as expected.
4 |
5 | ## API
6 |
7 | Test API.
8 |
9 | ## Services
10 |
11 | Test services.
12 |
13 | ## Controllers
14 |
15 | Test Controllers.
--------------------------------------------------------------------------------
/Libraries/Green.Core/Configuration/ISettings.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Green.Core.Configuration
3 | {
4 | ///
5 | /// Setting interface
6 | ///
7 | public interface ISettings
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/docs/layers/green.data.md:
--------------------------------------------------------------------------------
1 | # Green.Data
2 |
3 | Database Access Layer `Green.Data` builds the query based on received parameters from the `Green.Services` layer and passes it to the data base to execute. And simple return results from the database to `Green.Services`.
4 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "Debug": {
5 | "LogLevel": {
6 | "Default": "Warning"
7 | }
8 | },
9 | "Console": {
10 | "LogLevel": {
11 | "Default": "Warning"
12 | }
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Installation/IInstallationService.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Green.Services.Installation
3 | {
4 | public partial interface IInstallationService
5 | {
6 | void InstallData(string defaultUserEmail = "amir.gholzam@live.com", string defaultUserPassword = "p@55w0rd", bool installSampleData = true);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Models/Circles/CreateCircleModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace Green.Web.Models.Circles
3 | {
4 | public class CreateCircleModel
5 | {
6 | public CreateCircleModel()
7 | {
8 |
9 | }
10 | public string CircleName
11 | {
12 | get;
13 | set;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Tasks/ITask.cs:
--------------------------------------------------------------------------------
1 | namespace Green.Services.Tasks
2 | {
3 | ///
4 | /// Interface that should be implemented by each task
5 | ///
6 | public partial interface ITask
7 | {
8 | ///
9 | /// Executes a task
10 | ///
11 | void Execute();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/book.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": "./docs",
3 | "plugins": [ "theme-api" ],
4 | "pluginsConfig": {
5 | "theme-api": {
6 | "languages": [
7 | {
8 | "lang": "js",
9 | "name": "JavaScript",
10 | "default": true
11 | }
12 | ]
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | },
10 | "Green": {
11 | "SqlConnectionString": "server = 136.243.146.41, 1437; uid = greensou_social; password = rK~a7c73;"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/docs/layers/presentation.md:
--------------------------------------------------------------------------------
1 | # Presentation
2 |
3 | Presentation Layer is the only layer which is directly connected with the user. So in this matter, it’s also a really important layer for marketing purposes. Presentation Layer is mainly used for getting user data and then passing it to `Services` layer for further procedure, and when data is received in `Domain` then it’s responsible to represent `Model` in the appropriate form which user can understand.
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Circles/CircleMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Circles;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
5 |
6 | namespace Green.Data.Mapping.Circles
7 | {
8 | public class CircleMap : IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("Circle");
14 | builder.HasKey(u => u.Id);
15 |
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Notifies/NotifyMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Notifies;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
5 |
6 | namespace Green.Data.Mapping.Notifies
7 | {
8 | public class NotifyMap : IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("Notify");
14 | builder.HasKey(u => u.Id);
15 |
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Commnets/CommentMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Comments;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
5 |
6 | namespace Green.Data.Mapping.Commnets
7 | {
8 | public class CommentMap : IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("Comment");
14 | builder.HasKey(u => u.Id);
15 |
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/ImageGallery/ImageMap.cs:
--------------------------------------------------------------------------------
1 | using Green.Core.Domain.ImageGallery;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
4 |
5 | namespace Green.Data.Mapping.ImageGallery
6 | {
7 | public class ImageMap:IEntityTypeConfiguration
8 | {
9 | public void Configure(EntityTypeBuilder builder)
10 | {
11 | builder.ToTable("Image");
12 | builder.HasKey(c => c.Id);
13 |
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/IStartupTask.cs:
--------------------------------------------------------------------------------
1 | namespace Green.Core.Infrastructure
2 | {
3 | ///
4 | /// Interface which should be implemented by tasks run on startup
5 | ///
6 | public interface IStartupTask
7 | {
8 | ///
9 | /// Executes a task
10 | ///
11 | void Execute();
12 |
13 | ///
14 | /// Gets order of this startup task implementation
15 | ///
16 | int Order { get; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Configuration/GreenConfig.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Green.Core.Configuration
3 | {
4 | ///
5 | /// Represents startup Green configuration parameters
6 | ///
7 | public partial class GreenConfig
8 | {
9 | ///
10 | /// Gets or sets the sql connection string.
11 | ///
12 | /// The sql connection string.
13 | public string SqlConnectionString
14 | {
15 | get;
16 | set;
17 | }
18 |
19 | }
20 | }
--------------------------------------------------------------------------------
/Libraries/Green.Data/MigrationGreenDbContextFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Design;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Microsoft.Extensions.Configuration;
5 | using Autofac;
6 | using System.IO;
7 |
8 | namespace Green.Data
9 | {
10 | public class MigrationGreenDbContextFactory : IDesignTimeDbContextFactory
11 | {
12 |
13 | public GreenObjectContext CreateDbContext(string[] args)
14 | {
15 | return new GreenObjectContext();
16 | }
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore;
2 | using Microsoft.AspNetCore.Hosting;
3 |
4 |
5 | namespace Green.Web
6 | {
7 | public class Program
8 | {
9 | public static void Main(string[] args)
10 | {
11 |
12 | BuildWebHost(args).Run();
13 |
14 |
15 | }
16 |
17 | public static IWebHost BuildWebHost(string[] args) =>
18 | WebHost.CreateDefaultBuilder(args)
19 | .UseStartup()
20 | .Build();
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/docs/layers/green.services.md:
--------------------------------------------------------------------------------
1 | # Green.Services
2 |
3 | This layer works as a bridge between Presentation Layer and data access layer `(Green.Data)`. All the user values received from the presentation layer are being passed to `Services`. The results received from the `Data` are in row data in Data Table format but in `Services` it’s converting into `Object Class`. `Green.Services` is the most important class in the whole architecture because it mainly contains all the business logic of the program. Whenever a user wants to update the business logic of the program only need to update this class library.
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Tasks/TaskMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
4 | using Green.Core.Domain.Tasks;
5 |
6 | namespace Green.Data.Mapping.Tasks
7 | {
8 | public class PostMap : IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("ScheduleTask");
14 | builder.HasKey(t => t.Id);
15 | builder.Property(t => t.Name).IsRequired();
16 | builder.Property(t => t.Type).IsRequired();
17 | }
18 | }
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Summary
2 |
3 | * [Readme](README.md)
4 | * [Motivation](motivation.md)
5 |
6 | ## Layers
7 |
8 | * [Libraries](layers/libraries.md)
9 | * [Green.Core](layers/green.core.md)
10 | * [Green.Data](layers/green.data.md)
11 | * [Green.services](layers/green.services.md)
12 |
13 | * [Presentation](layers/libraries.md)
14 | * [Green.Web](layers/green.core.md)
15 | * [Green.Web.Framework](layers/green.data.md)
16 |
17 | * [Tests](layers/tests.md)
18 | * [In Developing ...](indev.md)
19 |
20 | ## API
21 |
22 | * [Authorization](api/authorization.md)
23 | * [In Developing ...](indev.md)
24 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Configuration/SettingMap.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 | using Green.Core.Domain.Configuration;
4 |
5 | namespace Green.Data.Mapping.Configuration
6 | {
7 | public class SettingMap : IEntityTypeConfiguration
8 | {
9 |
10 | public void Configure(EntityTypeBuilder builder)
11 | {
12 | builder.ToTable("Setting");
13 | builder.HasKey(s => s.Id);
14 | builder.Property(s => s.Name).IsRequired().HasMaxLength(200);
15 | builder.Property(s => s.Value).IsRequired().HasMaxLength(2000);
16 |
17 |
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Presentation/Green.Web.Framework/Green.Web.Framework.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Security/SecuritySettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Green.Core.Configuration;
3 |
4 | namespace Green.Core.Domain.Security
5 | {
6 | public class SecuritySettings : ISettings
7 | {
8 | ///
9 | /// Gets or sets a value indicating whether all pages will be forced to use SSL (no matter of a specified [HttpsRequirementAttribute] attribute)
10 | ///
11 | public bool ForceSslForAllPages { get; set; }
12 |
13 | ///
14 | /// Gets or sets an encryption key
15 | ///
16 | public string EncryptionKey { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/Presentation/Green.Web.Framework/Helpers/UnprocessableEntityObjectResult.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.ModelBinding;
3 | using System;
4 |
5 | namespace Green.Web.Framework.Helpers
6 | {
7 | public class UnprocessableEntityObjectResult : ObjectResult
8 | {
9 | public UnprocessableEntityObjectResult(ModelStateDictionary modelState)
10 | : base(new SerializableError(modelState))
11 | {
12 | if (modelState == null)
13 | {
14 | throw new ArgumentNullException(nameof(modelState));
15 | }
16 | StatusCode = 422;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Posts/PostMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Posts;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
5 |
6 | namespace Green.Data.Mapping.Posts
7 | {
8 | public class PostMap : IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("Post");
14 | builder.HasKey(u => u.Id);
15 |
16 | builder.HasMany(p => p.Comments)
17 | .WithOne(c => c.Post)
18 | .HasForeignKey(c => c.PostId)
19 | .OnDelete(DeleteBehavior.Restrict);
20 | }
21 | }
22 | }
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Green.Services.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Models/Users/UpdatePasswordModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace Green.Web.Models.Users
3 | {
4 | public class UpdatePasswordModel
5 | {
6 | ///
7 | /// Gets or sets the new password.
8 | ///
9 | /// The new password.
10 | public string NewPassword
11 | {
12 | get;
13 | set;
14 | }
15 |
16 | ///
17 | /// Gets or sets the confirm password.
18 | ///
19 | /// The confirm password.
20 | public string ConfirmPassword
21 | {
22 | get;
23 | set;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Extensions/CommonExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace Green.Core.Extensions
5 | {
6 | public static class CommonExtensions
7 | {
8 | public static bool IsNullOrDefault(this T? value) where T : struct
9 | {
10 | return default(T).Equals(value.GetValueOrDefault());
11 | }
12 |
13 | public static string ElText(this XmlNode node, string elName)
14 | {
15 | return node.SelectSingleNode(elName).InnerText;
16 | }
17 |
18 | public static TResult Return(this TInput o, Func evaluator, TResult failureValue)
19 | where TInput : class
20 | {
21 | return o == null ? failureValue : evaluator(o);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Circles/IUserCircleService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Circles;
4 |
5 | namespace Green.Services.Circles
6 | {
7 | public interface IUserCircleService
8 | {
9 | ///
10 | /// Inserts the userUserCircle.
11 | ///
12 | /// UserCircle.
13 | void InsertUserCircle(UserCircle userUserCircle);
14 |
15 | ///
16 | /// Gets all userUserCircles.
17 | ///
18 | /// The all userUserCircles.
19 | IList GetAllUserCircles();
20 |
21 | ///
22 | /// Updates the userUserCircle.
23 | ///
24 | /// UserCircle.
25 | void UpdateUserCircle(UserCircle userUserCircle);
26 | }
27 |
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Circles/UserCircleMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Circles;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
5 |
6 | namespace Green.Data.Mapping.Circles
7 | {
8 | public class NotifyMap : IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("UserCircle");
14 | builder.HasKey(uc => new {uc.CircleId, uc.UserId});
15 |
16 | builder.HasOne(uc => uc.Circle)
17 | .WithMany(c => c.UserCircles)
18 | .HasForeignKey(uc => uc.CircleId);
19 |
20 | builder.HasOne(uc => uc.User)
21 | .WithMany(c => c.UserCircles)
22 | .HasForeignKey(uc => uc.UserId);
23 |
24 | }
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/DependencyManagement/IDependencyRegistrar.cs:
--------------------------------------------------------------------------------
1 | using Autofac;
2 | using Green.Core.Configuration;
3 |
4 | namespace Green.Core.Infrastructure.DependencyManagement
5 | {
6 | ///
7 | /// Dependency registrar interface
8 | ///
9 | public interface IDependencyRegistrar
10 | {
11 | ///
12 | /// Register services and interfaces
13 | ///
14 | /// Container builder
15 | /// Type finder
16 | void Register(ContainerBuilder builder, ITypeFinder typeFinder, GreenConfig config);
17 |
18 | ///
19 | /// Gets order of this dependency registrar implementation
20 | ///
21 | int Order { get; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Configuration/Setting.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | namespace Green.Core.Domain.Configuration
4 | {
5 | ///
6 | /// Represents a setting
7 | ///
8 | public partial class Setting : BaseEntity
9 | {
10 | public Setting() { }
11 |
12 | public Setting(string name, string value) {
13 | this.Name = name;
14 | this.Value = value;
15 | }
16 |
17 | ///
18 | /// Gets or sets the name
19 | ///
20 | public string Name { get; set; }
21 |
22 | ///
23 | /// Gets or sets the value
24 | ///
25 | public string Value { get; set; }
26 |
27 |
28 | public override string ToString()
29 | {
30 | return Name;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Votes/VoteMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Votes;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
5 |
6 | namespace Green.Data.Mapping.Votes
7 | {
8 | public class VoteMap : IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("Vote");
14 | builder.HasKey(v => new {v.PostId ,v.VoterId });
15 |
16 | builder.HasOne(v => v.Post)
17 | .WithMany(p => p.Votes)
18 | .HasForeignKey(v => v.PostId)
19 | .OnDelete(DeleteBehavior.Restrict);
20 |
21 | builder.HasOne(v => v.Voter)
22 | .WithMany(u => u.Votes)
23 | .HasForeignKey(v => v.VoterId)
24 | .OnDelete(DeleteBehavior.Restrict);
25 |
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Authentication/IAuthenticationService.cs:
--------------------------------------------------------------------------------
1 | using Green.Core.Domain.Users;
2 |
3 | namespace Green.Services.Authentication
4 | {
5 | ///
6 | /// Authentication service interface
7 | ///
8 | public partial interface IAuthenticationService
9 | {
10 | ///
11 | /// Sign in
12 | ///
13 | /// User
14 | /// Whether the authentication session is persisted across multiple requests
15 | void SignIn(User user, bool isPersistent);
16 |
17 | ///
18 | /// Sign out
19 | ///
20 | void SignOut();
21 |
22 | ///
23 | /// Get authenticated user
24 | ///
25 | /// User
26 | User GetAuthenticatedUser();
27 | }
28 | }
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/ITypeFinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 |
5 | namespace Green.Core.Infrastructure
6 | {
7 | ///
8 | /// Classes implementing this interface provide information about types
9 | /// to various services in the Green engine.
10 | ///
11 | public interface ITypeFinder
12 | {
13 | IList GetAssemblies();
14 |
15 | IEnumerable FindClassesOfType(Type assignTypeFrom, bool onlyConcreteClasses = true);
16 |
17 | IEnumerable FindClassesOfType(Type assignTypeFrom, IEnumerable assemblies, bool onlyConcreteClasses = true);
18 |
19 | IEnumerable FindClassesOfType(bool onlyConcreteClasses = true);
20 |
21 | IEnumerable FindClassesOfType(IEnumerable assemblies, bool onlyConcreteClasses = true);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Models/Users/LoginResponseModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace Green.Web.Models.Users
3 | {
4 | public class LoginResponseModel
5 | {
6 | ///
7 | /// Gets or sets the key.
8 | ///
9 | /// The key.
10 | public Guid Key
11 | {
12 | get;
13 | set;
14 | }
15 |
16 | ///
17 | /// Gets or sets the email.
18 | ///
19 | /// The email.
20 | public string Email
21 | {
22 | get;
23 | set;
24 | }
25 |
26 | ///
27 | /// Gets or sets the full name.
28 | ///
29 | /// The full name.
30 | public string FullName
31 | {
32 | get;
33 | set;
34 | }
35 |
36 | ///
37 | /// Gets or sets the tag line.
38 | ///
39 | /// The tag line.
40 | public string TagLine
41 | {
42 | get;
43 | set;
44 | }
45 |
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Controllers/InstallController.cs:
--------------------------------------------------------------------------------
1 | using Green.Services.Installation;
2 | using Microsoft.AspNetCore.Mvc;
3 |
4 | // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
5 |
6 | namespace Green.Web.Controllers
7 | {
8 | [Route("api/[controller]")]
9 | public class InstallController : Controller
10 | {
11 |
12 |
13 | #region Fields
14 |
15 | private readonly IInstallationService _installationService;
16 |
17 | #endregion
18 |
19 |
20 | #region Constructor
21 |
22 | public InstallController(IInstallationService installationService)
23 | {
24 | this._installationService = installationService;
25 | }
26 |
27 | #endregion
28 |
29 | #region Methods
30 |
31 | [HttpGet()]
32 | public IActionResult Get()
33 | {
34 |
35 | _installationService.InstallData();
36 |
37 | return Ok();
38 | }
39 |
40 | #endregion
41 |
42 |
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Mapping/Users/UserMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Users;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
5 |
6 | namespace Green.Data.Mapping
7 | {
8 | public class UserMap:IEntityTypeConfiguration
9 | {
10 |
11 | public void Configure(EntityTypeBuilder builder)
12 | {
13 | builder.ToTable("User");
14 | builder.HasKey(u => u.Id);
15 | builder.Property(u => u.UserName).HasMaxLength(1000);
16 | builder.Property(u => u.Email).HasMaxLength(1000);
17 |
18 | builder.HasMany(u => u.Images)
19 | .WithOne(i => i.Owner)
20 | .HasForeignKey(i => i.OwnerUserId);
21 |
22 | builder.HasMany(u => u.Posts)
23 | .WithOne(p => p.Owner)
24 | .HasForeignKey(p => p.OwnerUserId);
25 |
26 | builder.HasMany(u => u.Notifies)
27 | .WithOne(n => n.User)
28 | .HasForeignKey(n => n.UserId);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Models/Users/LoginModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace Green.Web.Models.Users
3 | {
4 | public class LoginModel
5 | {
6 | ///
7 | /// Gets or sets the name of the user.
8 | ///
9 | /// The name of the user.
10 | public string Email
11 | {
12 | get;
13 | set;
14 | }
15 |
16 | ///
17 | /// Gets or sets the password.
18 | ///
19 | /// The password.
20 | public string Password
21 | {
22 | get;
23 | set;
24 | }
25 |
26 | ///
27 | /// Gets or sets a value indicating whether this is persistent.
28 | ///
29 | /// true if the authentication session is persistent across multiple request; otherwise, false.
30 | public bool IsPersistent
31 | {
32 | get;
33 | set;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Amir Movahedi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/ImageGallery/Image.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Users;
3 |
4 | namespace Green.Core.Domain.ImageGallery
5 | {
6 | public class Image:BaseEntity
7 | {
8 | public Image()
9 | {
10 |
11 | }
12 |
13 | ///
14 | /// Gets or sets the image owner identifier.
15 | ///
16 | /// The user identifier.
17 | public int OwnerUserId
18 | {
19 | get;
20 | set;
21 | }
22 |
23 |
24 | ///
25 | /// Gets or sets the name of the image.
26 | ///
27 | /// The name of the image.
28 | public string ImageName
29 | {
30 | get;
31 | set;
32 | }
33 |
34 | #region Navigation properties
35 |
36 | ///
37 | /// Gets or sets the image owner.
38 | ///
39 | /// The owner.
40 | public User Owner
41 | {
42 | get;
43 | set;
44 | }
45 |
46 | #endregion
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Models/Users/UserRegisterModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace Green.Web.Models.Users
3 | {
4 | public class UserRegisterModel
5 | {
6 |
7 | ///
8 | /// Gets or sets the full name.
9 | ///
10 | /// The full name.
11 | public string FullName
12 | {
13 | get;
14 | set;
15 | }
16 |
17 | ///
18 | /// Gets or sets the email.
19 | ///
20 | /// The email.
21 | public string Email
22 | {
23 | get;
24 | set;
25 | }
26 |
27 | ///
28 | /// Gets or sets the password.
29 | ///
30 | /// The password.
31 | public string Password
32 | {
33 | get;
34 | set;
35 | }
36 |
37 | ///
38 | /// Gets or sets the confirm password.
39 | ///
40 | /// The confirm password.
41 | public string ConfirmPassword
42 | {
43 | get;
44 | set;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Circles/ICircleService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Circles;
4 |
5 | namespace Green.Services.Circles
6 | {
7 | public interface ICircleService
8 | {
9 | ///
10 | /// Inserts the circle.
11 | ///
12 | /// Circle.
13 | void InsertCircle(Circle circle);
14 |
15 | ///
16 | /// Gets all circles.
17 | ///
18 | /// The all circles.
19 | IList GetAllCircles();
20 |
21 | ///
22 | /// Gets the circle by identifier.
23 | ///
24 | /// The circle by identifier.
25 | /// ircle identifier.
26 | Circle GetCircleById(int circleId);
27 |
28 | ///
29 | /// Gets the circle by GUID.
30 | ///
31 | /// The circle by GUID.
32 | /// Circle GUID.
33 | Circle GetCircleByGuid(Guid circleGuid);
34 |
35 | ///
36 | /// Updates the circle.
37 | ///
38 | /// Circle.
39 | void UpdateCircle(Circle circle);
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Migrations/20170716144213_AddPasswordProperty.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using System;
3 | using System.Collections.Generic;
4 |
5 | namespace Green.Data.Migrations
6 | {
7 | public partial class AddPasswordProperty : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.AddColumn(
12 | name: "Key",
13 | table: "Vote",
14 | type: "uniqueidentifier",
15 | nullable: false,
16 | defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
17 |
18 | migrationBuilder.AddColumn(
19 | name: "Password",
20 | table: "User",
21 | type: "nvarchar(max)",
22 | nullable: true);
23 | }
24 |
25 | protected override void Down(MigrationBuilder migrationBuilder)
26 | {
27 | migrationBuilder.DropColumn(
28 | name: "Key",
29 | table: "Vote");
30 |
31 | migrationBuilder.DropColumn(
32 | name: "Password",
33 | table: "User");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/IGreenStartup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 |
5 | namespace Green.Core.Infrastructure
6 | {
7 | ///
8 | /// Represents object for the configuring services and middleware on application startup
9 | ///
10 | public interface IGreenStartup
11 | {
12 | ///
13 | /// Add and configure any of the middleware
14 | ///
15 | /// Collection of service descriptors
16 | /// Configuration root of the application
17 | void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration);
18 |
19 | ///
20 | /// Configure the using of added middleware
21 | ///
22 | /// Builder for configuring an application's request pipeline
23 | void Configure(IApplicationBuilder application);
24 |
25 | ///
26 | /// Gets order of this startup configuration implementation
27 | ///
28 | int Order { get; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Posts/IPostService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Posts;
4 |
5 | namespace Green.Services.Posts
6 | {
7 | public interface IPostService
8 | {
9 | ///
10 | /// Inserts the post.
11 | ///
12 | /// Post.
13 | void InsertPost(Post post);
14 |
15 | ///
16 | /// Gets all posts.
17 | ///
18 | /// The all posts.
19 | IList GetAllPosts();
20 |
21 | ///
22 | /// Gets the post by identifier.
23 | ///
24 | /// The post by identifier.
25 | /// ircle identifier.
26 | Post GetPostById(int postId);
27 |
28 | ///
29 | /// Gets the post by GUID.
30 | ///
31 | /// The post by GUID.
32 | /// Post GUID.
33 | Post GetPostByGuid(Guid postGuid);
34 |
35 | ///
36 | /// Gets the post by email.
37 | ///
38 | /// The post by email.
39 | /// Email.
40 | Post GetPostByEmail(string email);
41 |
42 | ///
43 | /// Updates the post.
44 | ///
45 | /// Post.
46 | void UpdatePost(Post post);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Votes/IVoteService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Votes;
4 |
5 | namespace Green.Services.Votes
6 | {
7 | public interface IVoteService
8 | {
9 | ///
10 | /// Inserts the vote.
11 | ///
12 | /// Vote.
13 | void InsertVote(Vote vote);
14 |
15 | ///
16 | /// Gets all votes.
17 | ///
18 | /// The all votes.
19 | IList GetAllVotes();
20 |
21 | ///
22 | /// Gets the vote by identifier.
23 | ///
24 | /// The vote by identifier.
25 | /// ircle identifier.
26 | Vote GetVoteById(int voteId);
27 |
28 | ///
29 | /// Gets the vote by GUID.
30 | ///
31 | /// The vote by GUID.
32 | /// Vote GUID.
33 | Vote GetVoteByGuid(Guid voteGuid);
34 |
35 | ///
36 | /// Gets the vote by email.
37 | ///
38 | /// The vote by email.
39 | /// Email.
40 | Vote GetVoteByEmail(string email);
41 |
42 | ///
43 | /// Updates the vote.
44 | ///
45 | /// Vote.
46 | void UpdateVote(Vote vote);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/ImageGallery/IImageService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.ImageGallery;
4 |
5 | namespace Green.Services.ImageGallery
6 | {
7 | public interface IImageService
8 | {
9 | ///
10 | /// Inserts the image.
11 | ///
12 | /// Image.
13 | void InsertImage(Image image);
14 |
15 | ///
16 | /// Gets all images.
17 | ///
18 | /// The all images.
19 | IList GetAllImages();
20 |
21 | ///
22 | /// Gets the image by identifier.
23 | ///
24 | /// The image by identifier.
25 | /// ircle identifier.
26 | Image GetImageById(int imageId);
27 |
28 | ///
29 | /// Gets the image by GUID.
30 | ///
31 | /// The image by GUID.
32 | /// Image GUID.
33 | Image GetImageByGuid(Guid imageGuid);
34 |
35 | ///
36 | /// Gets the image by email.
37 | ///
38 | /// The image by email.
39 | /// Email.
40 | Image GetImageByEmail(string email);
41 |
42 | ///
43 | /// Updates the image.
44 | ///
45 | /// Image.
46 | void UpdateImage(Image image);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/docs/motivation.md:
--------------------------------------------------------------------------------
1 | # Motivation
2 |
3 | In this project we follow [loosely coupled](https://en.wikipedia.org/wiki/Loose_coupling) system principle with the idea each part of this project be independent from others. For example if you want to use [frontend](https://en.wikipedia.org/wiki/Front_and_back_ends) you are not depend on [backend](https://en.wikipedia.org/wiki/Front_and_back_ends) as you can use Firbase so easy which we have provided in this project. You also can use any kind of backend such as php, python, javascript and etc, completely independent of frontend or you can use [ASP.NET Core 2](https://docs.microsoft.com/en-us/dotnet/core/) backend that we provided in this project.
4 | As my target in this project, I've intended to build a social network with features of new and powerful web technologies such as [React](https://facebook.github.io/react/) as a front-end tool in [React Social Network](https://github.com/Qolzam/react-social-network) project and build a powerful backend by [ASP.NET Core 2](https://docs.microsoft.com/en-us/dotnet/core/) with its cool new features in [ASP.NET Core Social Network](https://github.com/Qolzam/aspnet-core-social-network). I also use [React Native](https://facebook.github.io/react-native/) to build a powerful mobile social app in [React Mobile Social](https://github.com/Qolzam/react-mobile-social). All cool new features are providing as an open source project under MIT LICENSE and it's so great ;).
--------------------------------------------------------------------------------
/Libraries/Green.Services/Notifies/INotifyService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Notifies;
4 |
5 | namespace Green.Services.Notifies
6 | {
7 | public interface INotifyService
8 | {
9 | ///
10 | /// Inserts the notify.
11 | ///
12 | /// Notify.
13 | void InsertNotify(Notify notify);
14 |
15 | ///
16 | /// Gets all notifys.
17 | ///
18 | /// The all notifys.
19 | IList GetAllNotifys();
20 |
21 | ///
22 | /// Gets the notify by identifier.
23 | ///
24 | /// The notify by identifier.
25 | /// ircle identifier.
26 | Notify GetNotifyById(int notifyId);
27 |
28 | ///
29 | /// Gets the notify by GUID.
30 | ///
31 | /// The notify by GUID.
32 | /// Notify GUID.
33 | Notify GetNotifyByGuid(Guid notifyGuid);
34 |
35 | ///
36 | /// Gets the notify by email.
37 | ///
38 | /// The notify by email.
39 | /// Email.
40 | Notify GetNotifyByEmail(string email);
41 |
42 | ///
43 | /// Updates the notify.
44 | ///
45 | /// Notify.
46 | void UpdateNotify(Notify notify);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Comments/ICommentService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Comments;
4 |
5 | namespace Green.Services.Comments
6 | {
7 | public interface ICommentService
8 | {
9 | ///
10 | /// Inserts the comment.
11 | ///
12 | /// Comment.
13 | void InsertComment(Comment comment);
14 |
15 | ///
16 | /// Gets all comments.
17 | ///
18 | /// The all comments.
19 | IList GetAllComments();
20 |
21 | ///
22 | /// Gets the comment by identifier.
23 | ///
24 | /// The comment by identifier.
25 | /// ircle identifier.
26 | Comment GetCommentById(int commentId);
27 |
28 | ///
29 | /// Gets the comment by GUID.
30 | ///
31 | /// The comment by GUID.
32 | /// Comment GUID.
33 | Comment GetCommentByGuid(Guid commentGuid);
34 |
35 | ///
36 | /// Gets the comment by email.
37 | ///
38 | /// The comment by email.
39 | /// Email.
40 | Comment GetCommentByEmail(string email);
41 |
42 | ///
43 | /// Updates the comment.
44 | ///
45 | /// Comment.
46 | void UpdateComment(Comment comment);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Green.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Configuration/SettingExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using System.Reflection;
4 | using Green.Core.Configuration;
5 |
6 | namespace Green.Services.Configuration
7 | {
8 | public static class SettingExtensions
9 | {
10 | ///
11 | /// Get setting key
12 | ///
13 | /// Type
14 | /// Property type
15 | /// Entity
16 | /// Key selector
17 | /// Key
18 | public static string GetSettingKey(this T entity,
19 | Expression> keySelector)
20 | where T : ISettings, new()
21 | {
22 | var member = keySelector.Body as MemberExpression;
23 | if (member == null)
24 | {
25 | throw new ArgumentException(string.Format(
26 | "Expression '{0}' refers to a method, not a property.",
27 | keySelector));
28 | }
29 |
30 | var propInfo = member.Member as PropertyInfo;
31 | if (propInfo == null)
32 | {
33 | throw new ArgumentException(string.Format(
34 | "Expression '{0}' refers to a field, not a property.",
35 | keySelector));
36 | }
37 |
38 | var key = typeof(T).Name + "." + propInfo.Name;
39 | return key;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Circles/UserCircle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Users;
3 |
4 | namespace Green.Core.Domain.Circles
5 | {
6 | public class UserCircle
7 | {
8 | ///
9 | /// Gets or sets a value indicating whether this is owner.
10 | ///
11 | /// true if is owner; otherwise, false.
12 | public bool IsOwner
13 | {
14 | get;
15 | set;
16 | }
17 |
18 | ///
19 | /// Gets or sets the user identifier.
20 | ///
21 | /// The user identifier.
22 | public int UserId
23 | {
24 | get;
25 | set;
26 | }
27 |
28 | ///
29 | /// Gets or sets the circle identifier.
30 | ///
31 | /// The circle identifier.
32 | public int CircleId
33 | {
34 | get;
35 | set;
36 | }
37 |
38 | #region Navigation properties
39 |
40 | ///
41 | /// Gets or sets the user.
42 | ///
43 | /// The user.
44 | public User User
45 | {
46 | get;
47 | set;
48 | }
49 |
50 | ///
51 | /// Gets or sets the circle.
52 | ///
53 | /// The circle.
54 | public Circle Circle
55 | {
56 | get;
57 | set;
58 | }
59 |
60 | #endregion
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Presentation/Green.Web.Framework/Infrastracture/GreenMvcStartup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Green.Core.Infrastructure;
5 | using Green.Web.Framework.Infrastructure.Extensions;
6 |
7 | namespace Green.Web.Framework.Infrastructure
8 | {
9 | ///
10 | /// Represents object for the configuring MVC on application startup
11 | ///
12 | public class GreenMvcStartup : IGreenStartup
13 | {
14 | ///
15 | /// Add and configure any of the middleware
16 | ///
17 | /// Collection of service descriptors
18 | /// Configuration root of the application
19 | public void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration)
20 | {
21 |
22 | //add and configure MVC feature
23 | services.AddGreenMvc();
24 | }
25 |
26 | ///
27 | /// Configure the using of added middleware
28 | ///
29 | /// Builder for configuring an application's request pipeline
30 | public void Configure(IApplicationBuilder application)
31 | {
32 | //MVC
33 | application.UseGreenMvc();
34 | }
35 |
36 | ///
37 | /// Gets order of this startup configuration implementation
38 | ///
39 | public int Order
40 | {
41 | //MVC should be loaded last
42 | get { return 1000; }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Tasks/IScheduleTaskService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Green.Core.Domain.Tasks;
3 |
4 | namespace Green.Services.Tasks
5 | {
6 | ///
7 | /// Task service interface
8 | ///
9 | public partial interface IScheduleTaskService
10 | {
11 | ///
12 | /// Deletes a task
13 | ///
14 | /// Task
15 | void DeleteTask(ScheduleTask task);
16 |
17 | ///
18 | /// Gets a task
19 | ///
20 | /// Task identifier
21 | /// Task
22 | ScheduleTask GetTaskById(int taskId);
23 |
24 | ///
25 | /// Gets a task by its type
26 | ///
27 | /// Task type
28 | /// Task
29 | ScheduleTask GetTaskByType(string type);
30 |
31 | ///
32 | /// Gets all tasks
33 | ///
34 | /// A value indicating whether to show hidden records
35 | /// Tasks
36 | IList GetAllTasks(bool showHidden = false);
37 |
38 | ///
39 | /// Inserts a task
40 | ///
41 | /// Task
42 | void InsertTask(ScheduleTask task);
43 |
44 | ///
45 | /// Updates the task
46 | ///
47 | /// Task
48 | void UpdateTask(ScheduleTask task);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Data/IRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace Green.Core.Data
5 | {
6 | ///
7 | /// Repository
8 | ///
9 | public partial interface IRepository where T : class
10 | {
11 | ///
12 | /// Get entity by identifier
13 | ///
14 | /// Identifier
15 | /// Entity
16 | T GetById(object id);
17 |
18 | ///
19 | /// Insert entity
20 | ///
21 | /// Entity
22 | void Insert(T entity);
23 |
24 | ///
25 | /// Insert entities
26 | ///
27 | /// Entities
28 | void Insert(IEnumerable entities);
29 |
30 | ///
31 | /// Update entity
32 | ///
33 | /// Entity
34 | void Update(T entity);
35 |
36 | ///
37 | /// Update entities
38 | ///
39 | /// Entities
40 | void Update(IEnumerable entities);
41 |
42 | ///
43 | /// Delete entity
44 | ///
45 | /// Entity
46 | void Delete(T entity);
47 |
48 | ///
49 | /// Delete entities
50 | ///
51 | /// Entities
52 | void Delete(IEnumerable entities);
53 |
54 | ///
55 | /// Gets a table
56 | ///
57 | IQueryable Table { get; }
58 |
59 | ///
60 | /// Gets a table with "no tracking" enabled (EF feature) Use it only when you load record(s) only for read-only operations
61 | ///
62 | IQueryable TableNoTracking { get; }
63 | }
64 | }
--------------------------------------------------------------------------------
/Presentation/Green.Web.Framework/Infrastracture/AuthenticationStartup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Green.Core.Infrastructure;
5 | using Green.Web.Framework.Infrastructure.Extensions;
6 |
7 | namespace Green.Web.Framework.Infrastructure
8 | {
9 | ///
10 | /// Represents object for the configuring authentication middleware on application startup
11 | ///
12 | public class AuthenticationStartup : IGreenStartup
13 | {
14 | ///
15 | /// Add and configure any of the middleware
16 | ///
17 | /// Collection of service descriptors
18 | /// Configuration root of the application
19 | public void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration)
20 | {
21 | services.AddGreenAuthentication();
22 | }
23 |
24 | ///
25 | /// Configure the using of added middleware
26 | ///
27 | /// Builder for configuring an application's request pipeline
28 | public void Configure(IApplicationBuilder application)
29 | {
30 | //configure authentication
31 | application.UseGreenAuthentication();
32 | }
33 |
34 | ///
35 | /// Gets order of this startup configuration implementation
36 | ///
37 | public int Order
38 | {
39 | //authentication should be loaded before MVC
40 | get { return 500; }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/GreenObjectContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 | using Green.Core;
5 | using Green.Core.Configuration;
6 | using Green.Core.Infrastructure;
7 | using Microsoft.EntityFrameworkCore;
8 |
9 | namespace Green.Data
10 | {
11 | ///
12 | /// Object context
13 | ///
14 | public class GreenObjectContext : DbContext
15 | {
16 |
17 |
18 | #region Constructor
19 |
20 | public GreenObjectContext(DbContextOptions options)
21 | :base(options)
22 | {
23 |
24 | }
25 |
26 | public GreenObjectContext():base(){
27 |
28 | }
29 |
30 | #endregion
31 |
32 | #region Utilities
33 |
34 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
35 | {
36 | // optionsBuilder.UseSqlServer("");
37 |
38 | }
39 |
40 | protected override void OnModelCreating(ModelBuilder modelBuilder)
41 | {
42 |
43 | var interfaceType = typeof(IEntityTypeConfiguration<>);
44 | var types = Assembly.GetExecutingAssembly()
45 | .GetTypes();
46 | foreach (var type in types)
47 | {
48 | string name = type.FullName;
49 |
50 | foreach (var intType in type.GetInterfaces())
51 | {
52 | if (intType.IsGenericType && intType.GetGenericTypeDefinition() == interfaceType)
53 | {
54 | dynamic configurationInstance = Activator.CreateInstance(type);
55 | modelBuilder.ApplyConfiguration(configurationInstance);
56 | break;
57 | }
58 | }
59 |
60 | }
61 |
62 |
63 | base.OnModelCreating(modelBuilder);
64 | }
65 |
66 | #endregion
67 |
68 |
69 | }
70 | }
--------------------------------------------------------------------------------
/Presentation/Green.Web/Controllers/UserController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Green.Core.Domain.Users;
6 | using Green.Services.Users;
7 | using Microsoft.AspNetCore.Hosting.Internal;
8 | using Microsoft.AspNetCore.Mvc;
9 |
10 | // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
11 |
12 | namespace Green.Web.Controllers
13 | {
14 | [Route("api/[controller]")]
15 | public class UserController : Controller
16 | {
17 |
18 | #region Fields
19 |
20 | private readonly IUserService _userService;
21 |
22 | #endregion
23 |
24 | #region Constructor
25 |
26 | public UserController(IUserService userService)
27 | {
28 | this._userService = userService;
29 | }
30 |
31 | #endregion
32 |
33 | #region Methods
34 |
35 | [HttpGet]
36 | public IActionResult Get()
37 | {
38 |
39 | string startupPath = new HostingEnvironment().ContentRootPath;
40 |
41 | string startupPath2 = Environment.CurrentDirectory;
42 |
43 | var user = new User()
44 | {
45 | Active = true,
46 | CannotLoginUntilDateUtc = DateTime.UtcNow,
47 | CreatedOnUtc = DateTime.UtcNow,
48 | Deleted = false,
49 | Email = "email.com",
50 | FailedLoginAttempts = 0,
51 | LastActivityDateUtc = DateTime.UtcNow,
52 | LastIpAddress = "09.3.2.2",
53 | LastLoginDateUtc = DateTime.UtcNow,
54 | UserName = "new user",
55 | FullName = "user"
56 | };
57 |
58 | var users = _userService.GetAllUsers();
59 | return Ok(new {users, startupPath, startupPath2});
60 | }
61 |
62 | #endregion
63 |
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Green.Web.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 | aspnet-Green.Web-42ADAEFA-BBD2-4D0D-AE7B-84C946D04EBC
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Comments/Comment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Posts;
3 | using Green.Core.Domain.Users;
4 |
5 | namespace Green.Core.Domain.Comments
6 | {
7 | public class Comment:BaseEntity
8 | {
9 |
10 | ///
11 | /// Gets or sets the text of comment.
12 | ///
13 | /// The text.
14 | public string Text
15 | {
16 | get;
17 | set;
18 | }
19 |
20 | ///
21 | /// Gets or sets the score.
22 | ///
23 | /// The score.
24 | public int Score
25 | {
26 | get;
27 | set;
28 | }
29 |
30 | ///
31 | /// Gets or sets the post identifier.
32 | ///
33 | /// The post identifier.
34 | public int PostId
35 | {
36 | get;
37 | set;
38 | }
39 |
40 | ///
41 | /// Gets or sets the user identifier.
42 | ///
43 | /// The user identifier.
44 | public int UserId
45 | {
46 | get;
47 | set;
48 | }
49 |
50 |
51 | #region Navigation properties
52 |
53 | ///
54 | /// Gets or sets the post.
55 | ///
56 | /// The post.
57 | public Post Post
58 | {
59 | get;
60 | set;
61 | }
62 |
63 | ///
64 | /// Gets or sets the user who write the comment.
65 | ///
66 | /// The user.
67 | public User User
68 | {
69 | get;
70 | set;
71 | }
72 |
73 | #endregion
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Users/IUserService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Users;
4 |
5 | namespace Green.Services.Users
6 | {
7 | public interface IUserService
8 | {
9 | ///
10 | /// Inserts the user.
11 | ///
12 | /// User.
13 | void InsertUser(User user);
14 |
15 | ///
16 | /// Gets all users.
17 | ///
18 | /// The all users.
19 | IList GetAllUsers();
20 |
21 | ///
22 | /// Gets the user by identifier.
23 | ///
24 | /// The user by identifier.
25 | /// User identifier.
26 | User GetUserById(int userId);
27 |
28 | ///
29 | /// Gets the user by GUID.
30 | ///
31 | /// The user by GUID.
32 | /// User GUID.
33 | User GetUserByGuid(Guid userGuid);
34 |
35 | ///
36 | /// Gets the user by email.
37 | ///
38 | /// The user by email.
39 | /// Email.
40 | User GetUserByEmail(string email);
41 |
42 | ///
43 | /// Updates the user.
44 | ///
45 | /// User.
46 | void UpdateUser(User user);
47 |
48 | ///
49 | /// If email exist.
50 | ///
51 | /// true, if the email is exist, false otherwise.
52 | /// Email.
53 | bool EmailExist(string email);
54 |
55 |
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Circles/Circle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Users;
4 |
5 | namespace Green.Core.Domain.Circles
6 | {
7 | public class Circle : BaseEntity
8 | {
9 |
10 | private ICollection _userCircles;
11 |
12 |
13 | ///
14 | /// Gets or sets the name of the circle.
15 | ///
16 | /// The name of the circle.
17 | public string CircleName
18 | {
19 | get;
20 | set;
21 | }
22 |
23 | ///
24 | /// Gets or sets a value indicating whether this is system.
25 | ///
26 | /// true if is system; otherwise, false.
27 | public bool IsSystem
28 | {
29 | get;
30 | set;
31 | }
32 |
33 | ///
34 | /// Gets or sets the followers counter.
35 | ///
36 | /// The followers counter.
37 | public int FollowersCounter
38 | {
39 | get;
40 | set;
41 | }
42 |
43 | ///
44 | /// Gets or sets the following counter.
45 | ///
46 | /// The following counter.
47 | public int FollowingCounter
48 | {
49 | get;
50 | set;
51 | }
52 |
53 | #region Navigation Properties
54 |
55 | ///
56 | /// Gets or sets the user circles.
57 | ///
58 | /// The user circles.
59 | public virtual ICollection UserCircles
60 | {
61 | get { return _userCircles ?? (_userCircles = new List()); }
62 | protected set { _userCircles = value; }
63 |
64 | }
65 |
66 | #endregion
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/EngineContext.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | namespace Green.Core.Infrastructure
4 | {
5 | ///
6 | /// Provides access to the singleton instance of the Green engine.
7 | ///
8 | public class EngineContext
9 | {
10 | #region Methods
11 |
12 | ///
13 | /// Create a static instance of the Green engine.
14 | ///
15 | [MethodImpl(MethodImplOptions.Synchronized)]
16 | public static IEngine Create()
17 | {
18 | //create GreenEngine as engine
19 | if (Singleton.Instance == null)
20 | Singleton.Instance = new GreenEngine();
21 |
22 | return Singleton.Instance;
23 | }
24 |
25 | ///
26 | /// Sets the static engine instance to the supplied engine. Use this method to supply your own engine implementation.
27 | ///
28 | /// The engine to use.
29 | /// Only use this method if you know what you're doing.
30 | public static void Replace(IEngine engine)
31 | {
32 | Singleton.Instance = engine;
33 | }
34 |
35 | #endregion
36 |
37 | #region Properties
38 |
39 | ///
40 | /// Gets the singleton Green engine used to access Green services.
41 | ///
42 | public static IEngine Current
43 | {
44 | get
45 | {
46 | if (Singleton.Instance == null)
47 | {
48 | Create();
49 | }
50 |
51 | return Singleton.Instance; }
52 | }
53 |
54 | #endregion
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Circles/UserCircleService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.Circles;
6 |
7 | namespace Green.Services.Circles
8 | {
9 | public class UserCircleService: IUserCircleService
10 | {
11 | #region Fields
12 |
13 | private readonly IRepository _userCircleRepository;
14 |
15 | #endregion
16 |
17 | #region Constructor
18 |
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | /// UserCircle repository.
24 | public UserCircleService(IRepository userCircleRepository)
25 | {
26 | this._userCircleRepository = userCircleRepository;
27 | }
28 |
29 | #endregion
30 |
31 | #region Methods
32 |
33 | ///
34 | /// Inserts the userCircle.
35 | ///
36 | /// UserCircle.
37 | public void InsertUserCircle(UserCircle userCircle)
38 | {
39 | if (userCircle == null)
40 | throw new ArgumentNullException(nameof(userCircle));
41 |
42 |
43 | _userCircleRepository.Insert(userCircle);
44 | }
45 |
46 | ///
47 | /// Gets all userCircles.
48 | ///
49 | /// The all userCircles.
50 | public IList GetAllUserCircles()
51 | {
52 | return _userCircleRepository.Table.ToList();
53 | }
54 |
55 | ///
56 | /// Updates the userCircle.
57 | ///
58 | /// UserCircle.
59 | public void UpdateUserCircle(UserCircle userCircle)
60 | {
61 | if (userCircle == null)
62 | throw new ArgumentNullException(nameof(userCircle));
63 |
64 | _userCircleRepository.Update(userCircle);
65 | }
66 |
67 |
68 | #endregion
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Security/IEncryptionService.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Green.Services.Security
3 | {
4 | public interface IEncryptionService
5 | {
6 | ///
7 | /// Create salt key
8 | ///
9 | /// Key size
10 | /// Salt key
11 | string CreateSaltKey(int size);
12 |
13 | ///
14 | /// Create a password hash
15 | ///
16 | /// {assword
17 | /// Salk key
18 | /// Password format (hash algorithm)
19 | /// Password hash
20 | string CreatePasswordHash(string password, string saltkey, string passwordFormat = "SHA1");
21 |
22 | ///
23 | /// Create a data hash
24 | ///
25 | /// The data for calculating the hash
26 | /// Hash algorithm
27 | /// Data hash
28 | string CreateHash(byte [] data, string hashAlgorithm = "SHA1");
29 |
30 | ///
31 | /// Encrypt text
32 | ///
33 | /// Text to encrypt
34 | /// Encryption private key
35 | /// Encrypted text
36 | string EncryptText(string plainText, string encryptionPrivateKey = "");
37 |
38 | ///
39 | /// Decrypt text
40 | ///
41 | /// Text to decrypt
42 | /// Encryption private key
43 | /// Decrypted text
44 | string DecryptText(string cipherText, string encryptionPrivateKey = "");
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Authentication/GreenCookieAuthenticationDefaults.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 |
3 | namespace Green.Services.Authentication
4 | {
5 | ///
6 | /// Default values related to cookie-based authentication handler
7 | ///
8 | public static class GreenCookieAuthenticationDefaults
9 | {
10 | ///
11 | /// The default value used for authentication scheme
12 | ///
13 | public const string AuthenticationScheme = "Authentication";
14 |
15 | ///
16 | /// The default value used for external authentication scheme
17 | ///
18 | public const string ExternalAuthenticationScheme = "ExternalAuthentication";
19 |
20 | ///
21 | /// The prefix used to provide a default cookie name
22 | ///
23 | public static readonly string CookiePrefix = ".Green.";
24 |
25 | ///
26 | /// The issuer that should be used for any claims that are created
27 | ///
28 | public static readonly string ClaimsIssuer = "greenSocial";
29 |
30 | ///
31 | /// The default value for the login path
32 | ///
33 | public static readonly PathString LoginPath = new PathString("/login");
34 |
35 | ///
36 | /// The default value used for the logout path
37 | ///
38 | public static readonly PathString LogoutPath = new PathString("/logout");
39 |
40 | ///
41 | /// The default value for the access denied path
42 | ///
43 | public static readonly PathString AccessDeniedPath = new PathString("/page-not-found");
44 |
45 | ///
46 | /// The default value of the return url parameter
47 | ///
48 | public static readonly string ReturnUrlParameter = "";
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Votes/Vote.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Posts;
3 | using Green.Core.Domain.Users;
4 |
5 | namespace Green.Core.Domain.Votes
6 | {
7 | public class Vote
8 | {
9 |
10 | public Vote()
11 | {
12 | this.CreatedDateOnUtc = DateTime.UtcNow;
13 | this.Key = Guid.NewGuid();
14 |
15 | }
16 |
17 | ///
18 | /// Gets or sets the key.
19 | ///
20 | /// The key.
21 | public Guid Key
22 | {
23 | get;
24 | set;
25 | }
26 |
27 | ///
28 | /// Gets or sets the created date on UTC.
29 | ///
30 | /// The created date on UTC.
31 | public DateTime CreatedDateOnUtc
32 | {
33 | get;
34 | set;
35 | }
36 |
37 | ///
38 | /// Gets or sets the post identifier.
39 | ///
40 | /// The post identifier.
41 | public int PostId
42 | {
43 | get;
44 | set;
45 | }
46 |
47 | ///
48 | /// Gets or sets the voter identifier.
49 | ///
50 | /// The voter identifier.
51 | public int VoterId
52 | {
53 | get;
54 | set;
55 | }
56 |
57 | #region Navigation properties
58 |
59 | ///
60 | /// Gets or sets the post.
61 | ///
62 | /// The post.
63 | public Post Post
64 | {
65 | get;
66 | set;
67 | }
68 |
69 | ///
70 | /// Gets or sets the voter.
71 | ///
72 | /// The voter.
73 | public User Voter
74 | {
75 | get;
76 | set;
77 | }
78 |
79 | #endregion
80 |
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Notifies/Notify.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Users;
3 |
4 | namespace Green.Core.Domain.Notifies
5 | {
6 | public class Notify : BaseEntity
7 | {
8 |
9 |
10 | ///
11 | /// Gets or sets the description.
12 | ///
13 | /// The description.
14 | public string Description
15 | {
16 | get;
17 | set;
18 | }
19 |
20 | ///
21 | /// Gets or sets a value indicating whether this is seen.
22 | ///
23 | /// true if is seen; otherwise, false.
24 | public bool IsSeen
25 | {
26 | get;
27 | set;
28 | }
29 |
30 | ///
31 | /// Gets or sets the URL to mention a page.
32 | ///
33 | /// The URL.
34 | public string Url
35 | {
36 | get;
37 | set;
38 | }
39 |
40 | ///
41 | /// Gets or sets a value indicating whether this is notifier.
42 | ///
43 | /// true if is notifier; otherwise, false.
44 | public bool IsNotifier
45 | {
46 | get;
47 | set;
48 | }
49 |
50 | ///
51 | /// Gets or sets the user identifier.
52 | ///
53 | /// The user identifier.
54 | public int UserId
55 | {
56 | get;
57 | set;
58 | }
59 |
60 | #region Navigation properties
61 |
62 | ///
63 | /// Gets or sets the user.
64 | ///
65 | /// The user.
66 | public User User
67 | {
68 | get;
69 | set;
70 | }
71 |
72 | #endregion
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Installation/InstallationService.cs:
--------------------------------------------------------------------------------
1 | using Green.Core;
2 | using Green.Core.Data;
3 | using Green.Core.Domain.Security;
4 | using Green.Core.Domain.Tasks;
5 | using Green.Core.Infrastructure;
6 | using Green.Services.Configuration;
7 | using Microsoft.AspNetCore.Hosting;
8 |
9 |
10 | namespace Green.Services.Installation
11 | {
12 | public partial class InstallationService : IInstallationService
13 | {
14 | #region Fields
15 |
16 | private readonly IRepository _scheduleTaskRepository;
17 | private readonly IWebHelper _webHelper;
18 | private readonly IHostingEnvironment _hostingEnvironment;
19 |
20 | #endregion
21 |
22 | #region Ctor
23 |
24 | public InstallationService(
25 | IRepository scheduleTaskRepository,
26 | IWebHelper webHelper,
27 | IHostingEnvironment hostingEnvironment)
28 | {
29 | this._scheduleTaskRepository = scheduleTaskRepository;
30 | this._webHelper = webHelper;
31 | this._hostingEnvironment = hostingEnvironment;
32 | }
33 |
34 | #endregion
35 |
36 |
37 |
38 |
39 | #region Methods
40 |
41 | protected virtual void InstallSettings(){
42 |
43 | var settingService = EngineContext.Current.Resolve();
44 |
45 | settingService.SaveSetting(new SecuritySettings
46 | {
47 | ForceSslForAllPages = false,
48 | EncryptionKey = CommonHelper.GenerateRandomDigitCode(16)
49 | });
50 | }
51 |
52 | public virtual void InstallData(string defaultUserEmail = "amir.gholzam@live.com",
53 | string defaultUserPassword = "p@55w0rd", bool installSampleData = true)
54 | {
55 |
56 |
57 | InstallSettings();
58 |
59 | if (installSampleData)
60 | {
61 |
62 |
63 | }
64 | }
65 |
66 | #endregion
67 | }
68 | }
--------------------------------------------------------------------------------
/Presentation/Green.Web/Startup.cs:
--------------------------------------------------------------------------------
1 | using Green.Data;
2 | using Microsoft.AspNetCore.Builder;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.EntityFrameworkCore;
6 | using Green.Web.Framework.Infrastructure.Extensions;
7 | using System;
8 | using Microsoft.Extensions.Configuration;
9 |
10 | namespace Green.Web
11 | {
12 | public class Startup
13 | {
14 |
15 | public Startup(IHostingEnvironment env)
16 | {
17 | var builder = new ConfigurationBuilder()
18 | .SetBasePath(env.ContentRootPath)
19 | .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
20 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
21 |
22 | if (env.IsDevelopment())
23 | {
24 | // For more details on using the user secret store see https://go.microsoft.com/fwlink/?LinkID=532709
25 | builder.AddUserSecrets();
26 | }
27 |
28 | builder.AddEnvironmentVariables();
29 | Configuration = builder.Build();
30 | }
31 |
32 | public IConfigurationRoot Configuration { get; }
33 |
34 |
35 | // This method gets called by the runtime. Use this method to add services to the container.
36 | public IServiceProvider ConfigureServices(IServiceCollection services)
37 | {
38 | return services.ConfigureApplicationServices(Configuration);
39 | }
40 |
41 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
42 | public void Configure(IApplicationBuilder app, IHostingEnvironment env)
43 | {
44 | using (var serviceScope = app.ApplicationServices.GetService().CreateScope())
45 | {
46 | var context = serviceScope.ServiceProvider.GetRequiredService();
47 | context.Database.Migrate();
48 |
49 | }
50 |
51 | app.ConfigureRequestPipeline();
52 |
53 |
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Votes/VoteService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.Votes;
6 |
7 | namespace Green.Services.Votes
8 | {
9 | public class VoteService
10 | {
11 | #region Fields
12 |
13 | private readonly IRepository _voteRepository;
14 |
15 | #endregion
16 |
17 | #region Constructor
18 |
19 | ///
20 | /// Initializes a new instance of the class.
21 | ///
22 | /// Vote repository.
23 | public VoteService(IRepository voteRepository)
24 | {
25 | this._voteRepository = voteRepository;
26 | }
27 |
28 | #endregion
29 |
30 | #region Methods
31 |
32 | ///
33 | /// Inserts the vote.
34 | ///
35 | /// Vote.
36 | public void InsertVote(Vote vote)
37 | {
38 | if (vote == null)
39 | throw new ArgumentNullException(nameof(vote));
40 |
41 |
42 | _voteRepository.Insert(vote);
43 | }
44 |
45 | ///
46 | /// Gets all votes.
47 | ///
48 | /// The all votes.
49 | public IList GetAllVotes()
50 | {
51 | return _voteRepository.Table.ToList();
52 | }
53 |
54 | ///
55 | /// Gets the vote by GUID.
56 | ///
57 | /// The vote by GUID.
58 | /// Vote GUID.
59 | public Vote GetVoteByGuid(Guid voteGuid)
60 | {
61 | if (voteGuid == Guid.Empty)
62 | return null;
63 |
64 | var query = from v in _voteRepository.Table
65 | where v.Key == voteGuid
66 | orderby v.CreatedDateOnUtc
67 | select v;
68 | var vote = query.FirstOrDefault();
69 |
70 | return vote;
71 | }
72 |
73 |
74 | ///
75 | /// Updates the vote.
76 | ///
77 | /// Vote.
78 | public void UpdateVote(Vote vote)
79 | {
80 | if (vote == null)
81 | throw new ArgumentNullException(nameof(vote));
82 |
83 | _voteRepository.Update(vote);
84 | }
85 |
86 |
87 | #endregion
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/WebAppTypeFinder.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection;
3 | using Microsoft.Extensions.PlatformAbstractions;
4 |
5 | namespace Green.Core.Infrastructure
6 | {
7 | ///
8 | /// Provides information about types in the current web application.
9 | /// Optionally this class can look at all assemblies in the bin folder.
10 | ///
11 | public class WebAppTypeFinder : AppDomainTypeFinder
12 | {
13 | #region Fields
14 |
15 | private bool _ensureBinFolderAssembliesLoaded = true;
16 | private bool _binFolderAssembliesLoaded;
17 |
18 | #endregion
19 |
20 | #region Properties
21 |
22 | ///
23 | /// Gets or sets whether assemblies in the bin folder of the web application should be specifically checked for being loaded on application load. This is need in situations where plugins need to be loaded in the AppDomain after the application been reloaded.
24 | ///
25 | public bool EnsureBinFolderAssembliesLoaded
26 | {
27 | get { return _ensureBinFolderAssembliesLoaded; }
28 | set { _ensureBinFolderAssembliesLoaded = value; }
29 | }
30 |
31 | #endregion
32 |
33 | #region Methods
34 |
35 | ///
36 | /// Gets a physical disk path of \Bin directory
37 | ///
38 | /// The physical path. E.g. "c:\inetpub\wwwroot\bin"
39 | public virtual string GetBinDirectory()
40 | {
41 | return PlatformServices.Default.Application.ApplicationBasePath;
42 | }
43 |
44 | public override IList GetAssemblies()
45 | {
46 | if (this.EnsureBinFolderAssembliesLoaded && !_binFolderAssembliesLoaded)
47 | {
48 | _binFolderAssembliesLoaded = true;
49 | string binPath = GetBinDirectory();
50 |
51 | LoadMatchingAssemblies(binPath);
52 | }
53 |
54 | return base.GetAssemblies();
55 | }
56 |
57 | #endregion
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 | [](https://gitter.im/react-social-network/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
13 |
14 | ASP.NET Core Social network is a web API for as simple social network backend powered by [ASP.NET Core 2](https://docs.microsoft.com/en-us/dotnet/core/).
15 |
16 | This project adheres to the Contributor Covenant [code of conduct](https://github.com/Qolzam/aspnet-core-social-network/blob/master/CODE_OF_CONDUCT.md).
17 | By participating, you are expected to uphold this code. Please report unacceptable behavior to amir.gholzam@live.com.
18 |
19 | ## Document
20 |
21 | Use [Documentation](https://qolzam.gitbooks.io/aspnet-core-social-network/) to find out more details about this project.
22 |
23 | # Installing
24 |
25 | 1. Fork the [aspnet-core-social-network](https://github.com/Qolzam/aspnet-core-social-network) repository on Github
26 | 2. Clone your fork to your local machine `git clone git@github.com:/aspnet-core-social-network.git`
27 | 3. Restore packages
28 | 4. Run project
29 | 5. Use API document
30 |
31 | ## Contribute
32 |
33 | [React Social Network](http://greensocial.herokuapp.com/) has been made by love. I planed to build a back-end for this project and improve the perfomance as I process all procedures on the fron-end side. If you'd like to help,
34 | check out the [document](https://qolzam.gitbooks.io/aspnet-core-social-network/).
35 | I'd greatly appreciate any [contribution](https://github.com/Qolzam/aspnet-core-social-network/blob/master/CONTRIBUTING.md)
36 | you make. :)
37 |
38 | # Authors
39 |
40 | - Amir Movahedi
41 |
42 | # License
43 |
44 | This project is licensed under the MIT License - see the [LICENSE](https://github.com/Qolzam/aspnet-core-social-network/blob/master/LICENSE) file for details
45 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 | [](https://gitter.im/react-social-network/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
13 |
14 | ASP.NET Core Social network is a web API for as simple social network backend powered by [ASP.NET Core 2](https://docs.microsoft.com/en-us/dotnet/core/).
15 |
16 | This project adheres to the Contributor Covenant [code of conduct](https://github.com/Qolzam/aspnet-core-social-network/blob/master/CODE_OF_CONDUCT.md).
17 | By participating, you are expected to uphold this code. Please report unacceptable behavior to amir.gholzam@live.com.
18 |
19 | ## Document
20 |
21 | Use [Documentation](https://qolzam.gitbooks.io/aspnet-core-social-network/) to find out more details about this project.
22 |
23 | # Installing
24 |
25 | 1. Fork the [aspnet-core-social-network](https://github.com/Qolzam/aspnet-core-social-network) repository on Github
26 | 2. Clone your fork to your local machine `git clone git@github.com:/aspnet-core-social-network.git`
27 | 3. Restore packages
28 | 4. Run project
29 | 5. Use API document
30 |
31 | ## Contribute
32 |
33 | [React Social Network](http://greensocial.herokuapp.com/) has been made by love. I planed to build a back-end for this project and improve the perfomance as I process all procedures on the fron-end side. If you'd like to help,
34 | check out the [document](https://qolzam.gitbooks.io/aspnet-core-social-network/).
35 | I'd greatly appreciate any [contribution](https://github.com/Qolzam/aspnet-core-social-network/blob/master/CONTRIBUTING.md)
36 | you make. :)
37 |
38 | # Authors
39 |
40 | - Amir Movahedi
41 |
42 | # License
43 |
44 | This project is licensed under the MIT License - see the [LICENSE](https://github.com/Qolzam/aspnet-core-social-network/blob/master/LICENSE) file for details
45 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/BaseEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Green.Core
4 | {
5 | ///
6 | /// Base class for entities
7 | ///
8 | public abstract partial class BaseEntity
9 | {
10 |
11 | public BaseEntity()
12 | {
13 | this.Key = Guid.NewGuid();
14 | this.CreatedOnUtc = DateTime.UtcNow;
15 | }
16 |
17 | ///
18 | /// Gets or sets the entity identifier
19 | ///
20 | public int Id { get; set; }
21 |
22 | ///
23 | /// Gets or sets the key.
24 | ///
25 | /// The key.
26 | public Guid Key
27 | {
28 | get;
29 | set;
30 | }
31 |
32 | ///
33 | /// Gets or sets the created on UTC.
34 | ///
35 | /// The created on UTC.
36 | public DateTime CreatedOnUtc
37 | {
38 | get;
39 | set;
40 | }
41 |
42 | public override bool Equals(object obj)
43 | {
44 | return Equals(obj as BaseEntity);
45 | }
46 |
47 | private static bool IsTransient(BaseEntity obj)
48 | {
49 | return obj != null && Equals(obj.Id, default(int));
50 | }
51 |
52 | private Type GetUnproxiedType()
53 | {
54 | return GetType();
55 | }
56 |
57 | public virtual bool Equals(BaseEntity other)
58 | {
59 | if (other == null)
60 | return false;
61 |
62 | if (ReferenceEquals(this, other))
63 | return true;
64 |
65 | if (!IsTransient(this) &&
66 | !IsTransient(other) &&
67 | Equals(Id, other.Id))
68 | {
69 | var otherType = other.GetUnproxiedType();
70 | var thisType = GetUnproxiedType();
71 | return thisType.IsAssignableFrom(otherType) ||
72 | otherType.IsAssignableFrom(thisType);
73 | }
74 |
75 | return false;
76 | }
77 |
78 | public override int GetHashCode()
79 | {
80 | if (Equals(Id, default(int)))
81 | return base.GetHashCode();
82 | return Id.GetHashCode();
83 | }
84 |
85 | public static bool operator ==(BaseEntity x, BaseEntity y)
86 | {
87 | return Equals(x, y);
88 | }
89 |
90 | public static bool operator !=(BaseEntity x, BaseEntity y)
91 | {
92 | return !(x == y);
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/Libraries/Green.Core/GreenException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace Green.Core
5 | {
6 | ///
7 | /// Represents errors that occur during application execution
8 | ///
9 | [Serializable]
10 | public class GreenException : Exception
11 | {
12 | ///
13 | /// Initializes a new instance of the Exception class.
14 | ///
15 | public GreenException()
16 | {
17 | }
18 |
19 | ///
20 | /// Initializes a new instance of the Exception class with a specified error message.
21 | ///
22 | /// The message that describes the error.
23 | public GreenException(string message)
24 | : base(message)
25 | {
26 |
27 | }
28 |
29 | ///
30 | /// Initializes a new instance of the Exception class with a specified error message.
31 | ///
32 | /// The exception message format.
33 | /// The exception message arguments.
34 | public GreenException(string messageFormat, params object[] args)
35 | : base(string.Format(messageFormat, args))
36 | {
37 | }
38 |
39 | ///
40 | /// Initializes a new instance of the Exception class with serialized data.
41 | ///
42 | /// The SerializationInfo that holds the serialized object data about the exception being thrown.
43 | /// The StreamingContext that contains contextual information about the source or destination.
44 | protected GreenException(SerializationInfo
45 | info, StreamingContext context)
46 | : base(info, context)
47 | {
48 | }
49 |
50 | ///
51 | /// Initializes a new instance of the Exception class with a specified error message and a reference to the inner exception that is the cause of this exception.
52 | ///
53 | /// The error message that explains the reason for the exception.
54 | /// The exception that is the cause of the current exception, or a null reference if no inner exception is specified.
55 | public GreenException(string message, Exception innerException)
56 | : base(message, innerException)
57 | {
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Tasks/ScheduleTask.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Green.Core.Domain.Tasks
4 | {
5 | ///
6 | /// Schedule task
7 | ///
8 | public partial class ScheduleTask : BaseEntity
9 | {
10 | ///
11 | /// Gets or sets the name
12 | ///
13 | public string Name { get; set; }
14 |
15 | ///
16 | /// Gets or sets the run period (in seconds)
17 | ///
18 | public int Seconds { get; set; }
19 |
20 | ///
21 | /// Gets or sets the type of appropriate ITask class
22 | ///
23 | public string Type { get; set; }
24 |
25 | ///
26 | /// Gets or sets the value indicating whether a task is enabled
27 | ///
28 | public bool Enabled { get; set; }
29 |
30 | ///
31 | /// Gets or sets the value indicating whether a task should be stopped on some error
32 | ///
33 | public bool StopOnError { get; set; }
34 |
35 |
36 | ///
37 | /// Gets or sets the machine name (instance) that leased this task. It's used when running in web farm (ensure that a task in run only on one machine). It could be null when not running in web farm.
38 | ///
39 | public string LeasedByMachineName { get; set; }
40 | ///
41 | /// Gets or sets the datetime until the task is leased by some machine (instance). It's used when running in web farm (ensure that a task in run only on one machine).
42 | ///
43 | public DateTime? LeasedUntilUtc { get; set; }
44 |
45 | ///
46 | /// Gets or sets the datetime when it was started last time
47 | ///
48 | public DateTime? LastStartUtc { get; set; }
49 | ///
50 | /// Gets or sets the datetime when it was finished last time (no matter failed ir success)
51 | ///
52 | public DateTime? LastEndUtc { get; set; }
53 | ///
54 | /// Gets or sets the datetime when it was sucessfully finished last time
55 | ///
56 | public DateTime? LastSuccessUtc { get; set; }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Green.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Presentation/Green.Web.Framework/Infrastracture/GreenCommonStartup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Microsoft.EntityFrameworkCore;
5 | using Green.Core.Configuration;
6 | using Green.Core.Infrastructure;
7 | using Green.Web.Framework.Infrastructure.Extensions;
8 | using Green.Data;
9 |
10 | namespace Green.Web.Framework.Infrastructure
11 | {
12 | ///
13 | /// Represents object for the configuring common features and middleware on application startup
14 | ///
15 | public class GreenCommonStartup : IGreenStartup
16 | {
17 | ///
18 | /// Add and configure any of the middleware
19 | ///
20 | /// Collection of service descriptors
21 | /// Configuration root of the application
22 | public void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration)
23 | {
24 |
25 |
26 | //add GreenConfig configuration parameters
27 | var greenConfig = services.ConfigureStartupConfig(configuration.GetSection("Green"));
28 |
29 | //add data layer
30 | services.AddDbContext(options => options.UseSqlServer(greenConfig.SqlConnectionString));
31 |
32 |
33 | //add accessor to HttpContext
34 | services.AddHttpContextAccessor();
35 |
36 | //add HTTP sesion state feature
37 | services.AddHttpSession();
38 |
39 | //add anti-forgery
40 | services.AddAntiForgery();
41 |
42 | }
43 |
44 | ///
45 | /// Configure the using of added middleware
46 | ///
47 | /// Builder for configuring an application's request pipeline
48 | public void Configure(IApplicationBuilder application)
49 | {
50 | //static files
51 | var greenConfig = EngineContext.Current.Resolve();
52 | application.UseStaticFiles();
53 |
54 | //use HTTP session
55 | application.UseSession();
56 |
57 | }
58 |
59 | ///
60 | /// Gets order of this startup configuration implementation
61 | ///
62 | public int Order
63 | {
64 | //common services should be loaded after error handlers
65 | get { return 100; }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Posts/PostService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.Posts;
6 |
7 | namespace Green.Services.Posts
8 | {
9 | public class PostService
10 | {
11 | #region Fields
12 |
13 | private readonly IRepository _postRepository;
14 |
15 | #endregion
16 |
17 | #region Constructor
18 |
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | /// Post repository.
24 | public PostService(IRepository postRepository)
25 | {
26 | this._postRepository = postRepository;
27 | }
28 |
29 | #endregion
30 |
31 | #region Methods
32 |
33 | ///
34 | /// Inserts the post.
35 | ///
36 | /// Post.
37 | public void InsertPost(Post post)
38 | {
39 | if (post == null)
40 | throw new ArgumentNullException(nameof(post));
41 |
42 |
43 | _postRepository.Insert(post);
44 | }
45 |
46 | ///
47 | /// Gets all posts.
48 | ///
49 | /// The all posts.
50 | public IList GetAllPosts()
51 | {
52 | return _postRepository.Table.ToList();
53 | }
54 |
55 | ///
56 | /// Gets the post by identifier.
57 | ///
58 | /// The post by identifier.
59 | /// Post identifier.
60 | public Post GetPostById(int postId)
61 | {
62 | if (postId == 0)
63 | return null;
64 |
65 | return _postRepository.GetById(postId);
66 | }
67 |
68 | ///
69 | /// Gets the post by GUID.
70 | ///
71 | /// The post by GUID.
72 | /// Post GUID.
73 | public Post GetPostByGuid(Guid postGuid)
74 | {
75 | if (postGuid == Guid.Empty)
76 | return null;
77 |
78 | var query = from p in _postRepository.Table
79 | where p.Key == postGuid
80 | orderby p.Id
81 | select p;
82 | var post = query.FirstOrDefault();
83 |
84 | return post;
85 | }
86 |
87 | ///
88 | /// Updates the post.
89 | ///
90 | /// Post.
91 | public void UpdatePost(Post post)
92 | {
93 | if (post == null)
94 | throw new ArgumentNullException(nameof(post));
95 |
96 | _postRepository.Update(post);
97 | }
98 |
99 |
100 | #endregion
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/IEngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.AspNetCore.Builder;
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.Extensions.DependencyInjection;
6 |
7 | namespace Green.Core.Infrastructure
8 | {
9 | ///
10 | /// Classes implementing this interface can serve as a portal for the various services composing the Green engine.
11 | /// Edit functionality, modules and implementations access most Green functionality through this interface.
12 | ///
13 | public interface IEngine
14 | {
15 | ///
16 | /// Initialize engine
17 | ///
18 | /// Collection of service descriptors
19 | void Initialize(IServiceCollection services);
20 |
21 | ///
22 | /// Add and configure services
23 | ///
24 | /// Collection of service descriptors
25 | /// Configuration root of the application
26 | /// Service provider
27 | IServiceProvider ConfigureServices(IServiceCollection services, IConfigurationRoot configuration);
28 |
29 | ///
30 | /// Configure HTTP request pipeline
31 | ///
32 | /// Builder for configuring an application's request pipeline
33 | void ConfigureRequestPipeline(IApplicationBuilder application);
34 |
35 | ///
36 | /// Resolve dependency
37 | ///
38 | /// Type of resolved service
39 | /// Resolved service
40 | T Resolve() where T : class;
41 |
42 | ///
43 | /// Resolve dependency
44 | ///
45 | /// Type of resolved service
46 | /// Resolved service
47 | object Resolve(Type type);
48 |
49 | ///
50 | /// Resolve dependencies
51 | ///
52 | /// Type of resolved services
53 | /// Collection of resolved services
54 | IEnumerable ResolveAll();
55 |
56 | ///
57 | /// Resolve unregistered service
58 | ///
59 | /// Type of service
60 | /// Resolved service
61 | object ResolveUnregistered(Type type);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/ImageGallery/ImageService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.ImageGallery;
6 |
7 | namespace Green.Services.ImageGallery
8 | {
9 | public class ImageService
10 | {
11 | #region Fields
12 |
13 | private readonly IRepository _imageRepository;
14 |
15 | #endregion
16 |
17 | #region Constructor
18 |
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | /// Image repository.
24 | public ImageService(IRepository imageRepository)
25 | {
26 | this._imageRepository = imageRepository;
27 | }
28 |
29 | #endregion
30 |
31 | #region Methods
32 |
33 | ///
34 | /// Inserts the image.
35 | ///
36 | /// Image.
37 | public void InsertImage(Image image)
38 | {
39 | if (image == null)
40 | throw new ArgumentNullException(nameof(image));
41 |
42 |
43 | _imageRepository.Insert(image);
44 | }
45 |
46 | ///
47 | /// Gets all images.
48 | ///
49 | /// The all images.
50 | public IList GetAllImages()
51 | {
52 | return _imageRepository.Table.ToList();
53 | }
54 |
55 | ///
56 | /// Gets the image by identifier.
57 | ///
58 | /// The image by identifier.
59 | /// Image identifier.
60 | public Image GetImageById(int imageId)
61 | {
62 | if (imageId == 0)
63 | return null;
64 |
65 | return _imageRepository.GetById(imageId);
66 | }
67 |
68 | ///
69 | /// Gets the image by GUID.
70 | ///
71 | /// The image by GUID.
72 | /// Image GUID.
73 | public Image GetImageByGuid(Guid imageGuid)
74 | {
75 | if (imageGuid == Guid.Empty)
76 | return null;
77 |
78 | var query = from im in _imageRepository.Table
79 | where im.Key == imageGuid
80 | orderby im.Id
81 | select im;
82 | var image = query.FirstOrDefault();
83 |
84 | return image;
85 | }
86 |
87 | ///
88 | /// Updates the image.
89 | ///
90 | /// Image.
91 | public void UpdateImage(Image image)
92 | {
93 | if (image == null)
94 | throw new ArgumentNullException(nameof(image));
95 |
96 | _imageRepository.Update(image);
97 | }
98 |
99 |
100 | #endregion
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Notifies/NotifyService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.Notifies;
6 |
7 | namespace Green.Services.Notifies
8 | {
9 | public class NotifyService
10 | {
11 | #region Fields
12 |
13 | private readonly IRepository _notifyRepository;
14 |
15 | #endregion
16 |
17 | #region Constructor
18 |
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | /// Notify repository.
24 | public NotifyService(IRepository notifyRepository)
25 | {
26 | this._notifyRepository = notifyRepository;
27 | }
28 |
29 | #endregion
30 |
31 | #region Methods
32 |
33 | ///
34 | /// Inserts the notify.
35 | ///
36 | /// Notify.
37 | public void InsertNotify(Notify notify)
38 | {
39 | if (notify == null)
40 | throw new ArgumentNullException(nameof(notify));
41 |
42 |
43 | _notifyRepository.Insert(notify);
44 | }
45 |
46 | ///
47 | /// Gets all notifys.
48 | ///
49 | /// The all notifys.
50 | public IList GetAllNotifys()
51 | {
52 | return _notifyRepository.Table.ToList();
53 | }
54 |
55 | ///
56 | /// Gets the notify by identifier.
57 | ///
58 | /// The notify by identifier.
59 | /// Notify identifier.
60 | public Notify GetNotifyById(int notifyId)
61 | {
62 | if (notifyId == 0)
63 | return null;
64 |
65 | return _notifyRepository.GetById(notifyId);
66 | }
67 |
68 | ///
69 | /// Gets the notify by GUID.
70 | ///
71 | /// The notify by GUID.
72 | /// Notify GUID.
73 | public Notify GetNotifyByGuid(Guid notifyGuid)
74 | {
75 | if (notifyGuid == Guid.Empty)
76 | return null;
77 |
78 | var query = from n in _notifyRepository.Table
79 | where n.Key == notifyGuid
80 | orderby n.Id
81 | select n;
82 | var notify = query.FirstOrDefault();
83 |
84 | return notify;
85 | }
86 |
87 | ///
88 | /// Updates the notify.
89 | ///
90 | /// Notify.
91 | public void UpdateNotify(Notify notify)
92 | {
93 | if (notify == null)
94 | throw new ArgumentNullException(nameof(notify));
95 |
96 | _notifyRepository.Update(notify);
97 | }
98 |
99 |
100 | #endregion
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Circles/CircleService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.Circles;
6 |
7 | namespace Green.Services.Circles
8 | {
9 | public class CircleService: ICircleService
10 | {
11 | #region Fields
12 |
13 | private readonly IRepository _circleRepository;
14 |
15 | #endregion
16 |
17 | #region Constructor
18 |
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | /// Circle repository.
24 | public CircleService(IRepository circleRepository)
25 | {
26 | this._circleRepository = circleRepository;
27 | }
28 |
29 | #endregion
30 |
31 | #region Methods
32 |
33 | ///
34 | /// Inserts the circle.
35 | ///
36 | /// Circle.
37 | public void InsertCircle(Circle circle)
38 | {
39 | if (circle == null)
40 | throw new ArgumentNullException(nameof(circle));
41 |
42 |
43 | _circleRepository.Insert(circle);
44 | }
45 |
46 | ///
47 | /// Gets all circles.
48 | ///
49 | /// The all circles.
50 | public IList GetAllCircles()
51 | {
52 | return _circleRepository.Table.ToList();
53 | }
54 |
55 | ///
56 | /// Gets the circle by identifier.
57 | ///
58 | /// The circle by identifier.
59 | /// Circle identifier.
60 | public Circle GetCircleById(int circleId)
61 | {
62 | if (circleId == 0)
63 | return null;
64 |
65 | return _circleRepository.GetById(circleId);
66 | }
67 |
68 | ///
69 | /// Gets the circle by GUID.
70 | ///
71 | /// The circle by GUID.
72 | /// Circle GUID.
73 | public Circle GetCircleByGuid(Guid circleGuid)
74 | {
75 | if (circleGuid == Guid.Empty)
76 | return null;
77 |
78 | var query = from c in _circleRepository.Table
79 | where c.Key == circleGuid
80 | orderby c.Id
81 | select c;
82 | var circle = query.FirstOrDefault();
83 |
84 | return circle;
85 | }
86 |
87 | ///
88 | /// Updates the circle.
89 | ///
90 | /// Circle.
91 | public void UpdateCircle(Circle circle)
92 | {
93 | if (circle == null)
94 | throw new ArgumentNullException(nameof(circle));
95 |
96 | _circleRepository.Update(circle);
97 | }
98 |
99 |
100 | #endregion
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Comments/CommentService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.Comments;
6 |
7 | namespace Green.Services.Comments
8 | {
9 | public class CommentService
10 | {
11 | #region Fields
12 |
13 | private readonly IRepository _commentRepository;
14 |
15 | #endregion
16 |
17 | #region Constructor
18 |
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | /// Comment repository.
24 | public CommentService(IRepository commentRepository)
25 | {
26 | this._commentRepository = commentRepository;
27 | }
28 |
29 | #endregion
30 |
31 | #region Methods
32 |
33 | ///
34 | /// Inserts the comment.
35 | ///
36 | /// Comment.
37 | public void InsertComment(Comment comment)
38 | {
39 | if (comment == null)
40 | throw new ArgumentNullException(nameof(comment));
41 |
42 |
43 | _commentRepository.Insert(comment);
44 | }
45 |
46 | ///
47 | /// Gets all comments.
48 | ///
49 | /// The all comments.
50 | public IList GetAllComments()
51 | {
52 | return _commentRepository.Table.ToList();
53 | }
54 |
55 | ///
56 | /// Gets the comment by identifier.
57 | ///
58 | /// The comment by identifier.
59 | /// Comment identifier.
60 | public Comment GetCommentById(int commentId)
61 | {
62 | if (commentId == 0)
63 | return null;
64 |
65 | return _commentRepository.GetById(commentId);
66 | }
67 |
68 | ///
69 | /// Gets the comment by GUID.
70 | ///
71 | /// The comment by GUID.
72 | /// Comment GUID.
73 | public Comment GetCommentByGuid(Guid commentGuid)
74 | {
75 | if (commentGuid == Guid.Empty)
76 | return null;
77 |
78 | var query = from com in _commentRepository.Table
79 | where com.Key == commentGuid
80 | orderby com.Id
81 | select com;
82 | var comment = query.FirstOrDefault();
83 |
84 | return comment;
85 | }
86 |
87 | ///
88 | /// Updates the comment.
89 | ///
90 | /// Comment.
91 | public void UpdateComment(Comment comment)
92 | {
93 | if (comment == null)
94 | throw new ArgumentNullException(nameof(comment));
95 |
96 | _commentRepository.Update(comment);
97 | }
98 |
99 |
100 | #endregion
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/IWebHelper.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 |
3 | namespace Green.Core
4 | {
5 | ///
6 | /// Represents a web helper
7 | ///
8 | public partial interface IWebHelper
9 | {
10 | ///
11 | /// Get URL referrer if exists
12 | ///
13 | /// URL referrer
14 | string GetUrlReferrer();
15 |
16 | ///
17 | /// Get IP address from HTTP context
18 | ///
19 | /// String of IP address
20 | string GetCurrentIpAddress();
21 |
22 | ///
23 | /// Returns true if the requested resource is one of the typical resources that needn't be processed by the cms engine.
24 | ///
25 | /// True if the request targets a static resource file.
26 | bool IsStaticResource();
27 |
28 | ///
29 | /// Modifies query string
30 | ///
31 | /// Url to modify
32 | /// Query string modification
33 | /// Anchor
34 | /// New url
35 | string ModifyQueryString(string url, string queryStringModification, string anchor);
36 |
37 | ///
38 | /// Remove query string from the URL
39 | ///
40 | /// Url to modify
41 | /// Query string to remove
42 | /// New URL without passed query string
43 | string RemoveQueryString(string url, string queryString);
44 |
45 | ///
46 | /// Gets query string value by name
47 | ///
48 | /// Returned value type
49 | /// Query parameter name
50 | /// Query string value
51 | T QueryString(string name);
52 |
53 | ///
54 | /// Gets a value that indicates whether the client is being redirected to a new location
55 | ///
56 | bool IsRequestBeingRedirected { get; }
57 |
58 | ///
59 | /// Gets or sets a value that indicates whether the client is being redirected to a new location using POST
60 | ///
61 | bool IsPostBeingDone { get; set; }
62 |
63 | ///
64 | /// Gets whether the specified http request uri references the local host.
65 | ///
66 | /// Http request
67 | /// True, if http request uri references to the local host
68 | bool IsLocalRequest(HttpRequest req);
69 |
70 | ///
71 | /// Get the raw path and full query of request
72 | ///
73 | /// Http request
74 | /// Raw URL
75 | string GetRawUrl(HttpRequest request);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Infrastructure/Singleton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Green.Core.Infrastructure
5 | {
6 | ///
7 | /// A statically compiled "singleton" used to store objects throughout the
8 | /// lifetime of the app domain. Not so much singleton in the pattern's
9 | /// sense of the word as a standardized way to store single instances.
10 | ///
11 | /// The type of object to store.
12 | /// Access to the instance is not synchrnoized.
13 | public class Singleton : Singleton
14 | {
15 | static T instance;
16 |
17 | /// The singleton instance for the specified type T. Only one instance (at the time) of this object for each type of T.
18 | public static T Instance
19 | {
20 | get { return instance; }
21 | set
22 | {
23 | instance = value;
24 | AllSingletons[typeof(T)] = value;
25 | }
26 | }
27 | }
28 |
29 | ///
30 | /// Provides a singleton list for a certain type.
31 | ///
32 | /// The type of list to store.
33 | public class SingletonList : Singleton>
34 | {
35 | static SingletonList()
36 | {
37 | Singleton>.Instance = new List();
38 | }
39 |
40 | /// The singleton instance for the specified type T. Only one instance (at the time) of this list for each type of T.
41 | public new static IList Instance
42 | {
43 | get { return Singleton>.Instance; }
44 | }
45 | }
46 |
47 | ///
48 | /// Provides a singleton dictionary for a certain key and vlaue type.
49 | ///
50 | /// The type of key.
51 | /// The type of value.
52 | public class SingletonDictionary : Singleton>
53 | {
54 | static SingletonDictionary()
55 | {
56 | Singleton>.Instance = new Dictionary();
57 | }
58 |
59 | /// The singleton instance for the specified type T. Only one instance (at the time) of this dictionary for each type of T.
60 | public new static IDictionary Instance
61 | {
62 | get { return Singleton>.Instance; }
63 | }
64 | }
65 |
66 | ///
67 | /// Provides access to all "singletons" stored by .
68 | ///
69 | public class Singleton
70 | {
71 | static Singleton()
72 | {
73 | allSingletons = new Dictionary();
74 | }
75 |
76 | static readonly IDictionary allSingletons;
77 |
78 | /// Dictionary of type to singleton instances.
79 | public static IDictionary AllSingletons
80 | {
81 | get { return allSingletons; }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/Migrations/20170720175504_AddTaskSettingClass.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Metadata;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace Green.Data.Migrations
7 | {
8 | public partial class AddTaskSettingClass : Migration
9 | {
10 | protected override void Up(MigrationBuilder migrationBuilder)
11 | {
12 | migrationBuilder.CreateTable(
13 | name: "ScheduleTask",
14 | columns: table => new
15 | {
16 | Id = table.Column(type: "int", nullable: false)
17 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
18 | CreatedOnUtc = table.Column(type: "datetime2", nullable: false),
19 | Enabled = table.Column(type: "bit", nullable: false),
20 | Key = table.Column(type: "uniqueidentifier", nullable: false),
21 | LastEndUtc = table.Column(type: "datetime2", nullable: true),
22 | LastStartUtc = table.Column(type: "datetime2", nullable: true),
23 | LastSuccessUtc = table.Column(type: "datetime2", nullable: true),
24 | LeasedByMachineName = table.Column(type: "nvarchar(max)", nullable: true),
25 | LeasedUntilUtc = table.Column(type: "datetime2", nullable: true),
26 | Name = table.Column(type: "nvarchar(max)", nullable: false),
27 | Seconds = table.Column(type: "int", nullable: false),
28 | StopOnError = table.Column(type: "bit", nullable: false),
29 | Type = table.Column(type: "nvarchar(max)", nullable: false)
30 | },
31 | constraints: table =>
32 | {
33 | table.PrimaryKey("PK_ScheduleTask", x => x.Id);
34 | });
35 |
36 | migrationBuilder.CreateTable(
37 | name: "Setting",
38 | columns: table => new
39 | {
40 | Id = table.Column(type: "int", nullable: false)
41 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
42 | CreatedOnUtc = table.Column(type: "datetime2", nullable: false),
43 | Key = table.Column(type: "uniqueidentifier", nullable: false),
44 | Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false),
45 | Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
46 | },
47 | constraints: table =>
48 | {
49 | table.PrimaryKey("PK_Setting", x => x.Id);
50 | });
51 | }
52 |
53 | protected override void Down(MigrationBuilder migrationBuilder)
54 | {
55 | migrationBuilder.DropTable(
56 | name: "ScheduleTask");
57 |
58 | migrationBuilder.DropTable(
59 | name: "Setting");
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Presentation/Green.Web/Controllers/CircleController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Green.Core.Domain.Circles;
6 | using Green.Core.Domain.Users;
7 | using Green.Services.Authentication;
8 | using Green.Services.Circles;
9 | using Green.Services.Users;
10 | using Green.Web.Framework.Helpers;
11 | using Green.Web.Models.Circles;
12 | using Microsoft.AspNetCore.Mvc;
13 |
14 | // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
15 |
16 | namespace Green.Web.Controllers
17 | {
18 | [Route("api/[controller]")]
19 | public class CircleController : Controller
20 | {
21 |
22 | #region Fields
23 |
24 | private readonly IUserService _userService;
25 | private readonly IAuthenticationService _authService;
26 | private readonly ICircleService _circleService;
27 | private readonly IUserCircleService _userCircleService;
28 |
29 |
30 | #endregion
31 |
32 |
33 | #region Constructor
34 |
35 | public CircleController(
36 | IUserService userService,
37 | IUserCircleService userCircleService,
38 | ICircleService circleService,
39 | IAuthenticationService authService)
40 | {
41 | this._userService = userService;
42 | this._userCircleService = userCircleService;
43 | this._circleService = circleService;
44 | this._authService = authService;
45 | }
46 |
47 | #endregion
48 |
49 | // GET: api/values
50 | [HttpGet]
51 | public IEnumerable Get()
52 | {
53 | return new string[] { "value1", "value2" };
54 | }
55 |
56 | // GET api/circle/id
57 | [HttpGet("{id}")]
58 | public string Get(Guid id)
59 | {
60 | return "value";
61 | }
62 |
63 | // POST api/values
64 | [HttpPost()]
65 | public IActionResult Post([FromForm]CreateCircleModel createCircleModel)
66 | {
67 | if(createCircleModel == null)
68 | {
69 | return BadRequest();
70 | }
71 |
72 | if (string.IsNullOrEmpty(createCircleModel.CircleName))
73 | {
74 | ModelState.AddModelError("errors", "Circle name can't be null or empty.");
75 | }
76 |
77 | if (!ModelState.IsValid)
78 | {
79 | // return 422
80 | return new UnprocessableEntityObjectResult(ModelState);
81 | }
82 |
83 |
84 | User user = _authService.GetAuthenticatedUser();
85 |
86 | if (user == null)
87 | {
88 | return Unauthorized();
89 | }
90 |
91 | Circle newCircle = new Circle(){
92 | CircleName = createCircleModel.CircleName,
93 | FollowersCounter = 0,
94 | FollowingCounter = 0,
95 | IsSystem = false
96 | };
97 |
98 | _circleService.InsertCircle(newCircle);
99 |
100 | return Ok(new { key = newCircle.Key, circleName = createCircleModel.CircleName });
101 | }
102 |
103 | // PUT api/values/5
104 | [HttpPut("{id}")]
105 | public void Put(int id, [FromBody]string value)
106 | {
107 | }
108 |
109 | // DELETE api/values/5
110 | [HttpDelete("{id}")]
111 | public void Delete(int id)
112 | {
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at [amir.gholzam@live.com](mailto:amir.gholzam@live.com). All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Tasks/ScheduleTaskService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core.Data;
5 | using Green.Core.Domain.Tasks;
6 |
7 | namespace Green.Services.Tasks
8 | {
9 | ///
10 | /// Task service
11 | ///
12 | public partial class ScheduleTaskService : IScheduleTaskService
13 | {
14 | #region Fields
15 |
16 | private readonly IRepository _taskRepository;
17 |
18 | #endregion
19 |
20 | #region Ctor
21 |
22 | public ScheduleTaskService(IRepository taskRepository)
23 | {
24 | this._taskRepository = taskRepository;
25 | }
26 |
27 | #endregion
28 |
29 | #region Methods
30 |
31 | ///
32 | /// Deletes a task
33 | ///
34 | /// Task
35 | public virtual void DeleteTask(ScheduleTask task)
36 | {
37 | if (task == null)
38 | throw new ArgumentNullException("task");
39 |
40 | _taskRepository.Delete(task);
41 | }
42 |
43 | ///
44 | /// Gets a task
45 | ///
46 | /// Task identifier
47 | /// Task
48 | public virtual ScheduleTask GetTaskById(int taskId)
49 | {
50 | if (taskId == 0)
51 | return null;
52 |
53 | return _taskRepository.GetById(taskId);
54 | }
55 |
56 | ///
57 | /// Gets a task by its type
58 | ///
59 | /// Task type
60 | /// Task
61 | public virtual ScheduleTask GetTaskByType(string type)
62 | {
63 | if (String.IsNullOrWhiteSpace(type))
64 | return null;
65 |
66 | var query = _taskRepository.Table;
67 | query = query.Where(st => st.Type == type);
68 | query = query.OrderByDescending(t => t.Id);
69 |
70 | var task = query.FirstOrDefault();
71 | return task;
72 | }
73 |
74 | ///
75 | /// Gets all tasks
76 | ///
77 | /// A value indicating whether to show hidden records
78 | /// Tasks
79 | public virtual IList GetAllTasks(bool showHidden = false)
80 | {
81 | var query = _taskRepository.Table;
82 | if (!showHidden)
83 | {
84 | query = query.Where(t => t.Enabled);
85 | }
86 | query = query.OrderByDescending(t => t.Seconds);
87 |
88 | var tasks = query.ToList();
89 | return tasks;
90 | }
91 |
92 | ///
93 | /// Inserts a task
94 | ///
95 | /// Task
96 | public virtual void InsertTask(ScheduleTask task)
97 | {
98 | if (task == null)
99 | throw new ArgumentNullException("task");
100 |
101 | _taskRepository.Insert(task);
102 | }
103 |
104 | ///
105 | /// Updates the task
106 | ///
107 | /// Task
108 | public virtual void UpdateTask(ScheduleTask task)
109 | {
110 | if (task == null)
111 | throw new ArgumentNullException("task");
112 |
113 | _taskRepository.Update(task);
114 | }
115 |
116 | #endregion
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/Presentation/Green.Web.Framework/Infrastracture/DependencyRegistrar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using Autofac;
6 | using Autofac.Builder;
7 | using Autofac.Core;
8 | using Microsoft.AspNetCore.Mvc.Infrastructure;
9 | using Green.Core.Infrastructure.DependencyManagement;
10 | using Green.Core.Configuration;
11 | using Green.Services.Configuration;
12 | using Green.Services.Tasks;
13 | using Green.Core.Infrastructure;
14 | using Green.Core;
15 | using Green.Services.Users;
16 | using Green.Data;
17 | using Green.Core.Data;
18 | using Green.Services.Authentication;
19 | using Green.Services.Installation;
20 | using Green.Services.Security;
21 | using Green.Services.Circles;
22 |
23 | namespace Green.Web.Framework.Infrastructure
24 | {
25 | ///
26 | /// Dependency registrar
27 | ///
28 | public class DependencyRegistrar : IDependencyRegistrar
29 | {
30 | ///
31 | /// Register services and interfaces
32 | ///
33 | /// Container builder
34 | /// Type finder
35 | /// Config
36 | public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, GreenConfig config)
37 | {
38 | //web helper
39 | builder.RegisterType().As().InstancePerLifetimeScope();
40 |
41 | //data layer
42 | builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
43 |
44 | //infrastracture
45 | builder.RegisterType().As().InstancePerLifetimeScope();
46 | builder.RegisterType().As().InstancePerLifetimeScope();
47 | builder.RegisterType().As().InstancePerLifetimeScope();
48 | builder.RegisterType().As();
49 | builder.RegisterType().As().InstancePerLifetimeScope();
50 |
51 |
52 | //app services
53 | builder.RegisterType().As().InstancePerLifetimeScope();
54 | builder.RegisterType().As().InstancePerLifetimeScope();
55 | builder.RegisterType().As().InstancePerLifetimeScope();
56 | builder.RegisterType().As().InstancePerLifetimeScope();
57 |
58 |
59 | //register all settings
60 | builder.RegisterSource(new SettingsSource());
61 |
62 |
63 | }
64 |
65 | ///
66 | /// Gets order of this dependency registrar implementation
67 | ///
68 | public int Order
69 | {
70 | get { return 0; }
71 | }
72 | }
73 |
74 |
75 | public class SettingsSource : IRegistrationSource
76 | {
77 | static readonly MethodInfo BuildMethod = typeof(SettingsSource).GetMethod(
78 | "BuildRegistration",
79 | BindingFlags.Static | BindingFlags.NonPublic);
80 |
81 | public IEnumerable RegistrationsFor(
82 | Service service,
83 | Func> registrations)
84 | {
85 | var ts = service as TypedService;
86 | if (ts != null && typeof(ISettings).IsAssignableFrom(ts.ServiceType))
87 | {
88 | var buildMethod = BuildMethod.MakeGenericMethod(ts.ServiceType);
89 | yield return (IComponentRegistration)buildMethod.Invoke(null, null);
90 | }
91 | }
92 |
93 | static IComponentRegistration BuildRegistration() where TSettings : ISettings, new()
94 | {
95 | return RegistrationBuilder
96 | .ForDelegate((c, p) =>
97 | {
98 | return c.Resolve().LoadSetting();
99 | })
100 | .InstancePerLifetimeScope()
101 | .CreateRegistration();
102 | }
103 |
104 | public bool IsAdapterForIndividualComponents { get { return false; } }
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Tasks/TaskManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using Green.Core.Infrastructure;
6 |
7 | namespace Green.Services.Tasks
8 | {
9 | ///
10 | /// Represents task manager
11 | ///
12 | public partial class TaskManager
13 | {
14 | private static readonly TaskManager _taskManager = new TaskManager();
15 | private readonly List _taskThreads = new List();
16 | private const int _notRunTasksInterval = 60 * 30; //30 minutes
17 |
18 | private TaskManager()
19 | {
20 | }
21 |
22 | ///
23 | /// Initializes the task manager
24 | ///
25 | public void Initialize()
26 | {
27 | this._taskThreads.Clear();
28 |
29 | var taskService = EngineContext.Current.Resolve();
30 | var scheduleTasks = taskService
31 | .GetAllTasks()
32 | .OrderBy(x => x.Seconds)
33 | .ToList();
34 |
35 | //group by threads with the same seconds
36 | foreach (var scheduleTaskGrouped in scheduleTasks.GroupBy(x => x.Seconds))
37 | {
38 | //create a thread
39 | var taskThread = new TaskThread
40 | {
41 | Seconds = scheduleTaskGrouped.Key
42 | };
43 | foreach (var scheduleTask in scheduleTaskGrouped)
44 | {
45 | var task = new Task(scheduleTask);
46 | taskThread.AddTask(task);
47 | }
48 | this._taskThreads.Add(taskThread);
49 | }
50 |
51 | //sometimes a task period could be set to several hours (or even days).
52 | //in this case a probability that it'll be run is quite small (an application could be restarted)
53 | //we should manually run the tasks which weren't run for a long time
54 | var notRunTasks = scheduleTasks
55 | //find tasks with "run period" more than 30 minutes
56 | .Where(x => x.Seconds >= _notRunTasksInterval)
57 | .Where(x => !x.LastStartUtc.HasValue || x.LastStartUtc.Value.AddSeconds(x.Seconds) < DateTime.UtcNow)
58 | .ToList();
59 | //create a thread for the tasks which weren't run for a long time
60 | if (notRunTasks.Any())
61 | {
62 | var taskThread = new TaskThread
63 | {
64 | RunOnlyOnce = true,
65 | Seconds = 60 * 5 //let's run such tasks in 5 minutes after application start
66 | };
67 | foreach (var scheduleTask in notRunTasks)
68 | {
69 | var task = new Task(scheduleTask);
70 | taskThread.AddTask(task);
71 | }
72 | this._taskThreads.Add(taskThread);
73 | }
74 | }
75 |
76 | ///
77 | /// Starts the task manager
78 | ///
79 | public void Start()
80 | {
81 | foreach (var taskThread in this._taskThreads)
82 | {
83 | taskThread.InitTimer();
84 | }
85 | }
86 |
87 | ///
88 | /// Stops the task manager
89 | ///
90 | public void Stop()
91 | {
92 | foreach (var taskThread in this._taskThreads)
93 | {
94 | taskThread.Dispose();
95 | }
96 | }
97 |
98 | ///
99 | /// Gets the task mamanger instance
100 | ///
101 | public static TaskManager Instance
102 | {
103 | get
104 | {
105 | return _taskManager;
106 | }
107 | }
108 |
109 | ///
110 | /// Gets a list of task threads of this task manager
111 | ///
112 | public IList TaskThreads
113 | {
114 | get
115 | {
116 | return new ReadOnlyCollection(this._taskThreads);
117 | }
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/DataReaderExtensions.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Data;
5 | using System.Reflection;
6 |
7 | namespace Green.Data
8 | {
9 | public static class DataReaderExtensions
10 | {
11 | ///
12 | /// Creates a list of a given type from all the rows in a DataReader.
13 | ///
14 | /// Note this method uses Reflection so this isn't a high performance
15 | /// operation, but it can be useful for generic data reader to entity
16 | /// conversions on the fly and with anonymous types.
17 | ///
18 | ///
19 | /// An open DataReader that's in position to read
20 | /// Optional - comma delimited list of fields that you don't want to update
21 | ///
22 | /// Optional - Cached PropertyInfo dictionary that holds property info data for this object.
23 | /// Can be used for caching hte PropertyInfo structure for multiple operations to speed up
24 | /// translation. If not passed automatically created.
25 | ///
26 | ///
27 | public static List DataReaderToObjectList(this IDataReader reader, string fieldsToSkip = null, Dictionary piList = null)
28 | where TType : new()
29 | {
30 | if (reader == null)
31 | return null;
32 |
33 | var items = new List();
34 |
35 | // Create lookup list of property info objects
36 | if (piList == null)
37 | {
38 | piList = new Dictionary();
39 | var props = typeof(TType).GetProperties(BindingFlags.Instance | BindingFlags.Public);
40 | foreach (var prop in props)
41 | piList.Add(prop.Name.ToLower(), prop);
42 | }
43 |
44 | while (reader.Read())
45 | {
46 | var inst = new TType();
47 | DataReaderToObject(reader, inst, fieldsToSkip, piList);
48 | items.Add(inst);
49 | }
50 |
51 | return items;
52 | }
53 |
54 | ///
55 | /// Populates the properties of an object from a single DataReader row using
56 | /// Reflection by matching the DataReader fields to a public property on
57 | /// the object passed in. Unmatched properties are left unchanged.
58 | ///
59 | /// You need to pass in a data reader located on the active row you want
60 | /// to serialize.
61 | ///
62 | /// This routine works best for matching pure data entities and should
63 | /// be used only in low volume environments where retrieval speed is not
64 | /// critical due to its use of Reflection.
65 | ///
66 | /// Instance of the DataReader to read data from. Should be located on the correct record (Read() should have been called on it before calling this method)
67 | /// Instance of the object to populate properties on
68 | /// Optional - A comma delimited list of object properties that should not be updated
69 | /// Optional - Cached PropertyInfo dictionary that holds property info data for this object
70 | public static void DataReaderToObject(this IDataReader reader, object instance, string fieldsToSkip = null, Dictionary piList = null)
71 | {
72 | if (reader.IsClosed)
73 | throw new InvalidOperationException("Data reader cannot be used because it's already closed");
74 |
75 | if (string.IsNullOrEmpty(fieldsToSkip))
76 | fieldsToSkip = string.Empty;
77 | else
78 | fieldsToSkip = "," + fieldsToSkip + ",";
79 |
80 | fieldsToSkip = fieldsToSkip.ToLower();
81 |
82 | // create a dictionary of properties to look up
83 | // we can pass this in so we can cache the list once
84 | // for a list operation
85 | if (piList == null)
86 | {
87 | piList = new Dictionary();
88 | var props = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
89 | foreach (var prop in props)
90 | piList.Add(prop.Name.ToLower(), prop);
91 | }
92 |
93 | for (int index = 0; index < reader.FieldCount; index++)
94 | {
95 | string name = reader.GetName(index).ToLower();
96 | if (piList.ContainsKey(name))
97 | {
98 | var prop = piList[name];
99 |
100 | if (fieldsToSkip.Contains("," + name + ","))
101 | continue;
102 |
103 | if ((prop != null) && prop.CanWrite)
104 | {
105 | var val = reader.GetValue(index);
106 | prop.SetValue(instance, (val == DBNull.Value) ? null : val, null);
107 | }
108 | }
109 | }
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/Libraries/Green.Services/Users/UserService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core;
5 | using Green.Core.Data;
6 | using Green.Core.Domain.Users;
7 |
8 | namespace Green.Services.Users
9 | {
10 | public class UserService:IUserService
11 | {
12 |
13 | #region Fields
14 |
15 | private readonly IRepository _userRepository;
16 | private readonly IWebHelper _webHelper;
17 |
18 | #endregion
19 |
20 | #region Constructor
21 |
22 |
23 | ///
24 | /// Initializes a new instance of the class.
25 | ///
26 | /// User repository.
27 | public UserService(IRepository userRepository, IWebHelper webHelper)
28 | {
29 | this._userRepository = userRepository;
30 | this._webHelper = webHelper;
31 | }
32 |
33 | #endregion
34 |
35 | #region Methods
36 |
37 | ///
38 | /// Inserts the user.
39 | ///
40 | /// User.
41 | public void InsertUser(User user)
42 | {
43 | if (user == null)
44 | throw new ArgumentNullException(nameof(user));
45 |
46 | user.LastIpAddress = _webHelper.GetCurrentIpAddress();
47 |
48 | _userRepository.Insert(user);
49 | }
50 |
51 | ///
52 | /// Gets all users.
53 | ///
54 | /// The all users.
55 | public IList GetAllUsers(){
56 | return _userRepository.Table.ToList();
57 | }
58 |
59 | ///
60 | /// Gets the user by identifier.
61 | ///
62 | /// The user by identifier.
63 | /// User identifier.
64 | public User GetUserById(int userId)
65 | {
66 | if (userId == 0)
67 | return null;
68 |
69 | return _userRepository.GetById(userId);
70 | }
71 |
72 | ///
73 | /// Gets the user by GUID.
74 | ///
75 | /// The user by GUID.
76 | /// User GUID.
77 | public User GetUserByGuid(Guid userGuid)
78 | {
79 | if (userGuid == Guid.Empty)
80 | return null;
81 |
82 | var query = from u in _userRepository.Table
83 | where u.Key == userGuid
84 | orderby u.Id
85 | select u;
86 | var user = query.FirstOrDefault();
87 |
88 | return user;
89 | }
90 |
91 | ///
92 | /// Gets the user by email.
93 | ///
94 | /// The user by email.
95 | /// Email.
96 | public User GetUserByEmail(string email)
97 | {
98 | if (string.IsNullOrEmpty(email))
99 | return null;
100 |
101 | var query = from u in _userRepository.Table
102 | where u.Email == email
103 | orderby u.Id
104 | select u;
105 | var user = query.FirstOrDefault();
106 |
107 | return user;
108 | }
109 |
110 | ///
111 | /// Updates the user.
112 | ///
113 | /// User.
114 | public void UpdateUser(User user)
115 | {
116 | if (user == null)
117 | throw new ArgumentNullException(nameof(user));
118 |
119 | user.LastIpAddress = _webHelper.GetCurrentIpAddress();
120 |
121 | _userRepository.Update(user);
122 | }
123 |
124 | ///
125 | /// If email exist.
126 | ///
127 | /// true, if the email is exist, false otherwise.
128 | /// Email.
129 | public bool EmailExist(string email)
130 | {
131 | if (string.IsNullOrEmpty(email))
132 | throw new ArgumentNullException(nameof(email));
133 |
134 | var query = from u in _userRepository.Table
135 | where u.Email.Equals(email)
136 | select u;
137 | return query.Any();
138 | }
139 |
140 |
141 | #endregion
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Tasks/TaskThread.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Threading;
5 |
6 | namespace Green.Services.Tasks
7 | {
8 | ///
9 | /// Represents task thread
10 | ///
11 | public partial class TaskThread : IDisposable
12 | {
13 | private Timer _timer;
14 | private bool _disposed;
15 | private readonly Dictionary _tasks;
16 |
17 | internal TaskThread()
18 | {
19 | this._tasks = new Dictionary();
20 | this.Seconds = 10 * 60;
21 | }
22 |
23 | private void Run()
24 | {
25 | if (Seconds <= 0)
26 | return;
27 |
28 | this.StartedUtc = DateTime.UtcNow;
29 | this.IsRunning = true;
30 | foreach (Task task in this._tasks.Values)
31 | {
32 | task.Execute();
33 | }
34 | this.IsRunning = false;
35 | }
36 |
37 | private void TimerHandler(object state)
38 | {
39 | this._timer.Change(-1, -1);
40 | this.Run();
41 | if (this.RunOnlyOnce)
42 | {
43 | this.Dispose();
44 | }
45 | else
46 | {
47 | this._timer.Change(this.Interval, this.Interval);
48 | }
49 | }
50 |
51 | ///
52 | /// Disposes the instance
53 | ///
54 | public void Dispose()
55 | {
56 | if ((this._timer != null) && !this._disposed)
57 | {
58 | lock (this)
59 | {
60 | this._timer.Dispose();
61 | this._timer = null;
62 | this._disposed = true;
63 | }
64 | }
65 | }
66 |
67 | ///
68 | /// Inits a timer
69 | ///
70 | public void InitTimer()
71 | {
72 | if (this._timer == null)
73 | {
74 | this._timer = new Timer(new TimerCallback(this.TimerHandler), null, this.Interval, this.Interval);
75 | }
76 | }
77 |
78 | ///
79 | /// Adds a task to the thread
80 | ///
81 | /// The task to be added
82 | public void AddTask(Task task)
83 | {
84 | if (!this._tasks.ContainsKey(task.Name))
85 | {
86 | this._tasks.Add(task.Name, task);
87 | }
88 | }
89 |
90 |
91 | ///
92 | /// Gets or sets the interval in seconds at which to run the tasks
93 | ///
94 | public int Seconds { get; set; }
95 |
96 | ///
97 | /// Get or sets a datetime when thread has been started
98 | ///
99 | public DateTime StartedUtc { get; private set; }
100 |
101 | ///
102 | /// Get or sets a value indicating whether thread is running
103 | ///
104 | public bool IsRunning { get; private set; }
105 |
106 | ///
107 | /// Get a list of tasks
108 | ///
109 | public IList Tasks
110 | {
111 | get
112 | {
113 | var list = new List();
114 | foreach (var task in this._tasks.Values)
115 | {
116 | list.Add(task);
117 | }
118 | return new ReadOnlyCollection(list);
119 | }
120 | }
121 |
122 | ///
123 | /// Gets the interval (in milliseconds) at which to run the task
124 | ///
125 | public int Interval
126 | {
127 | get
128 | {
129 | //if somobody entered more than "2147483" seconds, then an exception could be thrown (exceeds int.MaxValue)
130 | int interval = this.Seconds * 1000;
131 | if (interval <= 0)
132 | interval = int.MaxValue;
133 | return interval;
134 | }
135 | }
136 |
137 | ///
138 | /// Gets or sets a value indicating whether the thread whould be run only once (per appliction start)
139 | ///
140 | public bool RunOnlyOnce { get; set; }
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | If you're reading this, you're awesome! Thank you for helping us make this project great and being a part of the React Social Network community. Here are a few guidelines that will help you along the way.
4 |
5 | ## Asking Questions
6 |
7 | For how-to questions and other non-issues, please use [Gitter](https://gitter.im/react-social-network/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) chat instead of Github issues.
8 |
9 | ## Opening an Issue
10 |
11 | If you think you have found a bug, or have a new feature idea, please start by making sure it hasn't already been [reported or fixed](https://github.com/Qolzam/aspnet-core-social-network/issues?utf8=%E2%9C%93&q=is:open+is:closed). You can search through existing issues and PRs to see if someone has reported one similar to yours.
12 |
13 | Next, create a new issue that briefly explains the problem, and provides a bit of background as to the circumstances that triggered it, and steps to reproduce it.
14 |
15 | For code issues please include:
16 | * ASP.NET Core Social Network version
17 | * ASP.NET Core version
18 | * A code example or link to a repo, gist or running site.
19 |
20 | For visual or layout problems, images or animated gifs can help explain your issue.
21 | It's even better with a live reproduction test case. Have a look at the [`ISSUE_TEMPLATE.md`](https://github.com/Qolzam/aspnet-core-social-network/blob/master/.github/ISSUE_TEMPLATE.md) file for a live playground example.
22 |
23 | ### Issue Guidelines
24 |
25 | Please Use a succinct description. "doesn't work" doesn't help others find similar issues.
26 |
27 | Please don't group multiple topics into one issue, but instead each should be its own issue.
28 |
29 | And please don't just '+1' an issue. It spams the maintainers and doesn't help move the issue forward.
30 |
31 | ## Submitting a Pull Request
32 |
33 | ASP.NET Core Social Network is a community project, so pull requests are always welcome, but before working on a large change, it is best to open an issue first to discuss it with the maintainers.
34 |
35 | When in doubt, keep your pull requests small. To give a PR the best chance of getting accepted, don't bundle more than one feature or bug fix per pull request. It's always best to create two smaller PRs than one big one.
36 |
37 | As with issues, please begin the title with [LayerName].
38 |
39 | When adding new features or modifying existing code, please attempt to include tests to confirm the new behaviour. You can read more about our test setup [here](https://qolzam.gitbooks.io/aspnet-core-social-network/layers/tests.html).
40 |
41 | ### Branch Structure
42 |
43 | All stable releases are tagged ([view tags](https://github.com/Qolzam/aspnet-core-social-network/tags)). At any given time, `master` represents the latest development version of the library.
44 |
45 | #### `master` is unsafe
46 |
47 | We will do our best to keep `master` in good shape, with tests passing at all times. But in order to move fast, we will make API changes that your application might not be compatible with.
48 |
49 | ## Getting started
50 |
51 | Please create a new branch from an up to date master on your fork. (Note, urgent hotfixes should be branched off the latest stable release rather than master)
52 |
53 | 1. Fork the [aspnet-core-social-network](https://github.com/Qolzam/aspnet-core-social-network) repository on Github
54 | 2. Clone your fork to your local machine `git clone --depth 1 git@github.com:/aspnet-core-social-network.git`
55 | 3. Create a branch `git checkout -b my-topic-branch`
56 | 4. Make your changes, lint, then push to github with `git push --set-upstream origin my-topic-branch`.
57 | 5. Visit github and make your pull request.
58 |
59 | If you have an existing local repository, please update it before you start, to minimize the chance of merge conflicts.
60 | ```js
61 | git remote add upstream git@github.com:Qolzam/aspnet-core-social-network.git
62 | git checkout master
63 | git pull upstream master
64 | git checkout -b my-topic-branch
65 | ```
66 |
67 | ### Testing & documentation site
68 |
69 | The documentation site is built with [GitBook](https://www.gitbook.com/book/qolzam/aspnet-core-social-network/details), so you just need to edit `*.md` files. You can easily edit whole documentation files form `docs` folder.
70 |
71 | Test coverage is limited at present, but where possible, please add tests for any changes you make.
72 |
73 | ### Coding style
74 |
75 | Please follow the coding style of the current code base. ASP.NET Core Social Network uses [Framework Design Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/index), so if possible, follow the guide lines to have a clean code.
76 |
77 | ## License
78 |
79 | By contributing your code to the qolzam/aspnet-core-social-network GitHub repository, you agree to license your contribution under the MIT license.
80 |
--------------------------------------------------------------------------------
/Libraries/Green.Core/Domain/Posts/Post.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Green.Core.Domain.Comments;
4 | using Green.Core.Domain.Users;
5 | using Green.Core.Domain.Votes;
6 |
7 | namespace Green.Core.Domain.Posts
8 | {
9 | public class Post : BaseEntity
10 | {
11 |
12 | private ICollection _votes;
13 | private ICollection _comments;
14 |
15 |
16 | ///
17 | /// Gets or sets the body of post.
18 | ///
19 | /// The body of post.
20 | public string Body
21 | {
22 | get;
23 | set;
24 | }
25 |
26 | ///
27 | /// Gets or sets the commnet counter.
28 | ///
29 | /// The commnet counter.
30 | public int CommnetCounter
31 | {
32 | get;
33 | set;
34 | }
35 |
36 | ///
37 | /// Gets or sets the deleted date on UTC.
38 | ///
39 | /// The deleted date on UTC.
40 | public DateTime DeletedDateOnUtc
41 | {
42 | get;
43 | set;
44 | }
45 |
46 | ///
47 | /// Gets or sets a value indicating whether this is deleted.
48 | ///
49 | /// true if deleted; otherwise, false.
50 | public bool Deleted
51 | {
52 | get;
53 | set;
54 | }
55 |
56 | ///
57 | /// Gets or sets a value indicating whether this disable comment.
58 | ///
59 | /// true if disable comment; otherwise, false.
60 | public bool DisableComment
61 | {
62 | get;
63 | set;
64 | }
65 |
66 | ///
67 | /// Gets or sets a value indicating whether this disable sharing.
68 | ///
69 | /// true if disable sharing; otherwise, false.
70 | public bool DisableSharing
71 | {
72 | get;
73 | set;
74 | }
75 |
76 | ///
77 | /// Gets or sets the image identifier.
78 | ///
79 | /// The image identifier.
80 | public int ImageId
81 | {
82 | get;
83 | set;
84 | }
85 |
86 | ///
87 | /// Gets or sets the last edit on UTC.
88 | ///
89 | /// The last edit on UTC.
90 | public DateTime LastEditOnUtc
91 | {
92 | get;
93 | set;
94 | }
95 |
96 | ///
97 | /// Gets or sets the owner user identifier.
98 | ///
99 | /// The owner user identifier.
100 | public int OwnerUserId
101 | {
102 | get;
103 | set;
104 | }
105 |
106 | ///
107 | /// Gets or sets the post type identifier.
108 | ///
109 | /// The post type identifier.
110 | public int PostTypeId
111 | {
112 | get;
113 | set;
114 | }
115 |
116 | ///
117 | /// Gets or sets the score.
118 | ///
119 | /// The score.
120 | public int Score
121 | {
122 | get;
123 | set;
124 | }
125 |
126 | ///
127 | /// Gets or sets the view count.
128 | ///
129 | /// The view count.
130 | public int ViewCount
131 | {
132 | get;
133 | set;
134 | }
135 |
136 |
137 | #region Navigation properties
138 |
139 | ///
140 | /// Gets or sets the owner.
141 | ///
142 | /// The owner.
143 | public User Owner
144 | {
145 | get;
146 | set;
147 | }
148 |
149 | ///
150 | /// Gets or sets the votes.
151 | ///
152 | /// The votes.
153 | public virtual ICollection Votes
154 | {
155 | get { return _votes ?? (_votes = new List()); }
156 | protected set { _votes = value; }
157 | }
158 |
159 | ///
160 | /// Gets or sets the commnets.
161 | ///
162 | /// The commnets.
163 | public virtual ICollection Comments
164 | {
165 | get { return _comments ?? (_comments = new List()); }
166 | protected set { _comments = value; }
167 | }
168 |
169 | #endregion
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Authentication/CookieAuthenticationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Security.Claims;
4 | using System.Threading.Tasks;
5 | using Green.Core.Domain.Users;
6 | using Green.Services.Users;
7 | using Microsoft.AspNetCore.Authentication;
8 | using Microsoft.AspNetCore.Authentication.Cookies;
9 | using Microsoft.AspNetCore.Http;
10 |
11 |
12 | namespace Green.Services.Authentication
13 | {
14 | ///
15 | /// Represents service using cookie middleware for the authentication
16 | ///
17 | public partial class CookieAuthenticationService : IAuthenticationService
18 | {
19 | #region Fields
20 |
21 | private readonly IUserService _userService;
22 | private readonly IHttpContextAccessor _httpContextAccessor;
23 |
24 | private User _cachedUser;
25 |
26 | #endregion
27 |
28 | #region Ctor
29 |
30 | public CookieAuthenticationService(
31 | IUserService userService,
32 | IHttpContextAccessor httpContextAccessor)
33 | {
34 | this._userService = userService;
35 | this._httpContextAccessor = httpContextAccessor;
36 | }
37 |
38 | #endregion
39 |
40 | #region Methods
41 |
42 | ///
43 | /// Sign in
44 | ///
45 | /// User
46 | /// Whether the authentication session is persisted across multiple requests
47 | public virtual void SignIn(User user, bool isPersistent)
48 | {
49 | var httpContext = _httpContextAccessor.HttpContext;
50 |
51 | //create claims for username and email of the user
52 | var claims = new[]
53 | {
54 | new Claim(ClaimTypes.Name, user.FullName, ClaimValueTypes.String, GreenCookieAuthenticationDefaults.ClaimsIssuer),
55 | new Claim(ClaimTypes.Email, user.Email, ClaimValueTypes.Email, GreenCookieAuthenticationDefaults.ClaimsIssuer)
56 | };
57 |
58 | //create principal for the current authentication scheme
59 | var userIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
60 | var userPrincipal = new ClaimsPrincipal(userIdentity);
61 |
62 | //set value indicating whether session is persisted and the time at which the authentication was issued
63 | var authenticationProperties = new AuthenticationProperties
64 | {
65 | IsPersistent = isPersistent,
66 | IssuedUtc = DateTime.UtcNow
67 | };
68 |
69 | //sign in
70 | httpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, userPrincipal, authenticationProperties).Wait();
71 |
72 |
73 | //cache authenticated user
74 | _cachedUser = user;
75 | }
76 |
77 | ///
78 | /// Sign out
79 | ///
80 | public virtual void SignOut()
81 | {
82 | var httpContext = _httpContextAccessor.HttpContext;
83 |
84 |
85 | //reset cached user
86 | _cachedUser = null;
87 |
88 | //and sign out from the current authentication scheme
89 | var signOutTask = httpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
90 | signOutTask.Wait();
91 | }
92 |
93 | ///
94 | /// Get authenticated user
95 | ///
96 | /// User
97 | public virtual User GetAuthenticatedUser()
98 | {
99 |
100 | var httpContext = _httpContextAccessor.HttpContext;
101 |
102 | //whether there is a cached user
103 | if (_cachedUser != null)
104 | return _cachedUser;
105 |
106 |
107 | //try to get authenticated user identity
108 | var authenticateTask = httpContext.AuthenticateAsync(CookieAuthenticationDefaults.AuthenticationScheme);
109 | var userPrincipal = authenticateTask.Result;
110 | var userIdentity = userPrincipal?.Principal.Identities?.FirstOrDefault(identity => identity.IsAuthenticated);
111 | if (userIdentity == null)
112 | return null;
113 |
114 | User user = null;
115 |
116 | //try to get user by email
117 | var emailClaim = userIdentity.FindFirst(claim => claim.Type == ClaimTypes.Email
118 | && claim.Issuer.Equals(GreenCookieAuthenticationDefaults.ClaimsIssuer, StringComparison.InvariantCultureIgnoreCase));
119 | if (emailClaim != null)
120 | user = _userService.GetUserByEmail(emailClaim.Value);
121 |
122 | //whether the found user is available
123 | if (user == null || !user.Active || user.Deleted)
124 | return null;
125 |
126 | //cache authenticated user
127 | _cachedUser = user;
128 |
129 | return _cachedUser;
130 | }
131 |
132 | #endregion
133 | }
134 | }
--------------------------------------------------------------------------------
/Presentation/Green.Web.Framework/Infrastracture/Extensions/ApplicationBuilderExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Diagnostics;
3 | using Microsoft.AspNetCore.Http;
4 | using Green.Core;
5 | using Green.Core.Infrastructure;
6 |
7 | namespace Green.Web.Framework.Infrastructure.Extensions
8 | {
9 | ///
10 | /// Represents extensions of IApplicationBuilder
11 | ///
12 | public static class ApplicationBuilderExtensions
13 | {
14 | ///
15 | /// Configure the application HTTP request pipeline
16 | ///
17 | /// Builder for configuring an application's request pipeline
18 | public static void ConfigureRequestPipeline(this IApplicationBuilder application)
19 | {
20 | EngineContext.Current.ConfigureRequestPipeline(application);
21 | }
22 |
23 | ///
24 | /// Add exception handling
25 | ///
26 | /// Builder for configuring an application's request pipeline
27 | /// Whether to use detailed exception page
28 | public static void UseExceptionHandler(this IApplicationBuilder application, bool useDetailedExceptionPage)
29 | {
30 | if (useDetailedExceptionPage)
31 | {
32 | //get detailed exceptions for developing and testing purposes
33 | application.UseDeveloperExceptionPage();
34 | }
35 | else
36 | {
37 | //or use special exception handler
38 | application.UseExceptionHandler("/errorpage.htm");
39 | }
40 | }
41 |
42 | ///
43 | /// Adds a special handler that checks for responses with the 404 status code that do not have a body
44 | ///
45 | /// Builder for configuring an application's request pipeline
46 | public static void UsePageNotFound(this IApplicationBuilder application)
47 | {
48 | application.UseStatusCodePages(async context =>
49 | {
50 | //handle 404 Not Found
51 | if (context.HttpContext.Response.StatusCode == 404)
52 | {
53 | var webHelper = EngineContext.Current.Resolve();
54 | if (!webHelper.IsStaticResource())
55 | {
56 | //get original path and query
57 | var originalPath = context.HttpContext.Request.Path;
58 | var originalQueryString = context.HttpContext.Request.QueryString;
59 |
60 | //store the original paths in special feature, so we can use it later
61 | context.HttpContext.Features.Set(new StatusCodeReExecuteFeature()
62 | {
63 | OriginalPathBase = context.HttpContext.Request.PathBase.Value,
64 | OriginalPath = originalPath.Value,
65 | OriginalQueryString = originalQueryString.HasValue ? originalQueryString.Value : null,
66 | });
67 |
68 | //get new path
69 | context.HttpContext.Request.Path = "/page-not-found";
70 | context.HttpContext.Request.QueryString = QueryString.Empty;
71 |
72 | try
73 | {
74 | //re-execute request with new path
75 | await context.Next(context.HttpContext);
76 | }
77 | finally
78 | {
79 | //return original path to request
80 | context.HttpContext.Request.QueryString = originalQueryString;
81 | context.HttpContext.Request.Path = originalPath;
82 | context.HttpContext.Features.Set(null);
83 | }
84 | }
85 | }
86 | });
87 | }
88 |
89 |
90 | ///
91 | /// Congifure authentication
92 | ///
93 | /// Builder for configuring an application's request pipeline
94 | public static void UseGreenAuthentication(this IApplicationBuilder application)
95 | {
96 | //check whether database is installed
97 |
98 | application.UseAuthentication();
99 |
100 | }
101 |
102 | ///
103 | /// Configure MVC routing
104 | ///
105 | /// Builder for configuring an application's request pipeline
106 | public static void UseGreenMvc(this IApplicationBuilder application)
107 | {
108 | application.UseMvc(routes =>
109 | {
110 | //register all routes
111 | routes.MapRoute(
112 | name: "default",
113 | template: "{controller=User/action=Get}");
114 |
115 | });
116 | }
117 |
118 |
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Libraries/Green.Data/EfRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Green.Core;
5 | using Green.Core.Data;
6 | using Microsoft.EntityFrameworkCore;
7 |
8 | namespace Green.Data
9 | {
10 | ///
11 | /// Entity Framework repository
12 | ///
13 | public partial class EfRepository : IRepository where T : class
14 | {
15 | #region Fields
16 |
17 | private readonly GreenObjectContext _context;
18 | private DbSet _entities;
19 |
20 | #endregion
21 |
22 | #region Ctor
23 |
24 | ///
25 | /// Ctor
26 | ///
27 | /// Object context
28 | public EfRepository(GreenObjectContext context)
29 | {
30 | this._context = context;
31 | }
32 |
33 | #endregion
34 |
35 | #region Utilities
36 |
37 | ///
38 | /// Get full error
39 | ///
40 | /// Exception
41 | /// Error
42 | protected string GetFullErrorText(Exception exc)
43 | {
44 | return exc.Message;
45 | }
46 |
47 | #endregion
48 |
49 | #region Methods
50 |
51 | ///
52 | /// Get entity by identifier
53 | ///
54 | /// Identifier
55 | /// Entity
56 | public virtual T GetById(object id)
57 | {
58 | return this.Entities.Find(id);
59 | }
60 |
61 | ///
62 | /// Insert entity
63 | ///
64 | /// Entity
65 | public virtual void Insert(T entity)
66 | {
67 | try
68 | {
69 | if (entity == null)
70 | throw new ArgumentNullException(nameof(entity));
71 |
72 | this.Entities.Add(entity);
73 |
74 | this._context.SaveChanges();
75 | }
76 | catch (Exception dbEx)
77 | {
78 | throw new Exception(GetFullErrorText(dbEx), dbEx);
79 | }
80 | }
81 |
82 | ///
83 | /// Insert entities
84 | ///
85 | /// Entities
86 | public virtual void Insert(IEnumerable entities)
87 | {
88 | try
89 | {
90 | if (entities == null)
91 | throw new ArgumentNullException(nameof(entities));
92 |
93 | foreach (var entity in entities)
94 | this.Entities.Add(entity);
95 | this._context.SaveChanges();
96 | }
97 | catch (Exception dbEx)
98 | {
99 | throw new Exception(GetFullErrorText(dbEx), dbEx);
100 | }
101 | }
102 |
103 | ///
104 | /// Update entity
105 | ///
106 | /// Entity
107 | public virtual void Update(T entity)
108 | {
109 | try
110 | {
111 | if (entity == null)
112 | throw new ArgumentNullException(nameof(entity));
113 |
114 | this._context.SaveChanges();
115 | }
116 | catch (Exception dbEx)
117 | {
118 | throw new Exception(GetFullErrorText(dbEx), dbEx);
119 | }
120 | }
121 |
122 | ///
123 | /// Update entities
124 | ///
125 | /// Entities
126 | public virtual void Update(IEnumerable entities)
127 | {
128 | try
129 | {
130 | if (entities == null)
131 | throw new ArgumentNullException(nameof(entities));
132 |
133 | this._context.SaveChanges();
134 | }
135 | catch (Exception dbEx)
136 | {
137 | throw new Exception(GetFullErrorText(dbEx), dbEx);
138 | }
139 | }
140 |
141 | ///
142 | /// Delete entity
143 | ///
144 | /// Entity
145 | public virtual void Delete(T entity)
146 | {
147 | try
148 | {
149 | if (entity == null)
150 | throw new ArgumentNullException(nameof(entity));
151 |
152 | this.Entities.Remove(entity);
153 |
154 | this._context.SaveChanges();
155 | }
156 | catch (Exception dbEx)
157 | {
158 | throw new Exception(GetFullErrorText(dbEx), dbEx);
159 | }
160 | }
161 |
162 | ///
163 | /// Delete entities
164 | ///
165 | /// Entities
166 | public virtual void Delete(IEnumerable entities)
167 | {
168 | try
169 | {
170 | if (entities == null)
171 | throw new ArgumentNullException(nameof(entities));
172 |
173 | foreach (var entity in entities)
174 | this.Entities.Remove(entity);
175 |
176 | this._context.SaveChanges();
177 | }
178 | catch (Exception dbEx)
179 | {
180 | throw new Exception(GetFullErrorText(dbEx), dbEx);
181 | }
182 | }
183 |
184 | #endregion
185 |
186 | #region Properties
187 |
188 | ///
189 | /// Gets a table
190 | ///
191 | public virtual IQueryable Table
192 | {
193 | get
194 | {
195 | return this.Entities;
196 | }
197 | }
198 |
199 | ///
200 | /// Gets a table with "no tracking" enabled (EF feature) Use it only when you load record(s) only for read-only operations
201 | ///
202 | public virtual IQueryable TableNoTracking
203 | {
204 | get
205 | {
206 | return this.Entities.AsNoTracking();
207 | }
208 | }
209 |
210 | ///
211 | /// Entities
212 | ///
213 | protected virtual DbSet Entities
214 | {
215 | get
216 | {
217 | if (_entities == null)
218 | _entities = _context.Set();
219 | return _entities;
220 | }
221 | }
222 |
223 | #endregion
224 | }
225 | }
--------------------------------------------------------------------------------
/Libraries/Green.Services/Tasks/Task.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Green.Core.Domain.Tasks;
3 | using Green.Core.Infrastructure;
4 |
5 | namespace Green.Services.Tasks
6 | {
7 | ///
8 | /// Task
9 | ///
10 | public partial class Task
11 | {
12 | #region Ctor
13 |
14 | ///
15 | /// Ctor for Task
16 | ///
17 | private Task()
18 | {
19 | this.Enabled = true;
20 | }
21 |
22 | ///
23 | /// Ctor for Task
24 | ///
25 | /// Task
26 | public Task(ScheduleTask task)
27 | {
28 | this.Type = task.Type;
29 | this.Enabled = task.Enabled;
30 | this.StopOnError = task.StopOnError;
31 | this.Name = task.Name;
32 | this.LastSuccessUtc = task.LastSuccessUtc;
33 | }
34 |
35 | #endregion
36 |
37 | #region Utilities
38 |
39 | private ITask CreateTask()
40 | {
41 | if (!this.Enabled)
42 | return null;
43 |
44 | var type = System.Type.GetType(this.Type);
45 | if (type == null)
46 | return null;
47 |
48 | object instance = null;
49 | try
50 | {
51 | instance = EngineContext.Current.Resolve(type);
52 | }
53 | catch
54 | {
55 | //try resolve
56 | }
57 | if (instance == null)
58 | {
59 | //not resolved
60 | instance = EngineContext.Current.ResolveUnregistered(type);
61 | }
62 |
63 | return instance as ITask;
64 | }
65 |
66 | #endregion
67 |
68 | #region Methods
69 |
70 | ///
71 | /// Executes the task
72 | ///
73 | /// A value indicating whether exception should be thrown if some error happens
74 | public void Execute(bool throwException = false)
75 | {
76 | var scheduleTaskService = EngineContext.Current.Resolve();
77 | var scheduleTask = scheduleTaskService.GetTaskByType(this.Type);
78 |
79 | try
80 | {
81 | //flag that task is already executed
82 | var taskExecuted = false;
83 |
84 | //execute task in case if is not executed yet
85 | if (!taskExecuted)
86 | {
87 | //initialize and execute
88 | var task = this.CreateTask();
89 | if (task != null)
90 | {
91 | this.LastStartUtc = DateTime.UtcNow;
92 | if (scheduleTask != null)
93 | {
94 | //update appropriate datetime properties
95 | scheduleTask.LastStartUtc = this.LastStartUtc;
96 | scheduleTaskService.UpdateTask(scheduleTask);
97 | }
98 | task.Execute();
99 | this.LastEndUtc = this.LastSuccessUtc = DateTime.UtcNow;
100 | }
101 | }
102 | }
103 | catch (Exception)
104 | {
105 | this.Enabled = !this.StopOnError;
106 | this.LastEndUtc = DateTime.UtcNow;
107 |
108 | if (throwException)
109 | throw;
110 | }
111 |
112 | if (scheduleTask != null)
113 | {
114 | //update appropriate datetime properties
115 | scheduleTask.LastEndUtc = this.LastEndUtc;
116 | scheduleTask.LastSuccessUtc = this.LastSuccessUtc;
117 | scheduleTaskService.UpdateTask(scheduleTask);
118 | }
119 | }
120 |
121 | #endregion
122 |
123 | #region Properties
124 |
125 | ///
126 | /// Datetime of the last start
127 | ///
128 | public DateTime? LastStartUtc { get; private set; }
129 |
130 | ///
131 | /// Datetime of the last end
132 | ///
133 | public DateTime? LastEndUtc { get; private set; }
134 |
135 | ///
136 | /// Datetime of the last success
137 | ///
138 | public DateTime? LastSuccessUtc { get; private set; }
139 |
140 | ///
141 | /// A value indicating type of the task
142 | ///
143 | public string Type { get; private set; }
144 |
145 | ///
146 | /// A value indicating whether to stop task on error
147 | ///
148 | public bool StopOnError { get; private set; }
149 |
150 | ///
151 | /// Get the task name
152 | ///
153 | public string Name { get; private set; }
154 |
155 | ///
156 | /// A value indicating whether the task is enabled
157 | ///
158 | public bool Enabled { get; set; }
159 |
160 | #endregion
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/GreenSocialNetwork.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{1519F35B-ADD7-4336-A975-B63093B48259}"
5 | EndProject
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{8DE536B7-6E73-416E-9A53-1C8D8DF0AAC3}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{9B70B7B8-806C-4FC2-9217-70481CEC0F61}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Green.Core", "Libraries\Green.Core\Green.Core.csproj", "{6CF1BC48-043B-4F11-A93C-E8D576CA3735}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Green.Data", "Libraries\Green.Data\Green.Data.csproj", "{1F3756DF-C3EC-4CA4-9F6F-EE201A203D6E}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Green.Services", "Libraries\Green.Services\Green.Services.csproj", "{6CBBEDC0-0B65-4134-BD69-5C860A94378E}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Green.Web.Framework", "Presentation\Green.Web.Framework\Green.Web.Framework.csproj", "{2AA2F84B-4ECD-4C73-9610-F54762D7A368}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Green.Web", "Presentation\Green.Web\Green.Web.csproj", "{F2A6CC80-69EA-4900-B6BE-14CEC019A30C}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Release|Any CPU = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {6CF1BC48-043B-4F11-A93C-E8D576CA3735}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {6CF1BC48-043B-4F11-A93C-E8D576CA3735}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {6CF1BC48-043B-4F11-A93C-E8D576CA3735}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {6CF1BC48-043B-4F11-A93C-E8D576CA3735}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {734ED745-A22C-4974-BCAC-B080EEA511F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {734ED745-A22C-4974-BCAC-B080EEA511F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {734ED745-A22C-4974-BCAC-B080EEA511F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {734ED745-A22C-4974-BCAC-B080EEA511F9}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {6AEE649C-DBE5-4D8C-AA3D-6497489FA3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {6AEE649C-DBE5-4D8C-AA3D-6497489FA3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {6AEE649C-DBE5-4D8C-AA3D-6497489FA3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {6AEE649C-DBE5-4D8C-AA3D-6497489FA3A7}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {CE5518DB-A0FE-4850-9A26-D11E7F4B40FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {CE5518DB-A0FE-4850-9A26-D11E7F4B40FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {CE5518DB-A0FE-4850-9A26-D11E7F4B40FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {CE5518DB-A0FE-4850-9A26-D11E7F4B40FB}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {66022CDA-F859-4FA3-9041-8E9C188D24F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {66022CDA-F859-4FA3-9041-8E9C188D24F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {66022CDA-F859-4FA3-9041-8E9C188D24F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {66022CDA-F859-4FA3-9041-8E9C188D24F4}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {1F3756DF-C3EC-4CA4-9F6F-EE201A203D6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {1F3756DF-C3EC-4CA4-9F6F-EE201A203D6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {1F3756DF-C3EC-4CA4-9F6F-EE201A203D6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {1F3756DF-C3EC-4CA4-9F6F-EE201A203D6E}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {6CBBEDC0-0B65-4134-BD69-5C860A94378E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {6CBBEDC0-0B65-4134-BD69-5C860A94378E}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {6CBBEDC0-0B65-4134-BD69-5C860A94378E}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {6CBBEDC0-0B65-4134-BD69-5C860A94378E}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {2AA2F84B-4ECD-4C73-9610-F54762D7A368}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {2AA2F84B-4ECD-4C73-9610-F54762D7A368}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {2AA2F84B-4ECD-4C73-9610-F54762D7A368}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {2AA2F84B-4ECD-4C73-9610-F54762D7A368}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {F2A6CC80-69EA-4900-B6BE-14CEC019A30C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59 | {F2A6CC80-69EA-4900-B6BE-14CEC019A30C}.Debug|Any CPU.Build.0 = Debug|Any CPU
60 | {F2A6CC80-69EA-4900-B6BE-14CEC019A30C}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {F2A6CC80-69EA-4900-B6BE-14CEC019A30C}.Release|Any CPU.Build.0 = Release|Any CPU
62 | EndGlobalSection
63 | GlobalSection(NestedProjects) = preSolution
64 | {6CF1BC48-043B-4F11-A93C-E8D576CA3735} = {1519F35B-ADD7-4336-A975-B63093B48259}
65 | {734ED745-A22C-4974-BCAC-B080EEA511F9} = {1519F35B-ADD7-4336-A975-B63093B48259}
66 | {6AEE649C-DBE5-4D8C-AA3D-6497489FA3A7} = {1519F35B-ADD7-4336-A975-B63093B48259}
67 | {CE5518DB-A0FE-4850-9A26-D11E7F4B40FB} = {8DE536B7-6E73-416E-9A53-1C8D8DF0AAC3}
68 | {66022CDA-F859-4FA3-9041-8E9C188D24F4} = {8DE536B7-6E73-416E-9A53-1C8D8DF0AAC3}
69 | {1F3756DF-C3EC-4CA4-9F6F-EE201A203D6E} = {1519F35B-ADD7-4336-A975-B63093B48259}
70 | {6CBBEDC0-0B65-4134-BD69-5C860A94378E} = {1519F35B-ADD7-4336-A975-B63093B48259}
71 | {2AA2F84B-4ECD-4C73-9610-F54762D7A368} = {8DE536B7-6E73-416E-9A53-1C8D8DF0AAC3}
72 | {F2A6CC80-69EA-4900-B6BE-14CEC019A30C} = {8DE536B7-6E73-416E-9A53-1C8D8DF0AAC3}
73 | EndGlobalSection
74 | EndGlobal
75 |
--------------------------------------------------------------------------------
/Libraries/Green.Services/Configuration/ISettingService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq.Expressions;
4 | using Green.Core.Configuration;
5 | using Green.Core.Domain.Configuration;
6 |
7 | namespace Green.Services.Configuration
8 | {
9 | ///
10 | /// Setting service interface
11 | ///
12 | public partial interface ISettingService
13 | {
14 | ///
15 | /// Gets a setting by identifier
16 | ///
17 | /// Setting identifier
18 | /// Setting
19 | Setting GetSettingById(int settingId);
20 |
21 | ///
22 | /// Deletes a setting
23 | ///
24 | /// Setting
25 | void DeleteSetting(Setting setting);
26 |
27 | ///
28 | /// Deletes settings
29 | ///
30 | /// Settings
31 | void DeleteSettings(IList settings);
32 |
33 | ///
34 | /// Get setting by key
35 | ///
36 | /// Key
37 | /// A value indicating whether a shared value should be loaded if a value specific for a certain is not found
38 | /// Setting
39 | Setting GetSetting(string key, bool loadSharedValueIfNotFound = false);
40 |
41 | ///
42 | /// Get setting value by key
43 | ///
44 | /// Type
45 | /// Key
46 | /// Default value
47 | /// A value indicating whether a shared value should be loaded if a value specific for a certain is not found
48 | /// Setting value
49 | T GetSettingByKey(string key, T defaultValue = default(T), bool loadSharedValueIfNotFound = false);
50 |
51 | ///
52 | /// Set setting value
53 | ///
54 | /// Type
55 | /// Key
56 | /// Value
57 | void SetSetting(string key, T value);
58 |
59 | ///
60 | /// Gets all settings
61 | ///
62 | /// Settings
63 | IList GetAllSettings();
64 |
65 | ///
66 | /// Determines whether a setting exists
67 | ///
68 | /// Entity type
69 | /// Property type
70 | /// Settings
71 | /// Key selector
72 | /// true -setting exists; false - does not exist
73 | bool SettingExists(T settings,
74 | Expression> keySelector)
75 | where T : ISettings, new();
76 |
77 | ///
78 | /// Load settings
79 | ///
80 | /// Type
81 | T LoadSetting() where T : ISettings, new();
82 | ///
83 | /// Load settings
84 | ///
85 | /// Type
86 | ISettings LoadSetting(Type type);
87 |
88 | ///
89 | /// Save settings object
90 | ///
91 | /// Type
92 | /// Setting instance
93 | void SaveSetting(T settings) where T : ISettings, new();
94 |
95 | ///
96 | /// Save settings object
97 | ///
98 | /// Entity type
99 | /// Property type
100 | /// Settings
101 | /// Key selector
102 | void SaveSetting(T settings,
103 | Expression> keySelector) where T : ISettings, new();
104 |
105 | ///
106 | /// Save settings object If the setting is not overridden then it'll be delete
107 | ///
108 | /// Entity type
109 | /// Property type
110 | /// Settings
111 | /// Key selector
112 | /// A value indicating whether to setting is overridden
113 | void SaveSettingOverridable(T settings,
114 | Expression> keySelector,
115 | bool overrideFor) where T : ISettings, new();
116 |
117 | ///
118 | /// Delete all settings
119 | ///
120 | /// Type
121 | void DeleteSetting() where T : ISettings, new();
122 |
123 | ///
124 | /// Delete settings object
125 | ///
126 | /// Entity type
127 | /// Property type
128 | /// Settings
129 | /// Key selector
130 | void DeleteSetting(T settings,
131 | Expression> keySelector) where T : ISettings, new();
132 |
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/docs/api/authorization.md:
--------------------------------------------------------------------------------
1 | # Authorization
2 |
3 | This api is responsible to authorize a user. It's also responsible to registed a new user and do some action relate to authorizaion.
4 |
5 | **Login User**
6 | ----
7 | Returns json data about the authorized user.
8 |
9 | * **URL**
10 |
11 | /api/authorization/login
12 |
13 | * **Method:**
14 |
15 | `POST`
16 |
17 | * **URL Params**
18 |
19 | **Required:**
20 |
21 | None
22 |
23 | * **Data Params**
24 |
25 | ```json
26 | {
27 | "email": "amir.gholzam@live.com",
28 | "password": "123456",
29 | "isPersistent": "true"
30 | }
31 | ```
32 |
33 | * **Success Response:**
34 |
35 | * **Code:** 200
36 | **Content:**
37 |
38 | ```json
39 | {
40 | "email": "amir.gholzam@live.com",
41 | "fullName": "Amir Movahedi",
42 | "tagLine": "Think positively",
43 | "key": "38fc2758-1f96-435d-80ea-c7944037964d",
44 | }
45 | ```
46 | * **Error Response:**
47 |
48 | * **Code:** 422 Unprocessable Entity
49 | **Content:**
50 |
51 | ```json
52 | {
53 | "errors": [
54 | "Email address can't be null or empty.",
55 | "Password can't be null or empty.",
56 | "Email address or password is wrong."
57 | ]
58 | }
59 | ```
60 | OR
61 |
62 | * **Code:** 401 Unauthorized
63 | **Content:**
64 |
65 | ```json
66 | {
67 | "errors": [
68 | "Email address or password is wrong.",
69 | "amir.gholzam@live.com user user is inactive.",
70 | "amir.gholzam@live.com user has been deleted."
71 | ]
72 | }
73 | ```
74 |
75 | * **Sample Call:**
76 |
77 | ```javascript
78 | axios({
79 | method: 'post',
80 | url: '/api/authorization/login',
81 | responseType: 'json',
82 | data: {
83 | email: 'amir.gholzam@live.com',
84 | password: '123456',
85 | isPersistent": "true
86 | }
87 | })
88 | ```
89 |
90 | **Signup User**
91 | ----
92 | Returns json data user key.
93 |
94 | * **URL**
95 |
96 | /api/authorization/signup
97 |
98 | * **Method:**
99 |
100 | `POST`
101 |
102 | * **URL Params**
103 |
104 | **Required:**
105 |
106 | None
107 |
108 | * **Data Params**
109 |
110 | ```json
111 | {
112 | "email": "amir.gholzam@live.com",
113 | "fullName": "Amir Movahedi",
114 | "password": "123456",
115 | "confirmPassword": "123456"
116 | }
117 | ```
118 |
119 | * **Success Response:**
120 |
121 | * **Code:** 200
122 | **Content:**
123 |
124 | ```json
125 | {
126 | "key": "38fc2758-1f96-435d-80ea-c7944037964d"
127 | }
128 | ```
129 | * **Error Response:**
130 |
131 | * **Code:** 422 Unprocessable Entity
132 | **Content:**
133 |
134 | ```json
135 | {
136 | "errors": [
137 | "Full name can't be null or empty.",
138 | "Email can't be null or empty.",
139 | "Password can't be null or empty.",
140 | "Confirm password can't be null or empty.",
141 | "Password and confirm password should be equal."
142 | ]
143 | }
144 | ```
145 |
146 | * **Sample Call:**
147 |
148 | ```javascript
149 | axios({
150 | method: 'post',
151 | url: '/api/authorization/signup',
152 | responseType: 'json',
153 | data: {
154 | email: "amir.gholzam@live.com",
155 | fullName: "Amir Movahedi",
156 | password: "123456",
157 | confirmPassword: "123456"
158 | }
159 | })
160 | ```
161 |
162 | **Logout User**
163 | ----
164 | Returns Ok status.
165 |
166 | * **URL**
167 |
168 | /api/authorization/logout
169 |
170 | * **Method:**
171 |
172 | `GET`
173 |
174 | * **URL Params**
175 |
176 | **Required:**
177 |
178 | None
179 |
180 | * **Data Params**
181 |
182 | None
183 |
184 | * **Success Response:**
185 |
186 | * **Code:** 200
187 | **Content:**
188 |
189 | None
190 |
191 | * **Error Response:**
192 |
193 | * **Code:** 403 Forbidden
194 | **Content:**
195 |
196 | ```json
197 | {
198 | "errors": [
199 | "User is not authorized to logout."
200 | ]
201 | }
202 | ```
203 |
204 | * **Sample Call:**
205 |
206 | ```javascript
207 | axios({
208 | method: 'get',
209 | url: '/api/authorization/logout'
210 | })
211 | ```
212 |
213 | **Update User Password**
214 | ----
215 | Returns Ok status.
216 |
217 | * **URL**
218 |
219 | /api/authorization/password
220 |
221 | * **Method:**
222 |
223 | `PUT`
224 |
225 | * **URL Params**
226 |
227 | **Required:**
228 |
229 | None
230 |
231 | * **Data Params**
232 |
233 | ```json
234 | {
235 | "newPassword": "123456",
236 | "confirmPassword": "123456"
237 | }
238 | ```
239 |
240 | * **Success Response:**
241 |
242 | * **Code:** 200
243 | **Content:**
244 |
245 | None
246 |
247 | * **Error Response:**
248 |
249 | * **Code:** 422 Unprocessable Entity
250 | **Content:**
251 |
252 | ```json
253 | {
254 | "errors": [
255 | "New password can't be null or empty.",
256 | "Confirm password can't be null or empty.",
257 | "New password and confirm password should be equal."
258 | ]
259 | }
260 | ```
261 | OR
262 |
263 | * **Code:** 403 Unauthorized
264 | **Content:**
265 |
266 | ```json
267 | {
268 | "errors": [
269 | "User is not authorized to update password."
270 | ]
271 | }
272 | ```
273 |
274 | * **Sample Call:**
275 |
276 | ```javascript
277 | axios({
278 | method: 'put',
279 | url: '/api/authorization/password',
280 | data: {
281 | newPassword: 'amir.gholzam@live.com',
282 | confirmPassword: '123456'
283 | }
284 | })
285 | ```
286 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # VS Code
2 | .vscode
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # Benchmark Results
44 | BenchmarkDotNet.Artifacts/
45 |
46 | # .NET Core
47 | project.lock.json
48 | project.fragment.lock.json
49 | artifacts/
50 | **/Properties/launchSettings.json
51 |
52 | *_i.c
53 | *_p.c
54 | *_i.h
55 | *.ilk
56 | *.meta
57 | *.obj
58 | *.pch
59 | *.pdb
60 | *.pgc
61 | *.pgd
62 | *.rsp
63 | *.sbr
64 | *.tlb
65 | *.tli
66 | *.tlh
67 | *.tmp
68 | *.tmp_proj
69 | *.log
70 | *.vspscc
71 | *.vssscc
72 | .builds
73 | *.pidb
74 | *.svclog
75 | *.scc
76 |
77 | # Chutzpah Test files
78 | _Chutzpah*
79 |
80 | # Visual C++ cache files
81 | ipch/
82 | *.aps
83 | *.ncb
84 | *.opendb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 | *.VC.db
89 | *.VC.VC.opendb
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 | *.sap
96 |
97 | # TFS 2012 Local Workspace
98 | $tf/
99 |
100 | # Guidance Automation Toolkit
101 | *.gpState
102 |
103 | # ReSharper is a .NET coding add-in
104 | _ReSharper*/
105 | *.[Rr]e[Ss]harper
106 | *.DotSettings.user
107 |
108 | # JustCode is a .NET coding add-in
109 | .JustCode
110 |
111 | # TeamCity is a build add-in
112 | _TeamCity*
113 |
114 | # DotCover is a Code Coverage Tool
115 | *.dotCover
116 |
117 | # Visual Studio code coverage results
118 | *.coverage
119 | *.coveragexml
120 |
121 | # NCrunch
122 | _NCrunch_*
123 | .*crunch*.local.xml
124 | nCrunchTemp_*
125 |
126 | # MightyMoose
127 | *.mm.*
128 | AutoTest.Net/
129 |
130 | # Web workbench (sass)
131 | .sass-cache/
132 |
133 | # Installshield output folder
134 | [Ee]xpress/
135 |
136 | # DocProject is a documentation generator add-in
137 | DocProject/buildhelp/
138 | DocProject/Help/*.HxT
139 | DocProject/Help/*.HxC
140 | DocProject/Help/*.hhc
141 | DocProject/Help/*.hhk
142 | DocProject/Help/*.hhp
143 | DocProject/Help/Html2
144 | DocProject/Help/html
145 |
146 | # Click-Once directory
147 | publish/
148 |
149 | # Publish Web Output
150 | *.[Pp]ublish.xml
151 | *.azurePubxml
152 | # TODO: Comment the next line if you want to checkin your web deploy settings
153 | # but database connection strings (with potential passwords) will be unencrypted
154 | *.pubxml
155 | *.publishproj
156 |
157 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
158 | # checkin your Azure Web App publish settings, but sensitive information contained
159 | # in these scripts will be unencrypted
160 | PublishScripts/
161 |
162 | # NuGet Packages
163 | *.nupkg
164 | # The packages folder can be ignored because of Package Restore
165 | **/packages/*
166 | # except build/, which is used as an MSBuild target.
167 | !**/packages/build/
168 | # Uncomment if necessary however generally it will be regenerated when needed
169 | #!**/packages/repositories.config
170 | # NuGet v3's project.json files produces more ignorable files
171 | *.nuget.props
172 | *.nuget.targets
173 |
174 | # Microsoft Azure Build Output
175 | csx/
176 | *.build.csdef
177 |
178 | # Microsoft Azure Emulator
179 | ecf/
180 | rcf/
181 |
182 | # Windows Store app package directories and files
183 | AppPackages/
184 | BundleArtifacts/
185 | Package.StoreAssociation.xml
186 | _pkginfo.txt
187 | *.appx
188 |
189 | # Visual Studio cache files
190 | # files ending in .cache can be ignored
191 | *.[Cc]ache
192 | # but keep track of directories ending in .cache
193 | !*.[Cc]ache/
194 |
195 | # Others
196 | ClientBin/
197 | ~$*
198 | *~
199 | *.dbmdl
200 | *.dbproj.schemaview
201 | *.jfm
202 | *.pfx
203 | *.publishsettings
204 | orleans.codegen.cs
205 |
206 | # Since there are multiple workflows, uncomment next line to ignore bower_components
207 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
208 | #bower_components/
209 |
210 | # RIA/Silverlight projects
211 | Generated_Code/
212 |
213 | # Backup & report files from converting an old project file
214 | # to a newer Visual Studio version. Backup files are not needed,
215 | # because we have git ;-)
216 | _UpgradeReport_Files/
217 | Backup*/
218 | UpgradeLog*.XML
219 | UpgradeLog*.htm
220 |
221 | # SQL Server files
222 | *.mdf
223 | *.ldf
224 | *.ndf
225 |
226 | # Business Intelligence projects
227 | *.rdl.data
228 | *.bim.layout
229 | *.bim_*.settings
230 |
231 | # Microsoft Fakes
232 | FakesAssemblies/
233 |
234 | # GhostDoc plugin setting file
235 | *.GhostDoc.xml
236 |
237 | # Node.js Tools for Visual Studio
238 | .ntvs_analysis.dat
239 | node_modules/
240 |
241 | # Typescript v1 declaration files
242 | typings/
243 |
244 | # Visual Studio 6 build log
245 | *.plg
246 |
247 | # Visual Studio 6 workspace options file
248 | *.opt
249 |
250 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
251 | *.vbw
252 |
253 | # Visual Studio LightSwitch build output
254 | **/*.HTMLClient/GeneratedArtifacts
255 | **/*.DesktopClient/GeneratedArtifacts
256 | **/*.DesktopClient/ModelManifest.xml
257 | **/*.Server/GeneratedArtifacts
258 | **/*.Server/ModelManifest.xml
259 | _Pvt_Extensions
260 |
261 | # Paket dependency manager
262 | .paket/paket.exe
263 | paket-files/
264 |
265 | # FAKE - F# Make
266 | .fake/
267 |
268 | # JetBrains Rider
269 | .idea/
270 | *.sln.iml
271 |
272 | # CodeRush
273 | .cr/
274 |
275 | # Python Tools for Visual Studio (PTVS)
276 | __pycache__/
277 | *.pyc
278 |
279 | # Cake - Uncomment if you are using it
280 | # tools/**
281 | # !tools/packages.config
282 |
283 | # Tabs Studio
284 | *.tss
285 |
286 | # Telerik's JustMock configuration file
287 | *.jmconfig
288 |
289 | # BizTalk build output
290 | *.btp.cs
291 | *.btm.cs
292 | *.odx.cs
293 | *.xsd.cs
--------------------------------------------------------------------------------