This file contains 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var timeExecution = new Stopwatch(); | |
Console.WriteLine($"Iniciando a execução"); | |
timeExecution.Start(); | |
InitProcess(); | |
timeExecution.Stop(); |
This file contains 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
Field<StringGraphType>( | |
"deleteCustomer", | |
arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "customerId" }), | |
resolve: context => | |
{ | |
var customerId = context.GetArgument<Guid>("customerId"); | |
var customer = repository.GetById(customerId, false).Result; | |
if (customer == null) | |
{ | |
context.Errors.Add(new ExecutionError("Cliente não encontrado na base de dados com este id.")); |
This file contains 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
Field<CustomerType>( | |
"updateCustomer", | |
arguments: new QueryArguments( | |
new QueryArgument<NonNullGraphType<CustomerInputType>> { Name = "customer" }, | |
new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "customerId" }), | |
resolve: context => | |
{ | |
var customer = context.GetArgument<Customer>("customer"); | |
var customerId = context.GetArgument<Guid>("customerId"); | |
This file contains 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
Field<CustomerType>( | |
"createCustomer", | |
arguments: new QueryArguments(new QueryArgument<NonNullGraphType<CustomerInputType>> { Name = "customer" }), | |
resolve: context => | |
{ | |
var customer = context.GetArgument<Customer>("customer"); | |
return repository.Create(customer); | |
} | |
); |
This file contains 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
Field<CustomerType>( | |
"customerById", | |
arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "customerId" }), | |
resolve: context => | |
{ | |
Guid id; | |
if (!Guid.TryParse(context.GetArgument<string>("customerId"), out id)) | |
{ | |
context.Errors.Add(new ExecutionError("Valor inserido não é um guid válido")); | |
return null; |
This file contains 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
namespace Products.Api.Controllers | |
{ | |
[Route("v1/product")] | |
public class ProductController: Controller | |
{ | |
private readonly IProdutctService _productsService; | |
public ProductController(IProdutctService productsService) | |
{ | |
_productsService = productsService; |
This file contains 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
namespace Products.Api.Services | |
{ | |
public class ProductService : IProdutctService | |
{ | |
private readonly Dictionary<string, int> _productListStorage = new Dictionary<string, int>(); | |
public Dictionary<string, int> GetProducts() | |
{ | |
return _productListStorage; | |
} |
This file contains 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
namespace Products.Api.Services | |
{ | |
public interface IProdutctService | |
{ | |
Dictionary<string, int> GetProducts(); | |
void AddProduct(ProductModel product); | |
void RemoveProduct(string productName); | |
} | |
} |
This file contains 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
namespace Products.Api.Models | |
{ | |
public class ProductModel | |
{ | |
public string Name { get; set; } | |
public int Quantity { get; set; } | |
} | |
} |
This file contains 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
$.ajax({ | |
url : 'someurl', | |
type : 'POST', | |
data : ...., | |
tryCount : 0, | |
retryLimit : 3, | |
success : function(json) { | |
//do something | |
}, | |
error : function(xhr, textStatus, errorThrown ) { |
NewerOlder