Skip to content

Instantly share code, notes, and snippets.

Avatar
👻
coding & spooking

Alan Albuquerque Ferreira Lopes offpepe

👻
coding & spooking
View GitHub Profile
@offpepe
offpepe / ExampleToInjectClass.cs
Created Sep 6, 2022
Configure appsettings into object using microsoft.extensions.dependencyInjection
View ExampleToInjectClass.cs
using Microsoft.Extensions.Options;
using Offpepe.Gists.Configurations;
namespace Offpepe.Gists.Business;
// Injecting config
public class ExampleClassToInject {
private readonly ConfigObject _configObject;
public ExampleClassToInject(IOptions<ConfigObject> configObject) {
_configObject = configObject.Value;
View commit-types.md

commit types

  • build: Alterações que afetam o sistema de construção ou dependências externas (escopos de exemplo: gulp, broccoli, npm),

  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs);

  • docs: referem-se a inclusão ou alteração somente de arquivos de documentação;

  • feat: Tratam adições de novas funcionalidades ou de quaisquer outras novas implantações ao código;

@offpepe
offpepe / ValidationExample.cs
Created Feb 25, 2022
Abstract validator example to viewModel/DTO validation
View ValidationExample.cs
public class CustomValidation : AbstractValidator<ToValidateViewModel>
{
public EditarCursoValidation()
{
RuleFor(example => example).SetValidator(new Validator());
}
}
public class Validator : AbstractValidator<ToValidateViewModel>
@offpepe
offpepe / update1.cs
Last active Feb 24, 2022
update models
View update1.cs
public async Task updateT1 (T update) {
db.Table.Attach(updatedUser);
var entry = db.Entry(updatedUser);
entry.Property(e => e.Field).IsModified = true;
await db.SaveChangesAsync();
}