Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
.NET Developing...

Carlos W. Mercado carloswm85

🎯
.NET Developing...
View GitHub Profile
View gist:9ee73db5268cdc0be6e34a8cde20294c
Checking project for required NuGet packges...
Downloading service reference from http://localhost/WebApiMining/api/...
ErrorFailed adding service reference(s). Failed to download metadata file from : http://localhost/WebApiMining/api/.
Checking project for required NuGet packges...
Downloading service reference from http://localhost/WebApiMining/...
Adding service reference to the project...
Generating code to .cs...
ErrorFailed adding service reference(s). Code generation for file NSwag.exe failed.
Command line: openapi2csclient /input:"C:\Users\carlo\source\repos\guiaminera\MiningGuide\MiningGuide.Web\OpenAPIs\.json" /classname:defg /namespace:abce /output:"C:\Users\carlo\source\repos\guiaminera\MiningGuide\MiningGuide.Web\OpenAPIs\.cs"
Output: NSwag command line tool for .NET 4.6.1+ WinX64, toolchain v13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v11.0.0.0))
View GetFileStatusList.cs
public List<ExpedientesEstados> GetFileStatusList(int id = 0, int idRequestStatus = 0, int idSector = 0, string fileNumber = "")
{
if (id != 0) return _unitOfWork.ExpedientesEstadosRepository.GetAll().Where(e => e.id == id).ToList();
if (idRequestStatus != 0) return _unitOfWork.ExpedientesEstadosRepository.GetAll().Where(e => e.idEstadoSolicitud == idRequestStatus).ToList();
if (idSector != 0) return _unitOfWork.ExpedientesEstadosRepository.GetAll().Where(e => e.idSector == idSector).ToList();
if (fileNumber != "") return _unitOfWork.ExpedientesEstadosRepository.GetAll().Where(e => e.nroExpediente == fileNumber).ToList();
return _unitOfWork.ExpedientesEstadosRepository.GetAll().ToList();
}
@carloswm85
carloswm85 / IWebService.cs
Created Dec 1, 2022
Guías Miners web service interface
View IWebService.cs
using Mining.Data.Entities;
using Mining.Data.Model;
using Mining.Service.Tools;
using System.Collections.Generic;
using System.Web;
namespace Mining.Service
{
public interface IWebService
{
View permisos.cs
// 1) Recupero los permisos en el controlador a través de un web service
System.Collections.ObjectModel.Collection<ImportadorRegalias.WebServicesAccess.Permisos> ListPermisos = oServicio.obtainModulosPermisosBySession(idSesion, 16);
List<int> ListaPermisos = new List<int>();
foreach (ImportadorRegalias.WebServicesAccess.Permisos oPermiso in ListPermisos)
ListaPermisos.Add(oPermiso.IdModulo);
HttpContext.Current.Session["ListaPermiso"] = ListaPermisos;
View parametro.cs
Session["IdSesion"] = oExchangeData.IdSesion;
Session["NombreUsuario"] = oExchangeData.Nombre;
Session["IdUsuario"] = oExchangeData.IdUsuario;
Session["IdEmpresa"] = oExchangeData.Empresa;
int idSesion = Int32.Parse(Request["IdSesion"]);
System.Collections.ObjectModel.Collection<MiningGuide.Web.WebServicesAccessMiningPortal.Permisos> ListPermisos = oServicio.obtainModulosPermisosBySession(idSesion, 16);
List<int> ListaPermisos = new List<int>();
@carloswm85
carloswm85 / TransactionScope.cs
Created Oct 5, 2022
Saving multiple entities in one transaction using Entity Framework.
View TransactionScope.cs
using (TransactionScope scope = new TransactionScope())
{
// TODO: Working on saving transaction
// Step 1
if (driver.id > 0) _unitOfWork.PersonRepository.Update(driver); else _unitOfWork.PersonRepository.Add(driver);
if (destination.id > 0) _unitOfWork.DestinationRepository.Update(destination); else _unitOfWork.DestinationRepository.Add(destination);
_unitOfWork.Save();
// Step 2
transportation.id_persona_transportista = driver.id;
@carloswm85
carloswm85 / norepaint.js
Last active Aug 16, 2022
Saved as .js just for adding some color to it. No repainting function for Pinescript 5.0
View norepaint.js
//@version=5
// === No repainting.
f_nrp(_timeframe, _expression) =>
// request.security(symbol=syminfo.tickerid, timeframe=_timeframe, expression=_expression[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off)[barstate.isrealtime ? 0 : 1] // PineCoders best practice.
request.security(symbol=syminfo.tickerid, timeframe=_timeframe, expression=_expression[1], lookahead = barmerge.lookahead_on)
// Use
ema_expression = ta.ema(low, ema_length)
// Get values using anti-repainting
View select2Example.js
$(document).ready(function () {
// Variable assignment
var $producerSelect = $('#ProducersId');
$producerSelect.on('select2:select', function (e) {
var data = e.params.data;
var idPerson = data.id;
var dataWrapper = {
View w9-sql-summary-queries-exercise3_solution.md

This is the solution. Be sure that you've spent a good chanck of your time trying out your own approaches before using this solution.

-- 3. How many of each category of bikes do we have in our "Baldwin Bikes" store, which has the store_id of 2.
-- We need to see the name of the category as well as the number of bikes in the category.
-- Sort it by lowest numbers first. 
USE bike;
USE bike;
SELECT * FROM category;
SELECT * FROM product;
@carloswm85
carloswm85 / proxyswitcher.sh
Created Jun 8, 2022
Bash script functions for quickly setting and unsetting proxy configurations. Includes examples.
View proxyswitcher.sh
function proxy {
YW='\033[0;33m' # Yellow
NC='\033[0m' # No Color
SB='\033[1;34m' # Sky Blue
PP='\033[1;35m' # Purple
printf "\n${YW}How to set and unset proxy using Git Bash: ${NC}"
printf "\n${PP}Check:"
printf "\n${NC} $ git config --global --list"
printf "\n${PP}SET (Example):"
printf "\n${NC} $ http.proxy=http://username:password@proxyaddress:port"