Skip to content

Instantly share code, notes, and snippets.

View MufidJamaluddin's full-sized avatar

Mufid Jamaluddin MufidJamaluddin

  • Jakarta, Indonesia
View GitHub Profile
@MufidJamaluddin
MufidJamaluddin / models.py
Created April 20, 2020 15:46
Versioning dengan Flask-Continuum
# 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
public class BookShelfControllerTests : IClassFixture<IntegrationTestWebAppFactory<Startup>>
{
private readonly HttpClient _client;
public BookShelfControllerTests(IntegrationTestWebAppFactory<Startup> factory)
{
this._client = factory.CreateClient();
}
[Fact]
public class BookShelfControllerTests : IClassFixture<IntegrationTestWebAppFactory<Startup>>
{
private readonly HttpClient _client;
public BookShelfControllerTests(IntegrationTestWebAppFactory<Startup> factory)
{
this._client = factory.CreateClient();
}
[Fact]
/********************** 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!");
[Route("api/catalogue/[controller]")]
public class BookShelfController : ControllerBase
{
private readonly BookRepository _repository;
public BookShelfController(AppDbContext dbContext)
{
this._logger = logger;
this._repository = new BookRepository(dbContext);
}
// 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) =>
public class UnreleasedMotorcycle
{
public string ProductName {get;set;}
public Date ReleasedDate {get;set;}
}
public class AbgooMotor : UnreleasedMotorcycle
{
//...
}
public class Motorcycle
{
public string ProductName {get;set;}
public double Price {get;set;}
public void Buy(PublicUser user)
{
// beli
}
}
public class Invoice
{
public Double CalculateInvoice(Motorcycle motor, Duration duration)
{
if(motor.type = "rent")
{
// perhitungan tagihan tracking motor sewaan
}
else if(motor.type = "loan")
{
public class Invoice
{
public Double CalculateInvoice(Motorcycle motor, Duration duration)
{
// perhitungan tagihan tracking motor pribadi
}
public void PayInvoice(double invoice)
{
// pembayaran struk tagihan
}