Skip to main content

Posts

Showing posts from September, 2019

(JavaScript/jQuery): Create dynamically anchor tag and simulate click on that anchor tag automatically.

================================= var link = document.createElement('a');           link.href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + response.data;           link.download = "report" + GetCurrentDate() + ".xlsx";           //Firefox requires the link to be in the body           document.body.appendChild(link);           //simulate click           link.click();           //remove the link when done           document.body.removeChild(link); ================================= var GetCurrentDate = function () {       var today = new Date();       var dd = today.getDate();       var mm = today.getMonth() + 1; //January is 0!       var yyyy = today.getFullYear();       today = yyyy + '-' + mm + '-' + dd;       return today;     }; ======================================= //quarter = 2018.4, output = FY18 Q4 var GetFormattedQuarter = function (quarter) {       if (quarter) {        

Add Swagger To Asp.Net Core Rest API

Brief Add SwaggerGen to the services collection in the Configure method, and in the ConfigureServices method, enable the middleware for serving generated JSON document and the SwaggerUI. public void ConfigureServices ( IServiceCollection services ) { // Add framework services. services . AddMvc (); services . AddLogging (); // Add our repository type services . AddSingleton < ITodoRepository , TodoRepository >(); // Inject an implementation of ISwaggerProvider with defaulted settings applied services . AddSwaggerGen (); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure ( IApplicationBuilder app , IHostingEnvironment env , ILoggerFactory loggerFactory ) { app . UseMvcWithDefaultRoute (); // Enable middleware to serve generated Swagger as a JSON endpoint app . UseSwagger (); // Enable middlewar