@@ -6,20 +6,31 @@

namespace Courses.Models
{
class Product
{
public int ID { get; set;}
public class Product : DomainObject
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime UpdatedDate { get; set; }
public bool Active { get; set; }
public int Type { get; set; }
public int PartnerID { get; set; }
public int PartnerId { get; set; }
public string Teacher { get; set; }
public int SeatsCount { get; set; }
public int AssignedUserID { get; set; }
public int? AssignedUserId { get; set; }
public string Location { get; set; }

public List<Appointment> Appointments { get; set; }
public List<Comment> Comments { get; set; }

public Partner Partner { get; set; }
public User User { get; set; }
public List<Category> Categories { get; set; }
public List<Customer> Customers { get; set; }

public List<Customer> CustomersWithFavouriteProducts { get; set; }
public List<ProductRating> ProductRatings { get; set; }

}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Courses.Models
{
public class ProductRating : DomainObject
{

[Key,Column(Order = 0)]
public int CustomerId { get; set; }
[Key,Column(Order = 1)]
public int ProductId { get; set; }
public int Rate { get; set; }

[ForeignKey("CustomerId")]
public Customer Customer;
[ForeignKey("ProductId")]
public Product Product;
}
}
@@ -19,7 +19,7 @@
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
// The following GUId is for the Id of the typelib if this project is exposed to COM
[assembly: Guid("0d37d8a3-78ec-479e-86d1-1d1c27bb4928")]

// Version information for an assembly consists of the following four values:
@@ -33,9 +33,9 @@ public interface IRepository<T> where T:DomainObject
/// <summary>
/// Получение единственной сущности по значению ключевого поля
/// </summary>
/// <param name="id"></param>
/// <param name="Id"></param>
/// <returns></returns>
T Get(int id);
T Get(int Id);
/// <summary>
/// Добавление сущности в БД
/// </summary>
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Courses.Models
{
public class Schedule : DomainObject
{
/// <summary>
/// Ключевое поле
/// </summary>
public int Id
{
get;
set;
}
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public string Text { get; set; }
public int? ParentId { get; set; }
public int AppointmentId { get; set; }
[ForeignKey("ParentId")]
public Schedule _Schedule { get; set; }
public Appointment Appointment { get; set; }
}
}
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Courses.Models
{
public class User : DomainObject
{
/// <summary>
/// Ключевое поле
/// </summary>
public int Id
{
get;
set;
}
public string Login { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string AuthKey { get; set; }
public string PasswordHash { get; set; }
public string Email { get; set; }
public byte Role { get; set; }
public byte Status { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime UpdatedDate { get; set; }
public List<Product> Products { get; set; }
public List<Partner> Partners { get; set; }
public List<Event> Events { get; set; }
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
</packages>
@@ -1,73 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{811D53D2-0687-44E8-855D-020F629227FA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Courses.DAL</RootNamespace>
<AssemblyName>Courses.DAL</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AccountContext.cs" />
<Compile Include="AccountRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cources.Models\Courses.Models.csproj">
<Project>{1496fb44-c419-4eae-95c7-49a068dc2e78}</Project>
<Name>Courses.Models</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{811D53D2-0687-44E8-855D-020F629227FA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Courses.DAL</RootNamespace>
<AssemblyName>Courses.DAL</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AccountContext.cs" />
<Compile Include="AccountRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cources.Models\Courses.Models.csproj">
<Project>{1496fb44-c419-4eae-95c7-49a068dc2e78}</Project>
<Name>Courses.Models</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
@@ -38,7 +38,7 @@ public ActionResult New(AccountViewModel account)
return RedirectToAction("Index");
}
}
catch (Exception e)
catch (Exception)
{
ModelState.AddModelError("", "Unable to save changes");
}
@@ -68,7 +68,7 @@ public ActionResult Edit(AccountViewModel account)
return RedirectToAction("Index");
}
}
catch (Exception e)
catch (Exception)
{
ModelState.AddModelError("", "Unable to save changes");
}
@@ -1,63 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<!--<add name="CourseDatabase" connectionString="Data Source = B:\CourseRepository\dotnet01\dotnet01\App_Data\CourseDatabase.mdf"
providerName="System.Data.SqlClient"/>-->
<!--<add name="AccountsDatabase" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=B:\CourseRepository\dotnet01\dotnet01\App_Data\AccountsDatabase.mdf;Initial Catalog=B:\CourseRepository\dotnet01\dotnet01\App_Data;Integrated Security=True"
providerName="System.Data.SqlClient" />-->
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-dotnet01-20151213091035.mdf;Initial Catalog=aspnet-dotnet01-20151213091035;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="AccountsDatabase" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|AccountsDatabase.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<!--<add name="CourseDatabase" connectionString="Data Source = B:\CourseRepository\dotnet01\dotnet01\App_Data\CourseDatabase.mdf"
providerName="System.Data.SqlClient"/>-->
<!--<add name="AccountsDatabase" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=B:\CourseRepository\dotnet01\dotnet01\App_Data\AccountsDatabase.mdf;Initial Catalog=B:\CourseRepository\dotnet01\dotnet01\App_Data;Integrated Security=True"
providerName="System.Data.SqlClient" />-->
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-dotnet01-20151213091035.mdf;Initial Catalog=aspnet-dotnet01-20151213091035;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="AccountsDatabase" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|AccountsDatabase.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="MainDatabase" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|MainDatabase.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
@@ -0,0 +1,8 @@
using System;

public class Class1
{
public Class1()
{
}
}
@@ -1,71 +1,74 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.GUI.Old_WILL_BE_DELETED", "dotnet01\Courses.GUI.Old_WILL_BE_DELETED.csproj", "{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.DAL", "Courses.DAL\Courses.DAL.csproj", "{811D53D2-0687-44E8-855D-020F629227FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.Models", "Cources.Models\Courses.Models.csproj", "{1496FB44-C419-4EAE-95C7-49A068DC2E78}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GUI", "GUI", "{CA264FC3-6998-46A4-A848-9A33C92AA808}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.Buisness", "Courses.Buisness\Courses.Buisness.csproj", "{95BFAC8F-52BC-4841-893A-1E894CE785B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.ViewModels", "Courses.ViewModels\Courses.ViewModels.csproj", "{DEF79D34-00E6-4658-B8A9-12798A36E88B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Model", "Model", "{1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DAL", "DAL", "{5231A492-125E-4872-B878-D0B2FA5D296A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CA4EB1D6-8A6A-4FCC-8B90-A168F1C6AD6F}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.Gui.Admin", "Courses.Gui.Admin\Courses.Gui.Admin.csproj", "{EA6E5992-138E-4AA7-991B-22AD5A816E2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Release|Any CPU.Build.0 = Release|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Release|Any CPU.Build.0 = Release|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Release|Any CPU.Build.0 = Release|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Release|Any CPU.Build.0 = Release|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Release|Any CPU.Build.0 = Release|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1} = {CA264FC3-6998-46A4-A848-9A33C92AA808}
{811D53D2-0687-44E8-855D-020F629227FA} = {5231A492-125E-4872-B878-D0B2FA5D296A}
{1496FB44-C419-4EAE-95C7-49A068DC2E78} = {1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}
{95BFAC8F-52BC-4841-893A-1E894CE785B4} = {1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}
{DEF79D34-00E6-4658-B8A9-12798A36E88B} = {1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}
{EA6E5992-138E-4AA7-991B-22AD5A816E2C} = {CA264FC3-6998-46A4-A848-9A33C92AA808}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.GUI.Old_WILL_BE_DELETED", "dotnet01\Courses.GUI.Old_WILL_BE_DELETED.csproj", "{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.DAL", "Courses.DAL\Courses.DAL.csproj", "{811D53D2-0687-44E8-855D-020F629227FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.Models", "Cources.Models\Courses.Models.csproj", "{1496FB44-C419-4EAE-95C7-49A068DC2E78}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GUI", "GUI", "{CA264FC3-6998-46A4-A848-9A33C92AA808}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.Buisness", "Courses.Buisness\Courses.Buisness.csproj", "{95BFAC8F-52BC-4841-893A-1E894CE785B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.ViewModels", "Courses.ViewModels\Courses.ViewModels.csproj", "{DEF79D34-00E6-4658-B8A9-12798A36E88B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Model", "Model", "{1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}"
ProjectSection(SolutionItems) = preProject
FavouriteProduct.cs = FavouriteProduct.cs
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DAL", "DAL", "{5231A492-125E-4872-B878-D0B2FA5D296A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CA4EB1D6-8A6A-4FCC-8B90-A168F1C6AD6F}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Courses.Gui.Admin", "Courses.Gui.Admin\Courses.Gui.Admin.csproj", "{EA6E5992-138E-4AA7-991B-22AD5A816E2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1}.Release|Any CPU.Build.0 = Release|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{811D53D2-0687-44E8-855D-020F629227FA}.Release|Any CPU.Build.0 = Release|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1496FB44-C419-4EAE-95C7-49A068DC2E78}.Release|Any CPU.Build.0 = Release|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95BFAC8F-52BC-4841-893A-1E894CE785B4}.Release|Any CPU.Build.0 = Release|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEF79D34-00E6-4658-B8A9-12798A36E88B}.Release|Any CPU.Build.0 = Release|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA6E5992-138E-4AA7-991B-22AD5A816E2C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B8AA7BBD-F3E6-445D-8D3D-31C97F8230A1} = {CA264FC3-6998-46A4-A848-9A33C92AA808}
{811D53D2-0687-44E8-855D-020F629227FA} = {5231A492-125E-4872-B878-D0B2FA5D296A}
{1496FB44-C419-4EAE-95C7-49A068DC2E78} = {1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}
{95BFAC8F-52BC-4841-893A-1E894CE785B4} = {1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}
{DEF79D34-00E6-4658-B8A9-12798A36E88B} = {1DB02EEE-E98A-4BF5-BD47-119FAAD13B23}
{EA6E5992-138E-4AA7-991B-22AD5A816E2C} = {CA264FC3-6998-46A4-A848-9A33C92AA808}
EndGlobalSection
EndGlobal
@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using Courses.Models;
namespace Courses.DAL
{
class MainContext : DbContext
{
public MainContext() :
base("MainDatabase")
{ }

public DbSet<Product> Products { get; set; }
public DbSet<Appointment> Appointments { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<Customer> Customers { get; set; }
public DbSet<EmailNewsletter> EmailNewsLetters { get; set; }
public DbSet<EmailQueue> EmailQueues { get; set; }
public DbSet<EmailTemplate> EmailTemplates { get; set; }
public DbSet<Event> Events { get; set; }

public DbSet<Order> Orders { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
public DbSet<Partner> Partners { get; set; }

public DbSet<ProductRating> ProductRatings { get; set; }
public DbSet<Schedule> Schedules { get; set; }
public DbSet<User> Users { get; set; }


protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<Product>()
.HasMany(c => c.Appointments)
.WithRequired(o => o.Product).
HasForeignKey(o => o.ProductId);

modelBuilder.Entity<Appointment>()
.HasMany(o => o.Schedules)
.WithRequired(o => o.Appointment)
.HasForeignKey(o => o.AppointmentId);

modelBuilder.Entity<Appointment>()
.HasMany(o => o.OrderItems)
.WithRequired(o => o.Appointment)
.HasForeignKey(o => o.AppointmentId);

modelBuilder.Entity<Order>()
.HasMany(o => o.OrderItems)
.WithRequired(o => o.Order)
.HasForeignKey(o => o.OrderId);

modelBuilder.Entity<Customer>()
.HasMany(o => o.Orders)
.WithRequired(o => o.Customer)
.HasForeignKey(o => o.CustomerId);

modelBuilder.Entity<Customer>()
.HasMany(o => o.Comments)
.WithRequired(o => o.Customer)
.HasForeignKey(o => o.CustomerId);

modelBuilder.Entity<Product>()
.HasMany(o => o.Comments)
.WithRequired(o => o.Product)
.HasForeignKey(o => o.ProductId);

modelBuilder.Entity<Partner>()
.HasMany(o => o.Products)
.WithRequired(o => o.Partner)
.HasForeignKey(o => o.PartnerId);

modelBuilder.Entity<User>()
.HasMany(o => o.Products)
.WithOptional(o => o.User)
.HasForeignKey(o => o.AssignedUserId);

modelBuilder.Entity<EmailNewsletter>()
.HasMany(o => o.EmailQueues)
.WithOptional(o => o.EmailNewsLetter)
.HasForeignKey(o => o.NewsletterId);

modelBuilder.Entity<Customer>()
.HasMany(o => o.EmailQueues)
.WithRequired(o => o.Customer)
.HasForeignKey(o => o.CustomerId);

modelBuilder.Entity<EmailTemplate>()
.HasMany(o => o.EmailNewsLetters)
.WithOptional(o => o.EmailTemplate)
.HasForeignKey(o => o.TemplateId);

modelBuilder.Entity<User>()
.HasMany(o => o.Partners)
.WithOptional(o => o.User)
.HasForeignKey(o => o.UserId);

modelBuilder.Entity<User>()
.HasMany(o => o.Events)
.WithRequired(o => o.User)
.HasForeignKey(o => o.UserId);

modelBuilder.Entity<Product>()
.HasMany(o => o.CustomersWithFavouriteProducts)
.WithMany(o => o.FavouriteProducts)
.Map(m =>
{
m.ToTable("FavouriteProducts");
m.MapLeftKey("ProductId");
m.MapRightKey("CustomerId");

});
}

}
}

Large diffs are not rendered by default.

@@ -8,12 +8,16 @@
using System.Web.Routing;
using dotnet01.Areas.Admin.Models;
using Ninject;
using Courses.DAL;
using Courses.Models;
namespace dotnet01
{
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{
MainContext main = new MainContext();
main.Database.CreateIfNotExists();
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
@@ -16,6 +16,7 @@

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-dotnet01-20151213091035.mdf;Initial Catalog=aspnet-dotnet01-20151213091035;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="AccountsDatabase" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|AccountsDatabase.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="MainDatabase" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|MainDatabase.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />