Friday, July 26, 2019

Thursday, July 25, 2019

Web Api Route

1. Route with passing id parameter


[RoutePrefix("api/books")] public class BooksController : ApiController
{
// GET /api/authors/1/books [Route("~/api/authors/{Id}/books")] public IEnumerable<Book> GetByAuthor(int authorId) { ... }
// ... }

2. Route with passing id parameter int type

// GET /api/authors/1/books [Route("~/api/authors/{Id:int}/books")] public IEnumerable<Book> GetByAuthor(int authorId) { ... }

3. Route With Passing parameter min 1 value or none of zero Constraint

[Route("users/{id:int:min(1)}")] public User GetUserById(int id) { ... }

Monday, July 22, 2019

Cross domain web api calling get with Jsonp

Using with Jsonp
1. Install package by Tools > NuGet Package Manager > Package Manager Console
        Install-package WebApiContrib.Formatting.Jsonp

2. Register in WebApiConfig

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            var jsonpFormatter = new JsonpMediaTypeFormatter(config.Formatters.JsonFormatter);
            config.Formatters.Insert(0, jsonpFormatter);
        }

3.  Apply JQuery Using Jsonp

   function getdata() {
        $.ajax({
            type: "get",                     
            url: "http://localhost:52359/api/employees_/",  //cross domain
            contentType: "application/json",
            dataType: "jsonp",                     
            data: JSON.stringify({
                Srno: $("#Srno").val(),
                Emp_Name: $("#Emp_Name").val(),
                Address: $("#Address").val(),
                Mobile: $("#Mobile").val()
            }),         
            success: function (data) {
                alert(data);
                console.log(data);
                var dt = JSON.parse(data);
                //alert(jsonObj.length);
            },
            error: function (data) {
                alert("error : " + data);
            },
            failed: function (data) {
                alert("failed : " + data);
            }
        });
    }

Sunday, July 21, 2019

Call Api with authentication in jquery or Call Api with authorization in jquery

1. Call Api with authentication in jquery or  Call Api with authorization in jquery
    or Call Api with authentication in ajax or  Call Api with authorization in ajax

function fn_item_list() {
        $.ajax({
            type: "GET",
            xhrFields: {
                withCredentials: true
            },
            headers: {
                'Authorization': 'Basic ' + 'admin:123'
                //'Authorization': 'Basic ' + btoa('admin:123')
            },
            url: "/api/Customers_",
            data: {
                cust_name: $("#cust_names").val()
            },
            success: function (data) {
                //alert(data);
                $("#div_item1 table tbody").empty();
                //var dt = JSON.parse(data);
                var dt = data;
                //alert(jsonObj.length);
                for (var i = 0; i < dt.length; i++) {
                    var sql = "<tr>";
                    sql += " <td>" + dt[i].cust_code + "</td>";
                    sql += " <td>" + dt[i].cust_name + "</td>";
                    sql += " <td onclick=fn_Edit('" + dt[i].cust_code + "') class='btn btn-success' ><i class='fa fa-trash' aria-hidden='true'></i></td>";
                    sql += " <td onclick=fn_Delete('" + dt[i].cust_code + "') class='btn btn-danger' ><i class='fa fa-trash' aria-hidden='true'></i></td>";
                    sql += "</tr>";
                    $("#div_item1 table tbody").append(sql);
                }
            },
            error: function (data) {
                alert("error : " + data);
            },
            failed: function (data) {
                alert("failed : " + data);
            }
        });
    };

Api Post Put Same plate-form

1. Api Post Put Same plate-form not cross plate-form and
call Api Post using json with body,
call Api Put using json with body,
call Api Delete using json,
call Api Get using json with url,


<script src="~/scripts/jquery-3.4.1.min.js"></script>
<script>
    $(document).ready(function () {
        $("#insert").click(function () {
            insert();
        })
        $("#update").click(function () {
            update();
        })
    })

    function insert() {
        $.ajax({
            type: "post",
            url: "http://localhost:52359/api/employees_/",         
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify({
                Srno: $("#Srno").val(),
                Emp_Name: $("#Emp_Name").val(),
                Address: $("#Address").val(),
                Mobile: $("#Mobile").val()
            }),
            success: function (data) {
                alert(data);             
                var dt = JSON.parse(data);
                //alert(jsonObj.length);
            },
            error: function (data) {
                alert("error : " + data);
            },
            failed: function (data) {
                alert("failed : " + data);
            }
        });
    }
    function update() {
        $.ajax({
            type: "put",
            url: "http://localhost:52359/api/employees_/" + $("#Srno").val(),
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify({
                Srno: $("#Srno").val(),
                Emp_Name: $("#Emp_Name").val(),
                Address: $("#Address").val(),
                Mobile: $("#Mobile").val()
            }),
            success: function (data) {
                alert(data);
                var dt = JSON.parse(data);
                //alert(jsonObj.length);
            },
            error: function (data) {
                alert("error : " + data);
            },
            failed: function (data) {
                alert("failed : " + data);
            }
        });
    }

</script>

Friday, July 19, 2019

Convert mvc api xml into json or Convert mvc api into json

1. Convert mvc api xml into json in api route
    or Convert mvc api xml into json in WebApiConfig


       public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }

Thursday, July 18, 2019

local hosting

1. Link1
https://www.youtube.com/watch?v=nK0wsS9xF4E
2. Link2
https://www.youtube.com/watch?v=1Wo9ZvBMUIU
3. Link
https://www.youtube.com/watch?v=_cwOx_KyzJU

4.
new Google UI
flutter ui design


5.vs19 keys

<h4>Visual Studio 2019 Product Key:</h4>
<p>NBVFG-OCHGV-T58OE-DVGDE-7EOIV</p>
<p>G49EJ-Y7E8J-58F4T-9EDKJ-H594W</p>
<p>EKFH5-Y74ED-FCBHJ-48IEF-JEUI6</p>
<p>VBHFG-Y7S8V-98SIJ-4HUR6-C7FR5</p>
<p>3JKUI-9Y7E4-2KWPI-08RT5-JLWAH</p>
<h4>Visual Studio 2019 Serial Key:</h4>
<p>74L5J-PIFUR-42LWJ-SIPXF-SGRT4</p>
<p>2JNLW-RSFU8-SRT5N-JIPFS-RW42J</p>
<p>LWRSI-FRT4E-M7HGR-V6RDE-PL9IJ</p>
<h4>Visual Studio License Key {Premium}:</h4>
<p>HFYR7-8HXFY-7R8ED-HTY54-38DFT</p>
<p>Y54U8-EDRY7-54U8W-EDFGH-Y5F34</p>
<p>U8WES-DFNLJ-GRY54-UWEDF-GKH5U</p>
<p>8WSDX-JBGH5-8WFGJ-RU859-WDSFJ</p>
<p>NGU8E-49WED-FNDJG-TRU8C-PL9ID</p>
<h4>Visual Studio 2019 Activation Key:</h4>
<p>CFBHG-T5Y8D-FJDTH-I5G4Y-93T8Q</p>
<p>09WAS-DXFNB-GT593-480W9-EODFN</p>
<p>DJBGY-76G59-W4ESD-XFNGJ-BY76T</p>
<p>9U580-W9SDX-FJNBG-H85DE-L7YTR</p>
<h3>How to Install Visual Studio 2019 Crack:</h3>





Wednesday, July 17, 2019

Angular 2 Commads

1. Open commnad
    E:\E Drive\RND\Node\Angular2Apps\MyAng2App>ng serve --open 

2. Generate New Directory with .ts and .html and .css file like login
    E:\E Drive\RND\Node\Angular2Apps\MyAng2App>ng generate component login 




Publish in Angular2 or Build in Angular2

1.  ang2a is subdirectory name in localhost.
     Command is..
    c:\Users\DEESOFT07\myAng2\src>ng build --prod --base-href /ang2a/

2.  To Upload Direct Domain or Sub-domain on server.
     Command is..
    c:\Users\DEESOFT07\myAng2\src>ng build --prod

3. Publish folder create in angular2 project will be  dist  folder.
    Then copy from dist folder and paste or upload on server or localhost

4.  You can check in published (dist) folder and check Index.html Page




Monday, July 15, 2019

Set Local Hosting with sql server or localhost

1. Set Local Hosting with sql server


Correct Path

1. Correct Path in Html Form

       <form action="../Order_Mas/
       <form action="~/Order_Mas/

2. Correct Path in Jquery or Correct Path in Ajax

      function fun_item_change() {
            $.ajax({
                type: "get",
                url: "../Order_Mas/item_detail",
                data: {
                    GCode: $("#GCode").val(),
                    ICode: $("#ICode").val()
                },
                success: function (data) {
                    //alert(data)

                },
                error: function (data) {
                    alert("error : " + data);
                },
                failed: function (data) {
                    alert("failed : " + data);
                }
            });
        };


3. Correct Path in Script or Correct Path in Js File

      <script src="~/assets/js/jquery.min.js"></script>

4. Correct Path in css file

     <link href="~/assets/css/app.min.css" rel="stylesheet" type="text/css" />

5. Correct Path in Image

     <img src="~/assets/images/flags/us.jpg" alt="user-image" class="mr-1" height="12">

Tuesday, July 9, 2019

Linq SqlQuery fill SelectListItem by sql normal query in linq

1. Fill into List<SelectListItem> in Linq by normal sql query

sql = "\n select o.Odr_Code Value, o.Odr_No Text ";
sql += "\n from v_Order o left join v_Sales s on o.Odr_Code=s.Odr_Code and o.ICode=s.ICode  ";
sql += "\n where o.Pcode='" + du.CSQ(Pcode) +"' ";
sql += "\n group by o.Odr_Code,o.Odr_No ";
sql += "\n having sum(isnull(o.Qty,0)-isnull(s.Qty,0))>0 ";
sql += "\n order by convert(numeric(18),substring(o.Odr_No,2,15)) ";
List<SelectListItem> list = db.Database.SqlQuery<SelectListItem>(sql).ToList();

2. Fill into List<Class> in Linq by normal sql query

public class Order_Remain
    {
        public string Odr_Code { get; set; }
        public string Odr_No { get; set; }
        public decimal Qty_Bal { get; set; }
    }


sql = "\n select o.Odr_Code , o.Odr_No  ";
sql += "\n ,sum(isnull(o.Qty,0)-isnull(s.Qty,0)) Qty_Bal ";
sql += "\n from v_Order o left join v_Sales s on o.Odr_Code=s.Odr_Code and o.ICode=s.ICode  ";
sql += "\n where o.Pcode='" + du.CSQ(Pcode) +"' ";
sql += "\n group by o.Odr_Code,o.Odr_No ";
sql += "\n having sum(isnull(o.Qty,0)-isnull(s.Qty,0))>0 ";
sql += "\n order by convert(numeric(18),substring(o.Odr_No,2,15)) ";            
var list_ = db.Database.SqlQuery<Order_Remain>(sql).ToList();
var list = (from x in list_
            select (new SelectListItem() { Text = x.Odr_No, Value = x.Odr_Code })).ToList();

Monday, July 8, 2019

Download vs2017 professional for offline

1. Download vs2017 for offline
cmd like

c:\ downloads>vs_pro.exe --layout e:\rinkesh\vs2017


Monday, July 1, 2019

Get data in Angular

1. Html

<!DOCTYPE html>
<html ng-app="ApiApp">
<head>
    <title></title>
<meta charset="utf-8" />
    <script src="scripts/angular.min.js"></script>
</head>
<body ng-controller="ApiCtrl">
    <p>Welcome</p>
    <p ng-repeat="data in Data">
        {{data.id}}-{{data.Name}}-{{data.address}}
    </p>
    <script type="text/javascript">
        var app = angular.module("ApiApp", [])
                         .controller("ApiCtrl", function ($scope, $http) {
                             //$http.get("http://localhost:53083/api/data/getdata") applicable
                             //$http.get("api/data/getdata")                        applicable
                             $http.get("/api/data/getdata")
                                    .then(function (apiResponse) {
                                        console.log(apiResponse);
                                        $scope.Data = apiResponse.data;
                                    })
                         })
    </script>
</body>
</html>

2. Web Api  Controller

[RoutePrefix("api/data")]
    public class DemoApiController : ApiController
    {
        [Route("getdata")]
        public List<info> GetData()
        {
         
            var data = new List<info>();
            data.Add(new info {id=1,Name="Rinkesh",address="Rupbas",mobile="87987798778" });
            data.Add(new info { id = 2, Name = "Kusum", address = "Agra", mobile = "555555555" });
            data.Add(new info { id = 3, Name = "Darsika", address = "Agra", mobile = "66666666" });
            data.Add(new info { id = 4, Name = "Vihan", address = "Agra", mobile = "88888888888" });
            return data;
        }
    }


3. Model

  public class info
    {
        public int id { get; set; }
        public string Name { get; set; }
        public string address { get; set; }
        public string mobile { get; set; }

    }

4. Angular Js File
Angular Js File

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)