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
{ | |
"Version": "2012-10-17", | |
"Id": "Policy1553842544056", | |
"Statement": [ | |
{ | |
"Sid": "Stmt1553842540551", | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::golang-resize-image/*" |
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
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: 'AWS::Serverless-2016-10-31' | |
Description: An AWS Serverless Specification template describing your function. | |
Resources: | |
resizeimage: | |
Type: 'AWS::Serverless::Function' | |
Properties: | |
Handler: main | |
Runtime: go1.x | |
CodeUri: . |
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 User | |
{ | |
public int Id { get; set; } | |
public string FirstName { get; set; } | |
public string LastName { 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 Microsoft.EntityFrameworkCore.Metadata.Builders; | |
namespace Demo.Configurations { | |
public sealed class UserConfiguration : IEntityTypeConfiguration<User> | |
{ | |
public void Configure(EntityTypeBuilder<User> builder) { | |
builder.ToTable("UsersTbl"); | |
builder.HasKey(u => u.Id); | |
builder.Property(u => u.FirstName).IsRequired(); | |
builder.Property(u => u.LastName).IsRequired(); | |
} |
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 Demo { | |
public class MyDbContext : DbContext | |
{ | |
public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) {} | |
protected override void OnModelCreating(ModelBuilder modelBuilder){ | |
modelBuilder.ApplyConfiguration(new UserConfiguration()); | |
//In here, you will have to do loop again for every new entity configuration, it will make you feel lazy if you are :D | |
} |
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.Linq; | |
using System.Reflection; | |
using Microsoft.EntityFrameworkCore; | |
namespace Demo { | |
public static class Extensions | |
{ | |
/// <summary> | |
/// Auto find and apply all IEntityTypeConfiguration to modelBuilder |
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
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.ApplyAllConfigurations<MyDbContext>(); | |
} |
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
[AllowAnonymous] | |
[HttpPost] | |
public async Task<IHttpActionResult> Register (RegisterBindingModel model) { | |
if (!ModelState.IsValid) return BadRequest (ModelState); | |
var user = new User { | |
UserName = model.Email, | |
Email = model.Email, | |
DateOfBirth = DateTime.Parse (model.DateOfBirth.ToString (CultureInfo.InvariantCulture)), | |
PhoneNumber = model.PhoneNumber, |
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
[AllowAnonymous] | |
[HttpPost] | |
public async Task<IHttpActionResult> Register ([FromBody] CreateUserCommand command) { | |
return Ok (await new CommandAsync (command)); | |
} |
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 GetUserDetailQuery : IRequest<UserDto> | |
{ | |
public GetUserDetailQuery(int id) { | |
Id = id; | |
} | |
public int Id {get;} | |
} |
OlderNewer