This file contains hidden or 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
| using Microsoft.AspNetCore.Mvc; | |
| namespace BaseController.Controllers | |
| { | |
| [ApiController] | |
| [Route("api/weather-forecast")] | |
| public class WeatherForecastController : BaseController<WeatherForecast> | |
| { | |
| public WeatherForecastController(BaseControllerDBContext context) : base(context) | |
| { |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| using Microsoft.AspNetCore.Mvc; | |
| using Microsoft.EntityFrameworkCore; | |
| namespace BaseController.Controllers | |
| { | |
| [ApiController] |
This file contains hidden or 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
| using System; | |
| namespace BaseController | |
| { | |
| public class WeatherForecast : BaseModel | |
| { | |
| public DateTime Date { get; set; } | |
| public int TemperatureC { get; set; } |
This file contains hidden or 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
| using System; | |
| namespace BaseController | |
| { | |
| public class BaseModel | |
| { | |
| public Guid Id { get; set; } | |
| } | |
| } |
This file contains hidden or 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
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.AddDbContext<BaseControllerDBContext>(options => options.UseInMemoryDatabase("BaseController")); | |
| services.AddControllers(); | |
| } |
This file contains hidden or 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
| using Microsoft.EntityFrameworkCore; | |
| namespace BaseController | |
| { | |
| public class BaseControllerDBContext : DbContext | |
| { | |
| public DbSet<WeatherForecast> WeatherForecasts { get; set; } | |
| public BaseControllerDBContext(DbContextOptions<BaseControllerDBContext> options) : base(options) | |
| { |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using GenericRepositoryDemo.Entities; | |
| using GenericRepositoryDemo.Repositories; | |
| using Microsoft.AspNetCore.Mvc; | |
| namespace GenericRepositoryDemo.Controllers | |
| { | |
| [ApiController] |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using GenericRepositoryDemo.Entities; | |
| using Microsoft.EntityFrameworkCore; | |
| namespace GenericRepositoryDemo.Repositories | |
| { | |
| public class GenericRepository<Entity> where Entity : BaseModel | |
| { |
This file contains hidden or 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
| using System.Collections.Generic; | |
| using GenericRepositoryDemo.Entities; | |
| using Microsoft.EntityFrameworkCore; | |
| namespace GenericRepositoryDemo | |
| { | |
| public class BloggingContext : DbContext | |
| { | |
| public DbSet<Blog> Blogs { get; set; } | |
| public DbSet<Post> Posts { get; set; } |
This file contains hidden or 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
| namespace GenericRepositoryDemo.Entities | |
| { | |
| public class Post : BaseModel | |
| { | |
| public string Title { get; set; } | |
| public string Content { get; set; } | |
| public int BlogId { get; set; } | |
| public Blog Blog { get; set; } | |
| } |
NewerOlder