Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions ControllersLogic/ControllersLogic.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{89FC8B31-B22A-40DD-981E-89A86D96BE34}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ControllersLogic</RootNamespace>
<AssemblyName>ControllersLogic</AssemblyName>
<TargetFrameworkVersion>v4.5.2</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="CloudinaryDotNet, Version=1.0.24.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CloudinaryDotNet.1.0.24\lib\net40\CloudinaryDotNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Bson, Version=2.2.4.26, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Bson.2.2.4\lib\net45\MongoDB.Bson.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Interfaces\ICommentLogic.cs" />
<Compile Include="Interfaces\IImageLogic.cs" />
<Compile Include="Interfaces\IProjectLogic.cs" />
<Compile Include="Logic\CommentLogic.cs" />
<Compile Include="Logic\ImageLogic.cs" />
<Compile Include="Logic\ProjectLogic.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DB\DB.csproj">
<Project>{4841ab80-72fd-4f53-bb68-28b111786669}</Project>
<Name>DB</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<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>
17 changes: 17 additions & 0 deletions ControllersLogic/Interfaces/ICommentLogic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DB.Models;

namespace ControllersLogic.Interfaces
{
public interface ICommentLogic
{
String AddComment(String text, String name);
List<CommentWithoutObjectId> GetAllComment();
CommentWithoutObjectId GetById(String id);
CommentWithoutObjectId UpdateById(String id, String name, String text);
}
}
23 changes: 23 additions & 0 deletions ControllersLogic/Interfaces/IImageLogic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using DB.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace ControllersLogic.Interfaces
{
public interface IImageLogic
{
String AddCommentToImage(String simageId, String text, String name);
String AddImage(String url, String name);
String DeleteCommentFromImage(String idImage, String idComment);
String DownloadImage(HttpPostedFileBase uploadImage);
List<ImageWithoutObjectId> GetAllImage();
ImageWithoutObjectId GetById(String id);
ImageWithoutObjectId GetByIdAndVersion(String id, int version);
List<CommentWithoutObjectId> GetCommentFromImage(String simageId);
ImageWithoutObjectId UpdateById(String id, String name, String url);
}
}
23 changes: 23 additions & 0 deletions ControllersLogic/Interfaces/IProjectLogic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using DB.Models;
using System;
using System.Collections.Generic;

namespace ControllersLogic.Interfaces
{
public interface IProjectLogic
{
String AddCommentToProject(String text, String name, String sprojectId);
String AddImageToProject(String url, String name, String sprojectId);
String AddProject(String name);
String AddProjectToProject(String sidRoot, String name);
String DeleteById(String id);
String DeleteCommentFromProject(String projectId, String commentId);
String DeleteImageFromProject(String projectId, String imageId);
List<ProjectWithoutObjectId> GetAllProjects();
ProjectWithoutObjectId GetById(String id);
List<CommentWithoutObjectId> GetCommentsFormProject(String sidRoot);
List<ImageWithoutObjectId> GetImagesFormProject(String sidRoot);
List<ProjectWithoutObjectId> GetPtojectsFormProject(String sidRoot);
ProjectWithoutObjectId UpdateById(String id, String name);
}
}
73 changes: 73 additions & 0 deletions ControllersLogic/Logic/CommentLogic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using ControllersLogic.Interfaces;
using DB.Interfaces;
using DB.Models;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ControllerLogic
{
public class CommentLogic: ICommentLogic
{
private static ICommentRepository _commentRepository = new DB.Repositories.DBCommentRepository();
public String AddComment(String text, String name)
{
Comment comment = new Comment();
comment.Text = text;
comment.CreationelData = DateTime.UtcNow;
comment.Name = name;
comment.Version = 1;
var id = _commentRepository.AddComment(comment).Id.ToString();
return id;
}
public List<CommentWithoutObjectId> GetAllComment()
{
var comments = CommentWithoutObjectId.CommentsToCommentWithoutObjectId(_commentRepository.GetAll());
return comments;
}
public CommentWithoutObjectId GetById(String id)
{
var objectId = new ObjectId();
if (!ObjectId.TryParse(id, out objectId))
{
throw new Exception("This isn't objectId");
}
if (objectId == null)
{
throw new Exception("Bad id");
}
var comment = CommentWithoutObjectId.CommentToCommentWithoutObjectId(_commentRepository.GetCommentById(objectId));
if (comment == null)
{
throw new Exception("Bad id");
}
return comment;
}
public CommentWithoutObjectId UpdateById(String id, String name, String text)
{
var objectId = new ObjectId();
if (!ObjectId.TryParse(id, out objectId))
{
throw new Exception("This isn't objectId");
}
if (objectId == null)
{
throw new Exception("Bad id");
}
var comment = _commentRepository.GetCommentById(objectId);
if (comment == null)
{
throw new Exception("Bad id");
}
comment.Name = name;
comment.Text = text;
comment.Version++;
_commentRepository.DeleteById(objectId);
_commentRepository.AddComment(comment);
return CommentWithoutObjectId.CommentToCommentWithoutObjectId(comment);
}
}
}
Loading