Skip to content

Commit

Permalink
Day 4
Browse files Browse the repository at this point in the history
  • Loading branch information
fdeniz07 committed Sep 12, 2021
1 parent e02ea8e commit db7ca4e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 5 deletions.
18 changes: 18 additions & 0 deletions BusinessLayer/Abstract/ICategoryService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using CoreLayer.Utilities.Results.Abstract;
using EntityLayer.Concrete;
using System.Collections.Generic;
using System.Threading.Tasks;
using EntityLayer.Dtos;

namespace BusinessLayer.Abstract
{
public interface ICategoryService
{
Task<IDataResult<Category>> Get(int categoryId);
Task<IDataResult<IList<Category>>> GetAll();
Task<IResult> Add(CategoryAddDto categoryAddDto,string createdByName);
Task<IResult> Update(CategoryUpdateDto categoryUpdateDto, string modifiedByName);
Task<IResult> Delete(int categoryId);
Task<IResult> HardDelete(int categoryId);
}
}
1 change: 0 additions & 1 deletion BusinessLayer/BusinessLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\CoreLayer\CoreLayer.csproj" />
<ProjectReference Include="..\DataAccessLayer\DataAccessLayer.csproj" />
<ProjectReference Include="..\EntityLayer\EntityLayer.csproj" />
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions CoreLayer/Utilities/Results/Abstract/IDataResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace CoreLayer.Utilities.Results.Abstract
{
public interface IDataResult<out T> : IResult
{
public T Data { get;} //new DataResult<Category>(ResultStatus.Success,category);
//new DataResult<IList<Category>>(ResultStatus.Success,categoryList);
}
}
37 changes: 37 additions & 0 deletions CoreLayer/Utilities/Results/Concrete/DataResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using CoreLayer.Utilities.Results.Abstract;
using CoreLayer.Utilities.Results.ComplexTypes;
using System;

namespace CoreLayer.Utilities.Results.Concrete
{
public class DataResult<T>:IDataResult<T>
{
public DataResult(ResultStatus resultStatus, T data)
{
ResultStatus = resultStatus;
Data = data;
}

public DataResult(ResultStatus resultStatus,string message , T data)
{
ResultStatus = resultStatus;
Message = message;
Data = data;
}

public DataResult(ResultStatus resultStatus, string message, T data, Exception exception)
{
ResultStatus = resultStatus;
Message = message;
Data = data;
Exception = exception;
}

public ResultStatus ResultStatus { get; }
public string Message { get; }
public Exception Exception { get; }
public T Data { get; }


}
}
33 changes: 33 additions & 0 deletions CoreLayer/Utilities/Results/Concrete/Result.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using CoreLayer.Utilities.Results.Abstract;
using CoreLayer.Utilities.Results.ComplexTypes;

namespace CoreLayer.Utilities.Results.Concrete
{
public class Result : IResult
{
public Result(ResultStatus resultStatus)
{
ResultStatus = resultStatus;
}

public Result(ResultStatus resultStatus, string message)
{
ResultStatus = resultStatus;
Message = message;
}

public Result(ResultStatus resultStatus, string message,Exception exception)
{
ResultStatus = resultStatus;
Message = message;
Exception = exception;
}

public ResultStatus ResultStatus { get; }
public string Message { get; }
public Exception Exception { get; }
//new Result(ResultStatus.Error,exception.message, exception)

}
}
6 changes: 6 additions & 0 deletions EntityLayer/Dtos/CategoryAddDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace EntityLayer.Dtos
{
public class CategoryAddDto
{
}
}
6 changes: 6 additions & 0 deletions EntityLayer/Dtos/CategoryUpdateDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace EntityLayer.Dtos
{
public class CategoryUpdateDto
{
}
}
4 changes: 0 additions & 4 deletions EntityLayer/EntityLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="Dtos\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit db7ca4e

Please sign in to comment.