This repository has been archived by the owner on Oct 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
15,667 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
|
||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> | ||
</configSections> | ||
<connectionStrings> | ||
<add name="ZoliksEntities" connectionString="metadata=res://*/Models.MainModel.csdl|res://*/Models.MainModel.ssdl|res://*/Models.MainModel.msl;provider=System.Data.SqlClient;provider connection string="data source=SQL6003.site4now.net;initial catalog=DB_A42A18_zoliky;persist security info=True;user id=DB_A42A18_zoliky_admin;password=u3dEGPW3FtfZ;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" /> | ||
</connectionStrings> | ||
<entityFramework> | ||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> | ||
<parameters> | ||
<parameter value="mssqllocaldb" /> | ||
</parameters> | ||
</defaultConnectionFactory> | ||
<providers> | ||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> | ||
</providers> | ||
</entityFramework> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=other/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Data.Entity.Validation; | ||
using System.Linq; | ||
|
||
namespace DataAccess.Errors | ||
{ | ||
/* | ||
[Serializable] | ||
public class AlreadyExists : Exception | ||
{ | ||
public AlreadyExists() { } | ||
public AlreadyExists(string message) : base(message) { } | ||
public AlreadyExists(string message, Exception innerException) : base(message, innerException) { } | ||
} | ||
[Serializable] | ||
public class NotValidID : Exception | ||
{ | ||
public NotValidID() { } | ||
public NotValidID(string message) : base(message) { } | ||
public NotValidID(string message, Exception innerException) : base(message, innerException) { } | ||
} | ||
*/ | ||
public static class DbExceptionExtend | ||
{ | ||
public static string GetExceptionMessage(this DbEntityValidationException ex) | ||
{ | ||
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); | ||
var fullErrorMessage = string.Join("; ", errorMessages); | ||
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage); | ||
return exceptionMessage; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using DataAccess.Managers; | ||
using DataAccess.Models; | ||
using SharedLibrary; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DataAccess | ||
{ | ||
public sealed class Manager | ||
{ | ||
public ZoliksEntities Db { get; private set; } | ||
|
||
public ClassManager Classes { get; private set; } | ||
public ConsentManager Consents { get; private set; } | ||
public CrashManager Crashes { get; private set; } | ||
public HashMananger Hashes { get; private set; } | ||
public ChangelogManager Changelogs { get; private set; } | ||
public ImageManager Images { get; private set; } | ||
public NewsManager News { get; private set; } | ||
public NotificationManager Notifications { get; private set; } | ||
public PriceManager Prices { get; private set; } | ||
public ProjectManager Projects { get; private set; } | ||
public RankManager Ranks { get; private set; } | ||
public TokenManager Tokens { get; private set; } | ||
public TransManager Transactions { get; private set; } | ||
public UnavailabilitiesManager Unavailabilities { get; private set; } | ||
public UserManager Users { get; private set; } | ||
public LoginsManager Logins { get; private set; } | ||
public WebEventManager Events { get; private set; } | ||
public ZolikManager Zoliky { get; private set; } | ||
|
||
|
||
public Manager() | ||
{ | ||
Db = new ZoliksEntities(); | ||
|
||
Classes = new ClassManager(Db, this); | ||
Consents = new ConsentManager(Db, this); | ||
Crashes = new CrashManager(Db, this); | ||
Hashes = new HashMananger(Db, this); | ||
Changelogs = new ChangelogManager(Db, this); | ||
Images = new ImageManager(Db, this); | ||
News = new NewsManager(Db, this); | ||
Notifications = new NotificationManager(Db, this); | ||
Prices = new PriceManager(Db, this); | ||
Projects = new ProjectManager(Db, this); | ||
Ranks = new RankManager(Db, this); | ||
Tokens = new TokenManager(Db, this); | ||
Transactions = new TransManager(Db, this); | ||
Unavailabilities = new UnavailabilitiesManager(Db, this); | ||
Users = new UserManager(Db, this); | ||
Logins = new LoginsManager(Db, this); | ||
Events = new WebEventManager(Db, this); | ||
Zoliky = new ZolikManager(Db, this); | ||
} | ||
|
||
public void RefreshEntites() | ||
{ | ||
Db = new ZoliksEntities(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Data.Entity.Migrations; | ||
using System.Data.Entity.Validation; | ||
using DataAccess.Errors; | ||
using DataAccess.Models; | ||
using SharedLibrary; | ||
using SharedLibrary.Enums; | ||
|
||
namespace DataAccess.Managers | ||
{ | ||
public class AchievementsManager : IManager<Achievement> | ||
{ | ||
private ZoliksEntities _ent; | ||
private Manager _mgr; | ||
|
||
public AchievementsManager(ZoliksEntities ent, Manager mgr) | ||
{ | ||
this._ent = ent; | ||
this._mgr = mgr; | ||
} | ||
|
||
public MActionResult<Achievement> Select(int id) | ||
{ | ||
if (id < 1) { | ||
return new MActionResult<Achievement>(StatusCode.NotValidID); | ||
} | ||
|
||
Achievement a = _ent.Achievements.Find(id); | ||
if (a == null) { | ||
return new MActionResult<Achievement>(StatusCode.NotFound); | ||
} | ||
if (!a.Enabled) { | ||
return new MActionResult<Achievement>(StatusCode.NotEnabled, a); | ||
} | ||
return new MActionResult<Achievement>(StatusCode.OK, a); | ||
} | ||
|
||
public MActionResult<Achievement> Select(Achievements a) | ||
{ | ||
return Select((int)a); | ||
} | ||
|
||
public int Save(Achievement a, bool throwException = true) | ||
{ | ||
try { | ||
if (a != null) { | ||
_ent.Achievements.AddOrUpdate(a); | ||
} | ||
int changes = _ent.SaveChanges(); | ||
return changes; | ||
} catch (DbEntityValidationException ex) { | ||
if (throwException) { | ||
throw new DbEntityValidationException(ex.GetExceptionMessage(), ex.EntityValidationErrors); | ||
} | ||
return 0; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.Entity.Migrations; | ||
using System.Data.Entity.Validation; | ||
using System.Linq; | ||
using DataAccess.Errors; | ||
using DataAccess.Models; | ||
using SharedLibrary; | ||
using SharedLibrary.Enums; | ||
|
||
namespace DataAccess.Managers | ||
{ | ||
public class ChangelogManager : IManager<Changelog> | ||
{ | ||
private ZoliksEntities _ent; | ||
private Manager _mgr; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ChangelogManager"/> class. | ||
/// </summary> | ||
/// <param name="ent">The database entities</param> | ||
/// <param name="mgr">The <see cref="Manager"/></param> | ||
public ChangelogManager(ZoliksEntities ent, Manager mgr) | ||
{ | ||
this._ent = ent; | ||
this._mgr = mgr; | ||
} | ||
|
||
/// <summary> | ||
/// Selects Changelog by ID | ||
/// </summary> | ||
/// <param name="id">Changelog ID</param> | ||
/// <exception cref="StatusCode.NotValidID" /> | ||
/// <exception cref="StatusCode.NotFound" /> | ||
/// <exception cref="StatusCode.OK" /> | ||
public MActionResult<Changelog> Select(int id) | ||
{ | ||
if (id < 1) { | ||
return new MActionResult<Changelog>(StatusCode.NotValidID); | ||
} | ||
Changelog c = _ent.Changelogs.Find(id); | ||
if (c == null) { | ||
return new MActionResult<Changelog>(StatusCode.NotFound); | ||
} | ||
return new MActionResult<Changelog>(StatusCode.OK, c); | ||
} | ||
|
||
/// <summary> | ||
/// Changelogs the of the selected project. | ||
/// </summary> | ||
/// <param name="projectID">The owner Project ID.</param> | ||
/// <returns></returns> | ||
/// <exception cref="StatusCode.NotValidID" /> | ||
/// <exception cref="StatusCode.OK" /> | ||
public MActionResult<List<Changelog>> ChangelogsOfProject(int projectID) | ||
{ | ||
if (!_mgr.Projects.ValidID(projectID)) { | ||
return new MActionResult<List<Changelog>>(StatusCode.NotValidID); | ||
} | ||
|
||
List<Changelog> c = _ent.Changelogs.Where(x => x.ProjectID == projectID).OrderBy(x => x.Date).ToList(); | ||
return new MActionResult<List<Changelog>>(StatusCode.OK, c); | ||
} | ||
|
||
/// <summary> | ||
/// Changelogs the of the selected project. | ||
/// </summary> | ||
/// <param name="p">The owner Project ID.</param> | ||
/// <returns></returns> | ||
/// <exception cref="StatusCode.NotValidID" /> | ||
/// <exception cref="StatusCode.OK" /> | ||
public MActionResult<List<Changelog>> ChangelogsOfProject(Projects p) | ||
{ | ||
return ChangelogsOfProject((int)p); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Creates Changelog | ||
/// </summary> | ||
/// <param name="projectID">Owner project ID</param> | ||
/// <param name="title">Title of changelog</param> | ||
/// <param name="text">Content of changelog</param> | ||
/// <param name="releaseDate">The release date of new version.</param> | ||
/// <param name="versionName">Name of the version.</param> | ||
/// <param name="visible">Visibility of changelog</param> | ||
/// <returns></returns> | ||
/// <exception cref="StatusCode.NotValidID" /> | ||
/// <exception cref="StatusCode.InvalidInput" /> | ||
/// <exception cref="StatusCode.OK" /> | ||
public MActionResult<Changelog> Create(int projectID, string title, string text, DateTime releaseDate, string versionName, bool visible = true) | ||
{ | ||
if (!_mgr.Projects.ValidID(projectID)) { | ||
return new MActionResult<Changelog>(StatusCode.NotValidID); | ||
} | ||
if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(versionName)) { | ||
return new MActionResult<Changelog>(StatusCode.InvalidInput); | ||
} | ||
Changelog c = new Changelog() | ||
{ | ||
ProjectID = projectID, | ||
Title = title, | ||
Text = text, | ||
Date = releaseDate, | ||
Version = versionName, | ||
Visible = visible, | ||
}; | ||
Changelog c1 = _ent.Changelogs.Add(c); | ||
Save(null); | ||
return new MActionResult<Changelog>(StatusCode.OK, c1); | ||
} | ||
|
||
/// <summary> | ||
/// Creates Changelog | ||
/// </summary> | ||
/// <param name="p">Owner project ID</param> | ||
/// <param name="title">Title of changelog</param> | ||
/// <param name="text">Content of changelog</param> | ||
/// <param name="releaseDate">The release date of new version.</param> | ||
/// <param name="versionName">Name of the version.</param> | ||
/// <param name="visible">Visibility of changelog</param> | ||
/// <returns></returns> | ||
/// <exception cref="StatusCode.NotValidID" /> | ||
/// <exception cref="StatusCode.InvalidInput" /> | ||
/// <exception cref="StatusCode.OK" /> | ||
public MActionResult<Changelog> Create(Projects p, string title, string text, DateTime releaseDate, string versionName, bool visible = true) | ||
{ | ||
return Create((int)p, title, text, releaseDate, versionName, visible); | ||
} | ||
|
||
|
||
|
||
/// <summary> | ||
/// Saves Changelog | ||
/// </summary> | ||
/// <param name="c">The changelog to save</param> | ||
/// <param name="throwException">if set to <c>true</c> throw exception</param> | ||
/// <exception cref="DbEntityValidationException"></exception> | ||
public int Save(Changelog c, bool throwException = true) | ||
{ | ||
try { | ||
if (c != null) { | ||
_ent.Changelogs.AddOrUpdate(c); | ||
} | ||
int changes = _ent.SaveChanges(); | ||
return changes; | ||
} catch (DbEntityValidationException ex) { | ||
if (throwException) { | ||
throw new DbEntityValidationException(ex.GetExceptionMessage(), ex.EntityValidationErrors); | ||
} | ||
return 0; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.