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.Configuration; | |
using MySql.Data.MySqlClient; | |
namespace Data.Dapper.Class | |
{ | |
public abstract class BaseRepository | |
{ | |
public string connstringSQL = ConfigurationManager.ConnectionStrings["SqlServerConnString"].ConnectionString; | |
public MySqlConnection GetMySqlConnection(bool open = true, |
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 Newtonsoft.Json; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Net; | |
using Velyo.Google.Services.Models; | |
namespace CepApp | |
{ | |
public class AddressUtil |
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 static List<BankAccount> GetList() | |
{ | |
string sqlQuery = @"SELECT | |
BA.Id, BA.Account, BA.Branch, | |
U.Id, U.Name, | |
A.Id, A.Street, A.City, | |
C.Id, C.Name, | |
BK.Id, BK.Name, | |
ACT.Id, ACT.Name, | |
ACC.Id, ACC.Name, |
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
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
Cluster.Bootstrap(new NancyProvider(), new ConsulProvider(), "customers", "v1"); | |
Console.ReadLine(); | |
} | |
} |
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
private static void DiscoverService() | |
{ | |
var instance = Cluster.FindServiceInstanceAsync("customers").Result; | |
Console.WriteLine($"{instance.Address} {instance.Port}"); | |
Console.ReadLine(); | |
} |
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
private static void Main(string[] args) | |
{ | |
Console.WriteLine("Starting NancyFX..."); | |
using (var nancyHost = new NancyHost(new Uri("http://localhost:8889/nancy/"))) | |
{ | |
nancyHost.Start(); | |
Console.WriteLine("Nancy now listening - navigating to http://localhost:8889/nancy/. Press enter to stop"); | |
Console.ReadLine(); | |
} | |
} |
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 CustomerController : NancyModule | |
{ | |
public CustomerController() : base("/customers") | |
{ | |
try | |
{ | |
var obj = new CustomerService(); | |
Get["/"] = _ => | |
{ |
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 CustomerService | |
{ | |
[CacheableResult(600)] // 600 seconds, 10 minutes cache policy | |
public List<dynamic> ReturnCustomer() | |
{ | |
var lstCustomer = new List<dynamic>(); | |
var customer = new Customer | |
{ | |
Id = 1, |
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 ModelStateValidationActionFilterAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(HttpActionContext actionContext) | |
{ | |
var modelState = actionContext.ModelState; | |
if (!modelState.IsValid) | |
actionContext.Response = actionContext.Request | |
.CreateErrorResponse(HttpStatusCode.BadRequest, modelState); | |
} |
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
[HttpPost] | |
[ModelStateValidationActionFilter] | |
public IHttpActionResult Post(object model) | |
{ | |
// Do something here ;) | |
} |