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 ErrorHandlingMiddleware | |
{ | |
private readonly RequestDelegate _next; | |
private readonly EmailSettings _settings; | |
public ErrorHandlingMiddleware(RequestDelegate next, IOptions<EmailSettings> settings) | |
{ | |
_next = next; | |
_settings = settings.Value; | |
} |
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
//https://forums.asp.net/t/2071573.aspx?Call+SQL+Server+Function+with+UDT+as+input+parameter | |
public async Task<int> MainCategorySort(int BrandId, IEnumerable<MainCategoryViewModel> vm, string ModifiedBy) | |
{ | |
var udt = new DataTable(); | |
udt.Columns.Add("MainCategoryId", typeof(int)); | |
udt.Columns.Add("CMSOrder", typeof(int)); | |
foreach(var item in vm) |
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
// [DisableCors] | |
[Authorize] | |
[Route("api/[controller]")] | |
public class AuthController : Controller | |
{ | |
private AuthicationSettings _authSettings { get; set; } | |
public AuthController(IOptions<AuthicationSettings> settings) | |
{ | |
_authSettings = settings.Value; |
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
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<system.webServer> | |
<handlers> | |
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> | |
</handlers> | |
<aspNetCore processPath="dotnet" arguments=".\WebApiCore3.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true"/> | |
</system.webServer> | |
</configuration> | |
<!--ProjectGuid: f6a83dd6-0abf-4ebf-bc7e-b4e620ca6fa9--> |
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
Email Validator: ^[a-zA-Z0–9_.+-]+@[a-zA-Z0–9-]+.[a-zA-Z0–9.]+$ |
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 string DataTableToXML(DataTable dt) | |
{ | |
var stringwriter = new System.IO.StringWriter(); | |
var serializer = new XmlSerializer(dt.GetType()); | |
serializer.Serialize(stringwriter, dt); | |
stringwriter.ToString(); | |
System.IO.StringWriter writer = new System.IO.StringWriter(); | |
writer = new System.IO.StringWriter(); |
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
string fileName = string.Empty; | |
var grid = new System.Web.UI.WebControls.GridView(); | |
grid.DataSource = _db.spArtworkContentReport_ContentOnly_DI_Buyer(true, false).ToList(); | |
fileName = "DataReport"; | |
grid.DataBind(); | |
Response.ClearContent(); |
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 void Delete(string Customer) | |
{ | |
// not tested | |
var array = Read().Item1; | |
var path = Read().Item2; | |
array.RemoveAt(array.FindIndex(x => x.Customer.Equals(Customer))); | |
string jsonData = JsonConvert.SerializeObject(array); | |
File.WriteAllText(path, jsonData); |
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.Data.Common; | |
using System.Data.Entity.Core.EntityClient; | |
namespace DataAccessLayer.Models | |
{ | |
public partial class MyEntities | |
{ | |
public MyEntities(string connString) | |
: base(GetSqlConnection(connString), 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 (var client = new HttpClient()) | |
{ | |
var data = client.GetAsync(new Uri($"{AppSettingsHelper.api_url}/Controller/Action?Parameter={variable}")).Result; | |
string json = data.Content.ReadAsStringAsync().Result; | |
list = JsonConvert.DeserializeObject<List<ViewModel>>(json); | |
} |