Skip to content

Instantly share code, notes, and snippets.

View PradeepLoganathan's full-sized avatar

Pradeep Loganathan PradeepLoganathan

View GitHub Profile
public interface ICatalogueRepository:IGenericRepository<Catalogue>
{
}
@PradeepLoganathan
PradeepLoganathan / IGenericRepository.cs
Last active July 30, 2020 00:52
IGenericRepository
public interface IGenericRepository<T> where T : class
{
Task<T> Get(int id);
Task<IEnumerable<T>> GetAll();
Task<int> Add(T entity);
Task<int> Delete(int id);
Task<int> Update(T entity);
}
@PradeepLoganathan
PradeepLoganathan / ICatalogueRepository.cs
Last active July 29, 2020 12:04
ICatalogueRepository
public interface ICatalogueRepository
{
Task<Catalogue> Get(int id);
Task<IEnumerable<Catalogue>> GetAll();
Task<int> Add(Catalogue entity);
Task<bool> Delete(int id);
Task<bool> Update(Catalogue catalogueEntity);
}
@PradeepLoganathan
PradeepLoganathan / IBooksRepository.cs
Last active July 29, 2020 12:02
BooksRepository interface
public interface IBooksRepository
{
Task<Book> Get(int id);
Task<IEnumerable<Book>> GetAll();
Task<int> Add(Book entity);
Task<bool> Delete(int id);
Task<bool> Update(Book bookEntity);
}
@PradeepLoganathan
PradeepLoganathan / Catalogue.cs
Created July 29, 2020 11:46
catalogue entity for blog post
using System.Collections.Generic;
using BookStore.Domain.BooksAggregate;
namespace BookStore.Domain.CatalogueAggregate
{
public class Catalogue
{
public int CatalogueId { get; set; }
public string Name { get; set; }
public List<Book> Books { get; set; }
@PradeepLoganathan
PradeepLoganathan / Book.cs
Last active July 30, 2020 03:53
Book entity for blog
namespace BookStore.Domain.BooksAggregate
{
public class Book
{
public int Id { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public string Publisher { get; set; }
public string Genre { get; set; }
public int Price { get; set; }
@PradeepLoganathan
PradeepLoganathan / Startup.cs
Created July 14, 2020 23:46
Adding mediatr and pipeline behaviours
public void ConfigureServices(IServiceCollection services)
{
AddCORS(services);
AddSwagger(services);
services.AddMediatR(Assembly.GetExecutingAssembly());
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehaviour<,>));
services.AddControllers();
}
@PradeepLoganathan
PradeepLoganathan / addmediatr.cmd
Last active July 14, 2020 00:10
Adding Mediatr using dotnet command line tools
dotnet add package Mediatr
dotnet add package MediatR.Extensions.Microsoft.DependencyInjection
@PradeepLoganathan
PradeepLoganathan / startup.cs
Created July 9, 2020 00:59
Configure httpclientfactory to create httpclient for http2
services.AddHttpClient<ICandidateService, CandidateService>(client =>
{
client.BaseAddress = new Uri("https://localhost:5001"),
client.DefaultRequestVersion = new Version(2, 0)
});
@PradeepLoganathan
PradeepLoganathan / request.cs
Created July 9, 2020 00:56
.Net Core HTTP client support for HTTP2
var client = new HttpClient()
{
BaseAddress = new Uri("https://localhost:5001"),
DefaultRequestVersion = new Version(2, 0)
};