Dirty read set flag for update record angular js

$scope.Update = function () { var index = 0; var arrPermissions = []; $scope.dataResult.forEach(function (row) { if (row.IsDirty == true) { arrPermissions.push(row); } }); SpinStart(); $http.post(“Security/Update”, { ViewModels: arrPermissions }) .success(function (data) { alert(” updated successfully.”); }) .error(function () { SpinStop(); alert(“Not valid.”); }); } // key press event $scope.Changed = function (id) { var… Read More Dirty read set flag for update record angular js

chosen js dropdown last select issue

Error on last item selection When I select last item on second time. It is giving an error “Uncaught TypeError: Cannot set property ‘selected’ of undefined” on every chosen. solution I had the same problem with this behavior. I used the following as workaround: <select chosen data-placeholder=”Placeholder” ng-model=”myValue” ng-options=”item.name for item in itemList” > <option… Read More chosen js dropdown last select issue

Custom Media formatter – HttpClient

send file from one solution to other solution Client public void UploadDomainAssembly(string filename) { String strFile = System.IO.Path.GetFileName(filename); using (var client = new HttpClient()) using (var content = new MultipartFormDataContent()) { // Make sure to change API address client.BaseAddress = new Uri(“http://localhost:8090/&#8221;); var fileContent = new ByteArrayContent(File.ReadAllBytes(filename)); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue(“AssemblyAttachment”) { FileName = strFile };… Read More Custom Media formatter – HttpClient

Custom Media formatter

for byte[] send a file into stream (byte[]) and get uploaded into other solution. Add new class to web api service public class BinaryMediaTypeFormatter : MediaTypeFormatter { private static Type _supportedType = typeof(byte[]); private const int BufferSize = 8192; // 8K public BinaryMediaTypeFormatter() { SupportedMediaTypes.Add(new System.Net.Http.Headers.MediaTypeHeaderValue(“application/octet-stream”)); } public override bool CanReadType(Type type) { return type… Read More Custom Media formatter

Api Versioning – with header and with url

  WebApiConfig.cs public static class WebApiConfig { public static void Register(HttpConfiguration config) { //// CODE IS FOR VERSIONING USING HEADER config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: “DefaultApi”, routeTemplate: “api/{controller}/{id}”, defaults: new { id = RouteParameter.Optional } ); config.Services.Replace(typeof(IHttpControllerSelector), new CustomControllerSelector((config))); // //// CODE IS FOR VERSIONING USING URL //var constraintsResolver = new DefaultInlineConstraintResolver(); //constraintsResolver.ConstraintMap.Add(“apiVersion1Constraint”, typeof(ApiVersion1Constraint)); //constraintsResolver.ConstraintMap.Add(“apiVersion2Constraint”, typeof(ApiVersion2Constraint)); //config.MapHttpAttributeRoutes(constraintsResolver);… Read More Api Versioning – with header and with url

Clever way to append ‘s’ for plural form in .Net

https://msdn.microsoft.com/en-us/library/system.data.entity.design.pluralizationservices.pluralizationservice(v=vs.110).aspx Namespace:   System.Data.Entity.Design.PluralizationServices Assembly:  System.Data.Entity.Design (in System.Data.Entity.Design.dll) public static Extentions { public static string Pluralize(this string str,int n) { if ( n != 1 ) return PluralizationService.CreateService(new CultureInfo(“en-US”)) .Pluralize(str); return str; } }