-
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
0 parents
commit f49bbe7
Showing
47 changed files
with
1,121 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,11 @@ | ||
################################################################################ | ||
# This .gitignore file was automatically created by Microsoft(R) Visual Studio. | ||
################################################################################ | ||
|
||
/.vs | ||
/src/ToDoApp/.vs/ToDoApp/v16 | ||
/src/ToDoApp/ToDoApp.Application/bin/Debug/netcoreapp3.0 | ||
/src/ToDoApp/ToDoApp.Application/obj | ||
/src/ToDoApp/ToDoApp.Domain/bin/Debug/netcoreapp3.0 | ||
/src/ToDoApp/ToDoApp.Domain/obj | ||
/src/ToDoApp/ToDoApp.Persistance/obj |
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,6 @@ | ||
|
||
|
||
|
||
|
||
Reference: | ||
|
25 changes: 25 additions & 0 deletions
25
src/ToDoApp/ToDoApp.Application/Helpers/AutoMapperProfile.cs
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,25 @@ | ||
using AutoMapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
|
||
namespace ToDoApp.Application.Helpers | ||
{ | ||
public class AutoMapperProfile : Profile | ||
{ | ||
public AutoMapperProfile() | ||
{ | ||
CreateMap<Category, CategoryModel>().ReverseMap(); | ||
CreateMap<Category, CategoryDetailModel>().ReverseMap(); | ||
CreateMap<SubCategory, SubCategoryModel>().ReverseMap(); | ||
CreateMap<Link, LinkModel>().ReverseMap(); | ||
CreateMap<Note, NoteModel>().ReverseMap(); | ||
CreateMap<ToDo, ToDoModel>().ReverseMap(); | ||
CreateMap<File, FileModel>().ReverseMap(); | ||
CreateMap<UserParams, UserParamsModel>().ReverseMap(); | ||
|
||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/ToDoApp/ToDoApp.Application/Services/CategoryService.cs
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,62 @@ | ||
using AutoMapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.Services.Interface; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
using ToDoApp.Domain.Interface; | ||
|
||
namespace ToDoApp.Application.Services | ||
{ | ||
public class CategoryService : ICategoryService | ||
{ | ||
private readonly ICategoryRepository _repo; | ||
private readonly IMapper _mapper; | ||
|
||
public CategoryService(ICategoryRepository repo, IMapper mapper) | ||
{ | ||
_repo = repo; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task Add<CategoryModel>(CategoryModel entity) | ||
{ | ||
var newCategory = _mapper.Map<Category>(entity); | ||
await _repo.Add(newCategory); | ||
} | ||
|
||
public async Task Delete(Guid id) | ||
{ | ||
var category = await _repo.GetById(id); | ||
await _repo.Delete(category); | ||
} | ||
|
||
public async Task<QueryResult<CategoryModel>> GetAll(UserParamsModel userParams) | ||
{ | ||
var result = new QueryResult<CategoryModel>(); | ||
var categories = await _repo.GetAll(_mapper.Map<UserParams>(userParams)); | ||
|
||
var categoriesModels = _mapper.Map<List<Category>, List<CategoryModel>>(categories.Items); | ||
|
||
result.Items = categoriesModels; | ||
result.TotalItems = categories.TotalItems; | ||
result.CurrentPage = categories.CurrentPage; | ||
result.TotalPage = categories.TotalPage; | ||
|
||
return result; | ||
} | ||
|
||
public async Task<CategoryDetailModel> GetById(Guid Id) | ||
{ | ||
var category = await _repo.GetById(Id); | ||
return _mapper.Map<CategoryDetailModel>(category); | ||
} | ||
|
||
public async Task Update<CategoryModel>(CategoryModel entity) | ||
{ | ||
await _repo.Update(_mapper.Map<Category>(entity)); | ||
} | ||
} | ||
} |
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,77 @@ | ||
using AutoMapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.Services.Interface; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
using ToDoApp.Domain.Interface; | ||
|
||
namespace ToDoApp.Application.Services | ||
{ | ||
public class FileService : IFileService | ||
{ | ||
private readonly IFileRepository _repo; | ||
private readonly IMapper _mapper; | ||
|
||
public FileService(IFileRepository repo, IMapper mapper) | ||
{ | ||
_repo = repo; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task Add<FileModel>(FileModel entity) | ||
{ | ||
var newEntity = _mapper.Map<File>(entity); | ||
await _repo.Add(newEntity); | ||
} | ||
|
||
public async Task Delete(Guid id) | ||
{ | ||
var file = await _repo.GetById(id); | ||
await _repo.Delete(file); | ||
} | ||
|
||
public async Task<QueryResult<FileModel>> GetAll(UserParamsModel userParams) | ||
{ | ||
var result = new QueryResult<FileModel>(); | ||
var files = await _repo.GetAll(_mapper.Map<UserParams>(userParams)); | ||
|
||
var fileModels = _mapper.Map<List<File>, List<FileModel>>(files.Items); | ||
|
||
result.Items = fileModels; | ||
result.TotalItems = files.TotalItems; | ||
result.CurrentPage = files.CurrentPage; | ||
result.TotalPage = files.TotalPage; | ||
|
||
return result; | ||
} | ||
|
||
public async Task<FileModel> GetById(Guid Id) | ||
{ | ||
var file = await _repo.GetById(Id); | ||
return _mapper.Map<FileModel>(file); | ||
} | ||
|
||
public async Task<QueryResult<FileModel>> GetBySubCategoryId(Guid Id, UserParamsModel userParams) | ||
{ | ||
var result = new QueryResult<FileModel>(); | ||
var entities = await _repo.GetBySubCategoryId(Id, _mapper.Map<UserParams>(userParams)); | ||
|
||
var fileModels = _mapper.Map<List<File>, List<FileModel>>(entities.Items); | ||
|
||
result.Items = fileModels; | ||
result.TotalItems = entities.TotalItems; | ||
result.CurrentPage = entities.CurrentPage; | ||
result.TotalPage = entities.TotalPage; | ||
|
||
return result; | ||
} | ||
|
||
public async Task Update<FileModel>(FileModel entity) | ||
{ | ||
await _repo.Update(_mapper.Map<File>(entity)); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/ToDoApp/ToDoApp.Application/Services/Interface/ICategoryService.cs
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,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
|
||
namespace ToDoApp.Application.Services.Interface | ||
{ | ||
public interface ICategoryService : IGenericService | ||
{ | ||
Task<QueryResult<CategoryModel>> GetAll(UserParamsModel userParams); | ||
Task<CategoryDetailModel> GetById(Guid Id); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/ToDoApp/ToDoApp.Application/Services/Interface/IFileService.cs
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
|
||
namespace ToDoApp.Application.Services.Interface | ||
{ | ||
public interface IFileService : IGenericService | ||
{ | ||
Task<QueryResult<FileModel>> GetAll(UserParamsModel userParams); | ||
Task<QueryResult<FileModel>> GetBySubCategoryId(Guid Id, UserParamsModel userParams); | ||
Task<FileModel> GetById(Guid Id); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/ToDoApp/ToDoApp.Application/Services/Interface/IGenericService.cs
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,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ToDoApp.Application.Services.Interface | ||
{ | ||
public interface IGenericService | ||
{ | ||
Task Add<T>(T entity); | ||
Task Update<T>(T entity); | ||
Task Delete(Guid id); | ||
|
||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/ToDoApp/ToDoApp.Application/Services/Interface/ILinkService.cs
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
|
||
namespace ToDoApp.Application.Services.Interface | ||
{ | ||
public interface ILinkService : IGenericService | ||
{ | ||
Task<QueryResult<LinkModel>> GetAll(UserParamsModel userParams); | ||
Task<QueryResult<LinkModel>> GetBySubCategoryId(Guid Id, UserParamsModel userParams); | ||
Task<LinkModel> GetById(Guid Id); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/ToDoApp/ToDoApp.Application/Services/Interface/INoteService.cs
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
|
||
namespace ToDoApp.Application.Services.Interface | ||
{ | ||
public interface INoteService : IGenericService | ||
{ | ||
Task<QueryResult<NoteModel>> GetAll(UserParamsModel userParams); | ||
Task<QueryResult<NoteModel>> GetBySubCategoryId(Guid Id, UserParamsModel userParams); | ||
Task<NoteModel> GetById(Guid Id); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/ToDoApp/ToDoApp.Application/Services/Interface/ISubCategoryService.cs
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
|
||
namespace ToDoApp.Application.Services.Interface | ||
{ | ||
public interface ISubCategoryService : IGenericService | ||
{ | ||
Task<QueryResult<SubCategoryModel>> GetAll(UserParamsModel userParams); | ||
Task<QueryResult<SubCategoryModel>> GetBySubCategoryId(Guid Id, UserParamsModel userParams); | ||
Task<SubCategoryModel> GetById(Guid Id); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/ToDoApp/ToDoApp.Application/Services/Interface/IToDoService.cs
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
|
||
namespace ToDoApp.Application.Services.Interface | ||
{ | ||
public interface IToDoService : IGenericService | ||
{ | ||
Task<QueryResult<ToDoModel>> GetAll(UserParamsModel userParams); | ||
Task<QueryResult<ToDoModel>> GetBySubCategoryId(Guid Id, UserParamsModel userParams); | ||
Task<ToDoModel> GetById(Guid Id); | ||
} | ||
} |
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,77 @@ | ||
using AutoMapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToDoApp.Application.Services.Interface; | ||
using ToDoApp.Application.ViewModel; | ||
using ToDoApp.Domain.Entities; | ||
using ToDoApp.Domain.Interface; | ||
|
||
namespace ToDoApp.Application.Services | ||
{ | ||
public class LinkService : ILinkService | ||
{ | ||
private readonly ILinkRepository _repo; | ||
private readonly IMapper _mapper; | ||
|
||
public LinkService(ILinkRepository repo, IMapper mapper) | ||
{ | ||
_repo = repo; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task Add<FileModel>(FileModel entity) | ||
{ | ||
var newEntity = _mapper.Map<Link>(entity); | ||
await _repo.Add(newEntity); | ||
} | ||
|
||
public async Task Delete(Guid id) | ||
{ | ||
var entity = await _repo.GetById(id); | ||
await _repo.Delete(entity); | ||
} | ||
|
||
public async Task<QueryResult<LinkModel>> GetAll(UserParamsModel userParams) | ||
{ | ||
var result = new QueryResult<LinkModel>(); | ||
var entities = await _repo.GetAll(_mapper.Map<UserParams>(userParams)); | ||
|
||
var models = _mapper.Map<List<Link>, List<LinkModel>>(entities.Items); | ||
|
||
result.Items = models; | ||
result.TotalItems = entities.TotalItems; | ||
result.CurrentPage = entities.CurrentPage; | ||
result.TotalPage = entities.TotalPage; | ||
|
||
return result; | ||
} | ||
|
||
public async Task<LinkModel> GetById(Guid Id) | ||
{ | ||
var entity = await _repo.GetById(Id); | ||
return _mapper.Map<LinkModel>(entity); | ||
} | ||
|
||
public async Task<QueryResult<LinkModel>> GetBySubCategoryId(Guid Id, UserParamsModel userParams) | ||
{ | ||
var result = new QueryResult<LinkModel>(); | ||
var entities = await _repo.GetBySubCategoryId(Id, _mapper.Map<UserParams>(userParams)); | ||
|
||
var fileModels = _mapper.Map<List<Link>, List<LinkModel>>(entities.Items); | ||
|
||
result.Items = fileModels; | ||
result.TotalItems = entities.TotalItems; | ||
result.CurrentPage = entities.CurrentPage; | ||
result.TotalPage = entities.TotalPage; | ||
|
||
return result; | ||
} | ||
|
||
public async Task Update<LinkModel>(LinkModel entity) | ||
{ | ||
await _repo.Update(_mapper.Map<Link>(entity)); | ||
} | ||
} | ||
} |
Oops, something went wrong.