Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aroankingslin committed Feb 8, 2020
0 parents commit f49bbe7
Show file tree
Hide file tree
Showing 47 changed files with 1,121 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
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
6 changes: 6 additions & 0 deletions doc/Setup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@




Reference:

25 changes: 25 additions & 0 deletions src/ToDoApp/ToDoApp.Application/Helpers/AutoMapperProfile.cs
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 src/ToDoApp/ToDoApp.Application/Services/CategoryService.cs
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));
}
}
}
77 changes: 77 additions & 0 deletions src/ToDoApp/ToDoApp.Application/Services/FileService.cs
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));
}
}
}
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 src/ToDoApp/ToDoApp.Application/Services/Interface/IFileService.cs
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);
}
}
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 src/ToDoApp/ToDoApp.Application/Services/Interface/ILinkService.cs
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 src/ToDoApp/ToDoApp.Application/Services/Interface/INoteService.cs
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);
}
}
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 src/ToDoApp/ToDoApp.Application/Services/Interface/IToDoService.cs
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);
}
}
77 changes: 77 additions & 0 deletions src/ToDoApp/ToDoApp.Application/Services/LinkService.cs
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));
}
}
}
Loading

0 comments on commit f49bbe7

Please sign in to comment.