Skip to content

Instantly share code, notes, and snippets.

@joshi-kumar
joshi-kumar / XML Code and Call Stored Procedure (Bind into model)
Created February 17, 2018 11:30
Create XML Code and call Stored Procedure & bind data into model
C# Code
=============================================================================================================================
Here we create an xml code and we parse or get data from xml file using SQL (Stored Procedure)
------------------------------------------------------------------------------------------------
public string AddEntitlementMaster(EntitlementMaster EmModel)
{
String strXmlString;
string empId = EmModel.vEmpId;
@joshi-kumar
joshi-kumar / SQL Stored Procedures (EHD)
Created February 17, 2018 11:32
SQL Stored Procedure
SQL Stored Procedures
----------------------------------------------------------------------
Here some example of SQL Stored Procedure for Insert/Update/Delete.
----------------------------------------------------------------------
USE [EHD]
GO
/****** Object: StoredProcedure [dbo].[EHD_ENTITLEMENT_MASTER_DETAILS] Script Date: 12/09/2017 09:49:55 ******/
SET ANSI_NULLS ON
GO
@joshi-kumar
joshi-kumar / save and resize image
Created February 17, 2018 11:33
Save image and resize image
public string SavePictureApiPath(string mimeType, int productId, byte[] pictureBinary)
{
//string lastPart = GetFileExtensionFromMimeType(mimeType);
string lastPart = "jpg";
string fileName = string.Format("{0}.{1}",productId, lastPart);
string path = Path.Combine(CommonHelper.MapPath("~/reader/new-epubs/coverpage/"), fileName);
byte[] resizePictureBinary;
@joshi-kumar
joshi-kumar / Count Duplicate value
Created February 17, 2018 11:34
Count duplicate value in List
var ListbrandList = new List<String>() {
"Joshi",
"Vikas",
"Joshi",
"Vikas",
"Sharma",
"Anuj",
"Joshi",
};
@joshi-kumar
joshi-kumar / Bind data into Model using Stored procedure
Created February 17, 2018 11:37
Bind data (Table Record) into Domain using Stored Procudure
Use Old Technique -
------------------------
SqlConnection sqlcon = new SqlConnection(SqlConString);
sqlcon.Open();
SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand("UserRecentRequestList", sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
@joshi-kumar
joshi-kumar / Delete duplicate record from table
Created February 17, 2018 11:38
Delete duplicate record from table in SQL
delete FROM dbo.GenrePreference WHERE id NOT IN (SELECT MIN(id) _
FROM dbo.GenrePreference GROUP BY CategoryId)
@joshi-kumar
joshi-kumar / String format
Created February 17, 2018 11:40
Convert variable value into string format
string accountActivationUrl = string.Format("{0}/customer/activation?token={1}&email={2}", url, "AccountActivationToken", HttpUtility.UrlEncode(email));
@joshi-kumar
joshi-kumar / Html file load changes and write a new file
Created February 17, 2018 11:42
Html file load changes and write in different file (read a html file)
string epubPath = "D://reader/epubs/test.html";
string epubPath1 = "D://reader/epubs/test1.html";
HtmlDocument doc = new HtmlDocument();
doc.Load(epubPath);
HtmlNode rootbody_node = doc.DocumentNode.Descendants("body").ElementAt(0);
HtmlNodeCollection body_elements = rootbody_node.ChildNodes;
if (body_elements.Count != 0)
@joshi-kumar
joshi-kumar / Add data in kendo grid using ajax
Created February 17, 2018 11:43
Add data into kendo grid using ajax
@model EmailAndNotificationModel
@using System.Globalization;
@{
var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
//page title
ViewBag.Title = "Send email & notification";
var GroupRolesIdsInput = new List<int>();
}
@joshi-kumar
joshi-kumar / Parse Json
Created February 17, 2018 11:45
Json parse and stringify
json stringify vs parse
Defi : JSON.parse() is for "parsing" something that was received as JSON. JSON.stringify() is to create a JSON string out of an object/array. They are the inverse of each other. JSON.stringify() serializes a JS object into a JSON string, whereas JSON.parse() will deserialize a JSON string into a JS object.Jul 22, 2013
https://stackoverflow.com/questions/17785592/difference-between-json-stringify-and-json-parse