DrMadWill.Layers 5.0.0

dotnet add package DrMadWill.Layers --version 5.0.0
NuGet\Install-Package DrMadWill.Layers -Version 5.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DrMadWill.Layers" Version="5.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DrMadWill.Layers --version 5.0.0
#r "nuget: DrMadWill.Layers, 5.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DrMadWill.Layers as a Cake Addin
#addin nuget:?package=DrMadWill.Layers&version=5.0.0

// Install DrMadWill.Layers as a Cake Tool
#tool nuget:?package=DrMadWill.Layers&version=5.0.0

Layers

Description

Layers is a software project developed primarily in C#.

Installation

To install Layers, you will need .

  1. You can clone the repository using the following command:

    • bash
      • Copy code git clone https://github.com/DrMadWill/Layers.git
  2. You can install the package form your project using the following command:

    • nuget
      • terminal> dotnet add package DrMadWill.Layers --version 3.1.0
      • nuget-terminal> NuGet\Install-Package DrMadWill.Layers -Version 3.1.0

Usage

Here is how you can use Layers: This class must be added your project.


public static class ServiceRegistration  
{  
    public static void AddLayerServices(this IServiceCollection services)  
    {  
        if (services == null) throw new AggregateException("service is null");  
  
        #region Repositories  
        services.AddScoped(typeof(IReadRepository<,>), typeof(ReadRepository<,>));  
        services.AddScoped(typeof(IWriteRepository<,>), typeof(WriteRepository<,>));  
        services.AddScoped<IQueryRepositories, DQueryRepositories>();   
        services.AddScoped<IUnitOfWork, DUnitOfWork>();  
        #endregion  
  
		#region Services  
        services.AddScoped<IServiceManager, DServiceManager>();    
        #endregion  
  
  }  
}
  • DQueryRepositories

public class DQueryRepositories : QueryRepositories, IQueryRepositories  
{  
    public DQueryRepositories(DictContext dictContext, IMapper mapper) : base(dictContext, mapper, typeof(ServiceRegistration))  
    {  
    }  
}
  • DUnitOfWork
public class DUnitOfWork:UnitOfWork  
{  
    public DUnitOfWork(DictContext dictContext) : base(dictContext,typeof(ServiceRegistration))  
    {  
    }  
}
  • DServiceManager
public class DServiceManager :ServiceManager  
{  
    public DServiceManager(IUnitOfWork unitOfWork, IQueryRepositories queryRepositories, IMapper mapper,ILoggerFactory loggerFactory) :   
        base(unitOfWork, queryRepositories, mapper,loggerFactory,typeof(ServiceRegistration))  
    {  
    }  
      
}

For example : Dictionary Type Service Add

public class DictionaryTypeService:BaseService,IDictionaryTypeService  
{  
    private readonly IReadRepository<DictionaryType, int> _read;  
    private readonly IWriteRepository<DictionaryType, int> _write;  
    public DictionaryTypeService(IUnitOfWork unitOfWork, IQueryRepositories queryRepositories,IMapper mapper,ILogger<DictionaryTypeService> logger) :   
        base(unitOfWork, queryRepositories,mapper,logger)  
    {  
        _read = QueryRepositories.Repository<DictionaryType,int>();  
        _write = UnitOfWork.Repository<DictionaryType,int>();  
    }  
      
    public async Task<SourcePaged<DictionaryTypeDto>> GetAll(DictionaryTypeFilter filter,PageReq page)  
    {  
        IQueryable<DictionaryType> query = QueryRepositories.Repository<DictionaryType, int>().GetAllQueryable()  
            .OrderByDescending(s => s.Hierarchy);  
        if (filter != null)  
            query = filter.Filtered(query);  
        var source =  
            await SourcePaged<DictionaryTypeDto>.PagedAsync(query, page);  
  
        return Mapper.Map<SourcePaged<DictionaryTypeDto>>(source);  
    }  
      
    public async Task<DictionaryTypeDto> Get(int id)  
    {  
        var dictionaryType = await _read.GetFirstAsync(s => s.Id == id);  
        if (dictionaryType == null) return null;  
        var result = Mapper.Map<DictionaryTypeDto>(dictionaryType);  
        return result;  
    }  
  
    public Task<bool> AddAsync(AddDictionaryTypeReq req)  
        => CompleteProcess(async () =>  
        {  
            var dictionaryType = Mapper.Map<DictionaryType>(req);  
            await _write.AddAsync(dictionaryType);  
            await UnitOfWork.CommitAsync();  
        });  
     
    public Task<bool> UpdateAsync(UpdateDictionaryTypeReq req)  
        => CompleteProcess(async () =>  
        {  
            var dictionaryType = await _read.GetAllQueryable(true).FirstOrDefaultAsync(s => s.Id == req.Id);  
            if (dictionaryType == null) throw new Exception("Dictionary Type is not found");  
            Mapper.Map(req, dictionaryType);  
            await _write.UpdateAsync(dictionaryType);  
            await UnitOfWork.CommitAsync();  
        });  
  
    public Task<bool> DeleteAsync(int id)  
       => CompleteProcess(async () =>  
       {  
            var dictionaryType =await _read.GetAllQueryable(true).FirstOrDefaultAsync(s => s.Id == id);  
            if (dictionaryType == null) throw new Exception("Dictionary Type is not found");   
            await _write.DeleteAsync(dictionaryType);  
            await UnitOfWork.CommitAsync();   
       });  
      
}

Contributing

Contributions to Layers are welcome! Please feel free to fork the repository, make changes, and submit pull requests.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

  • me
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.0 109 2/22/2024
4.2.0 97 2/22/2024
4.1.0 65 2/22/2024
4.0.0 82 2/22/2024
3.1.2 99 2/9/2024
3.1.1 109 1/28/2024
3.1.0 81 1/26/2024
3.0.0 77 1/25/2024
2.4.1 80 1/25/2024
2.3.1 79 1/25/2024
2.3.0 80 1/24/2024
2.2.1 79 1/24/2024
2.1.1 73 1/24/2024
2.0.1 84 1/23/2024
2.0.0 78 1/23/2024
1.9.0 86 1/19/2024
1.8.0 102 1/11/2024
1.7.1 142 12/23/2023
1.7.0 108 12/23/2023
1.6.0 107 12/22/2023
1.5.0 99 12/20/2023
1.4.2 112 12/20/2023
1.3.2 110 12/19/2023
1.2.2 105 12/19/2023
1.2.1 100 12/19/2023
1.2.0 100 12/19/2023
1.1.2 105 12/19/2023
1.0.2 103 12/19/2023
1.0.1 97 12/19/2023
1.0.0 108 12/19/2023