Skip to content

Instantly share code, notes, and snippets.

View mdcarmo's full-sized avatar
🏠
Working from home

Marcelo Dias mdcarmo

🏠
Working from home
View GitHub Profile
@mdcarmo
mdcarmo / .cshtml
Created May 6, 2016 19:43
post_mvc_knocnout
@using AjaxHelpers.Extensions
@model AjaxHelpers.Models.TaskList
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>TaskList</h2>
@using (Html.BeginForm())
{
<div class="row">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.divTotal{
border:1px solid gray;
padding: 10px;
width: 500px;
@mdcarmo
mdcarmo / grid_com_datatables
Created July 29, 2016 11:16
Modelo de criação de grid com DataTables
<h4 class="text-success">Listando tarefas com o Datatables</h4>
<div style="width:90%;">
<table id="Jdatatable" class="table table-responsive table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Titulo</th>
<th>Criado em:</th>
<th>Descrição</th>
<th>Fechado ?</th>
@mdcarmo
mdcarmo / configSwagger.cs
Last active March 21, 2018 11:43
configuração do swagger método ConfigureServices
services.AddSwaggerGen(c =>
{
c.AddSecurityDefinition(
"Bearer",
new ApiKeyScheme()
{
In = "header",
Description = "Please insert JWT with Bearer into field",
Name = "Authorization",
Type = "apiKey"
services.AddDbContext<ApiForBlogContext>(options =>
options.UseInMemoryDatabase("InMemoryDatabase"));
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
c.InjectStylesheet("/swagger-ui/custom.css");
c.InjectOnCompleteJavaScript("/swagger-ui/custom.js");
});
app.Run(context => {
@mdcarmo
mdcarmo / AutomapperConfig.cs
Created March 21, 2018 14:19
exemplo de mapeamento de classes com o Automapper
public class AutoMapperProfile: Profile
{
public AutoMapperProfile()
{
CreateMap<User, UserDto>();
CreateMap<UserDto, User>();
CreateMap<Post, PostDto>();
CreateMap<PostDto, Post>();
}
@mdcarmo
mdcarmo / AutomapperConfigClasse.cs
Created March 21, 2018 14:26
Exemplo para injetar a interface do AutoMappper
public class UserController: Controller
{
private UserService _service;
private IMapper _mapper;
/// <summary>
/// Construtor
/// </summary>
/// <param name="service"></param>
/// <param name="mapper"></param>
public class AlgumController
{
public IActionResult GetAll()
{
//recupero todas as entidades
var users = _service.GetAll();
//transformo uma lista de entidades em uma lista de dtos
var userDtos = _mapper.Map<IList<UserDto>>(users);
@mdcarmo
mdcarmo / SplashActivity.cs
Last active April 23, 2018 01:08
SplashActivity
[Activity(Theme = "@style/Theme.Splash",
MainLauncher = true, NoHistory = true)]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}