Skip to content

Instantly share code, notes, and snippets.

@joshi-kumar
joshi-kumar / Dispaly ENUM class property name (Display attribute value)
Created April 3, 2018 09:16
Dispaly ENUM class property name (Display attribute value)
public string GetDisplayName(Enum enumValue)
{
return enumValue.GetType().GetMember(enumValue.ToString())
.First()
.GetCustomAttribute<DisplayAttribute>()
.Name;
}
@joshi-kumar
joshi-kumar / Send Email method with attachment
Last active December 22, 2021 05:54
Send Email method with attachment (with bcc option)
static public void Send(string emails, string subject, string message, bool isHTML=true, params string[] attachmentPaths)
{
try
{
using (var client = new SmtpClient())
{
var section = ConfigurationManager.GetSection("system.net/mailSettings/smtp") as SmtpSection;
// email message setting
MailMessage msg = new MailMessage();
using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProtectPDF
{
@joshi-kumar
joshi-kumar / JQuery Date time (Watch)
Created March 3, 2018 17:06
JQuery Date time (Watch)
Html File Code
===============================
<!doctype html>
<html>
<head><title> Translate </title>
<script type="text/javascript" src="watch.js">
</script>
</head>
@joshi-kumar
joshi-kumar / Xml issues
Created February 17, 2018 13:40
C# xml attribute get
var elemList = doc.GetElementsByTagName("spine")[0].ChildNodes; //solved by this
----------------------------------------------------------------
http://stackoverflow.com/questions/18017692/c-sharp-get-values-from-xml-attributes
<?xml version="1.0" encoding="utf-8" ?>
<Config version="1.0.1.1" >
<Items>
<Item action="Create" filename="newtest.xml"/>
<Item action="Update" filename="oldtest.xml"/>
</Items>
protected virtual string GetEpubPath()
{
return Path.Combine(_webHelper.MapPath("~/content/epubs/"));
}
public string CreateSampleEpub()
{
string[] files = Directory.GetFiles(GetEpubPath());//GetAllFiles
@joshi-kumar
joshi-kumar / Script
Created February 17, 2018 13:35
Script
analyticsandreport: function (urladd,productId,categoryId,typeId) {
$.ajax({
cache: false,
url: '/AnalyticsAndReports/InsertAnalytic',
data: { productId: productId, typeId: typeId, categoryId: categoryId },
type: 'post',
success: function (data) {
// window.location.href = urladd
},
});
@joshi-kumar
joshi-kumar / HIGH Chart
Created February 17, 2018 13:33
HIGH Chart
http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/members/setoptions/
http://api.highcharts.com/highcharts/yAxis
***********************
<Script>
@model DotNet.Highcharts.Highcharts
@using Nop.Core.Infrastructure;
@{
//Html.AppendScriptParts("~/Administration/Scripts/Highcharts-4.0.1/highcharts.js");
@joshi-kumar
joshi-kumar / LINQ best
Created February 17, 2018 13:30
LINQ best
query = from p in query
from pc in p.ProductCategories.Where(pc => (pc.Category.Published))
select p;
condition on property that is in list of list ex here [query] is list and in this list [ProductCategories] is list, And here check publish prperty that is in query=>ProductCategories=>category.
@joshi-kumar
joshi-kumar / Pass viewbag value from view to partialview
Created February 17, 2018 13:27
Pass viewbag value from view to partial view
Main view =>
@Html.Partial("_CatalogSelectors", Model.PagingFilteringContext, new ViewDataDictionary { { "pageTotal", ViewBag.pageTotal },{"productTotal", ViewBag.TotalProduct},{"productName",Model.Name} })
Get in partial view =>
@{
string pageTotal = Convert.ToString(ViewData["pageTotal"]);