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
| # SQLAlchemy Lib | |
| from sqlalchemy import ( | |
| Boolean, Column, Date, DateTime, Float, | |
| ForeignKey, ForeignKeyConstraint, Index, | |
| Integer, SmallInteger, BigInteger, String, | |
| Table, Text, Time, text | |
| ) | |
| from sqlalchemy.orm import relationship |
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 class BookShelfControllerTests : IClassFixture<IntegrationTestWebAppFactory<Startup>> | |
| { | |
| private readonly HttpClient _client; | |
| public BookShelfControllerTests(IntegrationTestWebAppFactory<Startup> factory) | |
| { | |
| this._client = factory.CreateClient(); | |
| } | |
| [Fact] |
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 class BookShelfControllerTests : IClassFixture<IntegrationTestWebAppFactory<Startup>> | |
| { | |
| private readonly HttpClient _client; | |
| public BookShelfControllerTests(IntegrationTestWebAppFactory<Startup> factory) | |
| { | |
| this._client = factory.CreateClient(); | |
| } | |
| [Fact] |
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
| /********************** REPOSITORY ****************************************/ | |
| public class AuthorRepository : BaseRepository, IAuthorRepository | |
| { | |
| public AuthorRepository(AppDbContext dbContext) : base(dbContext) { } | |
| public void SaveAuthor(Author author) | |
| { | |
| // VALIDASI | |
| if (author.Name?.Length > 20) throw new Exception("Author Lenght Max is 20!"); |
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
| [Route("api/catalogue/[controller]")] | |
| public class BookShelfController : ControllerBase | |
| { | |
| private readonly BookRepository _repository; | |
| public BookShelfController(AppDbContext dbContext) | |
| { | |
| this._logger = logger; | |
| this._repository = new BookRepository(dbContext); | |
| } |
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
| // Kelas-kelas Infrastruktur | |
| class SQLServerService<T> : BaseDatabaseService<T> where T : DbContext | |
| { | |
| public SQLServerService(IServiceCollection services, string connectionString) | |
| : base(services, connectionString) { } | |
| public override void Configure() | |
| { | |
| base.AppServices.AddDbContextPool<T>((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
| public class UnreleasedMotorcycle | |
| { | |
| public string ProductName {get;set;} | |
| public Date ReleasedDate {get;set;} | |
| } | |
| public class AbgooMotor : UnreleasedMotorcycle | |
| { | |
| //... | |
| } |
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 class Motorcycle | |
| { | |
| public string ProductName {get;set;} | |
| public double Price {get;set;} | |
| public void Buy(PublicUser user) | |
| { | |
| // beli | |
| } | |
| } |
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 class Invoice | |
| { | |
| public Double CalculateInvoice(Motorcycle motor, Duration duration) | |
| { | |
| if(motor.type = "rent") | |
| { | |
| // perhitungan tagihan tracking motor sewaan | |
| } | |
| else if(motor.type = "loan") | |
| { |
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 class Invoice | |
| { | |
| public Double CalculateInvoice(Motorcycle motor, Duration duration) | |
| { | |
| // perhitungan tagihan tracking motor pribadi | |
| } | |
| public void PayInvoice(double invoice) | |
| { | |
| // pembayaran struk tagihan | |
| } |