Skip to content

Instantly share code, notes, and snippets.

@hendrasyp
hendrasyp / Foo.cs
Created April 1, 2024 03:37
Execute Stored Procedure
public interface IService{
public Task<MyModel> Get_MyMethod();
}
public class Service : IService {
public async Task<MyModel> Get_MyMethod(){
// 1. Buat list parameter
List<SqlParam> parameters = new List<SqlParam>();
parameters.Add(new SqlParam { ParamType = DataTypeConstant.NUMERIC, ParamValue = partnerKey }); // @ID
```
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Application": {
@hendrasyp
hendrasyp / Foo.cs
Created February 16, 2024 02:39
HOM API Client
string response = "";
// parameter Body, menggunakan format JSON, jika semua nilai adalah string, Anda dapat menggunakan
// tipe data Dictionary<string, string>,
// tetapi Anda juga dapat menggunakan sebuah class object untuk menampung data request.
// Call API using dictionary
Dictionary<string, string> request = new Dictionary<string, string>();
request.add("itemKey1","value");
request.add("itemKey2","value");
@hendrasyp
hendrasyp / BPJSLog.cs
Last active September 20, 2023 07:14
BPJSLog
public BPJSFingerSEPFindOne_Response SEPFINGER_FindOne(string memberNo, DateOnly serviceDate, BPJSSetupEntity bpjsSetup)
{
string DateVal = serviceDate.ToString(BaseConfiguration.DateOnly).ToString();
StringBuilder jsonString = new StringBuilder();
BPJSResponse bpjsResponse = new BPJSResponse();
BPJSFingerSEPFindOne_Response resultBpjs = new BPJSFingerSEPFindOne_Response();
LogRequest dbLog = new LogRequest();
dbLog.DeviceInfo = "Background Process";
dbLog.PartnerKey = Int32.Parse(partnerKey);
@hendrasyp
hendrasyp / Foo.cs
Last active September 7, 2023 09:03
DevExpress GridView HTML RowPrepared
// 1. Tambahkan event OnHtmlRowPrepared pada Grid
protected void gridDaftarPasien_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
{
if (e.RowType != GridViewRowType.Data)
return;
// Dapatkan nilai dari si kolom
string status = e.GetValue("NamaKolom").ToString().ToLower();
// apa yang dilakukan pada grid jika memenuhi suatu kondisi tertentu
@hendrasyp
hendrasyp / CountryRepository.cs
Created April 5, 2023 01:54
Asynchronous Api NET6
public async Task<IQueryable<object>> GetCountry()
{
MSSQLDataAccess helper = new MSSQLDataAccess(_options);
List<SqlParam> tParams = new List<SqlParam>();
tParams.Add(new SqlParam { ParamType = DataTypeConstant.STR, ParamValue = "" });
string strSQL = helper.BuildQueryString(TSqlHelper.spName("STOREDPROCEDURE"), tParams);
IQueryable<object> result = helper.Read(strSQL);
return await Task.FromResult(result);
@hendrasyp
hendrasyp / SQLTableDescription.sql
Created March 29, 2023 07:32
Describe Table Description SQL Server
DECLARE @TableName VARCHAR(50) = 'TXP_Header';
select
st.name [Table],
sc.name [Column],
sep.value [Description]
from sys.tables st
inner join sys.columns sc on st.object_id = sc.object_id
left join sys.extended_properties sep on st.object_id = sep.major_id
and sc.column_id = sep.minor_id
@hendrasyp
hendrasyp / TableToCsharp.sql
Created March 29, 2023 07:30
Convert Table To Class csharp
--Updated by @Sean on 23th,December 2022
declare @TableName sysname = 'TXP_DataInfo' -- Replace this with your database table name.
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
@hendrasyp
hendrasyp / SP_Select.sql
Created December 23, 2022 10:51
SQL Server - Stored Procedure Show Data
CREATE PROCEDURE [Schema].[SP_Name] (@Param [DataType(Size)] = DEFAULT_VALUE)
AS
BEGIN
-- Condition With Coalesce
WHERE COALESCE(id, NULL) = COALESCE(@paramId, id, NULL) -- EQUALS
AND COALESCE(name, '%') LIKE COALESCE('%' + @paramName + '%', name, '%') -- LIKE
AND ( -- DATE RANGE
CONVERT(VARCHAR(10) , date, 111) >= CONVERT(VARCHAR(10) , @FromDate, 111) AND
CONVERT(VARCHAR(10) , date, 111) <= CONVERT(VARCHAR(10) , @ToDate, 111)
@hendrasyp
hendrasyp / SP_Transaction.sql
Created December 23, 2022 01:58
SQL Server - Stored Procedure With Transaction
CREATE PROCEDURE [Schema].[SP_Name] (@Param [DataType(Size)] = DEFAULT_VALUE)
AS
BEGIN TRY
BEGIN TRANSACTION
-- Business Logic Here
-- Throw Exception Example
-- RAISERROR (N'Please delete detail vital sign first !!' , 11, 1);