Wednesday, 23 August 2023

API IN PHP

 <?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: *');
header('Access-Control-Allow-Headers: *');
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Max-Age: 3600");
include "conn.php";
$json = file_get_contents("php://input");
$obj= json_decode($json,true);
$method=$_SERVER['REQUEST_METHOD'];
$path=explode('/',$_SERVER['REQUEST_URI']);
switch ($method) {
    case 'GET' :
        if(isset($path[4]) && is_numeric($path[4]))
        {
            $result=mysqli_query($conn,"Select * from expence where ID='$path[4]'");
            if (mysqli_num_rows($result) > 0) {
                while($row = mysqli_fetch_assoc($result)) {
                  $data=json_encode($row);
                }
                echo $data;
            }
            else
            {
                echo json_encode("result not found.");
            }
        }
        else
        {
            $result=mysqli_query($conn,"Select * from expence");
        if (mysqli_num_rows($result) > 0) {
            while($row[] = mysqli_fetch_assoc($result)) {
              $data=json_encode($row);
            }
            echo $data;
        }
        else
        {
            echo json_encode("result not found.");
        }
        }
        break;
    case 'POST':
        $dE=$obj["DE"];
        $aMOUNT=$obj["AMOUNT"];
        $tYPE=$obj["TYPE"];
        $yEAR=$obj["YEAR"];
        $cDATE=$obj["CDATE"];
        $result=mysqli_query($conn,"INSERT INTO `expence`(`DE`, `AMOUNT`, `TYPE`, `YEAR`, `CDATE`) VALUES ('$dE','$aMOUNT','$tYPE','$yEAR','$cDATE')");
        if($result)
        {
            echo json_encode("Data Inserted successfully.");
        }
        else
        {
            echo json_encode("Something went wrong.");
        }
        break;
        case 'PUT':
            $iD=$obj["ID"];
            $dE=$obj["DE"];
            $aMOUNT=$obj["AMOUNT"];
            $tYPE=$obj["TYPE"];
            $yEAR=$obj["YEAR"];
            $cDATE=$obj["CDATE"];
            $result=mysqli_query($conn,"UPDATE `expence` SET `DE`='$dE',`AMOUNT`='$aMOUNT',`TYPE`='$tYPE',`YEAR`='$yEAR',`CDATE`='$cDATE'  WHERE ID='$iD'");
            if($result)
            {
                echo json_encode("Data Updated successfully.");
            }
            else
            {
                echo json_encode("Something went wrong.");
            }  
            break;
            case 'DELETE':
                $iD=$obj["ID"];
    $result=mysqli_query($conn,"delete from  expence where ID='$iD'");
    if($result)
    {
        echo json_encode("Data deleted successfully.");
    }
    else
    {
        echo json_encode("Something went wrong.");
    }
                break;
    default:

        echo 'Something went wrong.';

        break;

}
mysqli_close($conn);
?>

Thursday, 17 August 2023

how to implement payment gateway




 

<html>

<button id="rzp-button1" class="btn btn-outline-dark btn-lg"><i class="fas fa-money-bill"></i> Own Checkout</button>

<script src="https://checkout.razorpay.com/v1/checkout.js"></script>

<script>

  var options = {

    "key": "Enter Your Key", // Enter the Key ID generated from the Dashboard

    "amount": "1000",

    "currency": "INR",

    "description": "Acme Corp",

    "image": "https://s3.amazonaws.com/rzp-mobile/images/rzp.jpg",

    "prefill":

    {

      "email": "gaurav.kumar@example.com",

      "contact": +919900000000,

    },

    config: {

    display: {

      blocks: {

        banks: {

          name: 'Pay using Axis banks',

          instruments: [

            {

              method: 'netbanking',

              banks: ['UTIB'],

            },

            {

              method: 'card',

              issuers: ['UTIB'],

            },

            {

                method: 'wallet',

                wallets:['payzapp']

            }

          ],

        },

      },

      sequence: ['block.banks'],

      preferences: {

        show_default_blocks: true,

      },

    },

  },

    "handler": function (response) {

      alert(response.razorpay_payment_id);

    },

    "modal": {

      "ondismiss": function () {

        if (confirm("Are you sure, you want to close the form?")) {

          txt = "You pressed OK!";

          console.log("Checkout form closed by the user");

        } else {

          txt = "You pressed Cancel!";

          console.log("Complete the Payment")

        }

      }

    }

  };

  var rzp1 = new Razorpay(options);

  document.getElementById('rzp-button1').onclick = function (e) {

    rzp1.open();

    e.preventDefault();

  }

</script>

</html>

Monday, 14 August 2023

how to send mail in php




 <?php

include 'Header.php';

if(isset($_POST["SubmitBtn"])){

$message ="Name = ". $_POST["name"] . "\r\n Mobile Number = " . $_POST["mobile"] . "\r\n Email id ="

.$_POST["email"]."\r\n".$_POST["msg"]; 

    $subject ="Feedback from JBS";

    $fromname ="JBSTECHNOSOFT";

    $fromemail = 'noreply@codeconia.com';  //if u dont have an email create one on your cpanel

    $mailto = 'chinmayaparijabanglore@gmail.com';  //the email which u want to recv this email

    // a random hash will be necessary to send mixed content

    $separator = md5(time());

    // carriage return type (RFC)

    $eol = "\r\n";

    // main header (multipart mandatory)

    $headers = "From: ".$fromname." <".$fromemail.">" . $eol;

    $headers .= "MIME-Version: 1.0" . $eol;

    $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;

    $headers .= "Content-Transfer-Encoding: 7bit" . $eol;

    $headers .= "This is a MIME encoded message." . $eol;

    // message

    $body = "--" . $separator . $eol;

    $body .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;

    $body .= "Content-Transfer-Encoding: 8bit" . $eol;

    $body .= $message . $eol;

    // attachment

    $body .= "--" . $separator . $eol;

    $body .= "Content-Transfer-Encoding: base64" . $eol;

    $body .= "Content-Disposition: attachment" . $eol;

    $body .= "--" . $separator . "--";

    //SEND Mail

    if (mail($mailto, $subject, $body, $headers)) {

        echo ""; // do what you want after sending the email

        

        

    } else {

        echo "mail send ... ERROR!";

        print_r( error_get_last() );

    }

}

?>

<div class="container" style="padding-top:5px">

<div class="well well-lg" style="text-align:left">

    <div class="panel panel-primary">

        <div class="panel-heading">Feedback</div>

        <div class="panel-body">

            <form id="emailForm" name="emailForm" method="post" action="Feedback">

                <div class="row form-group">

                <div class="col-md-3 col-sm-3 col-lg-3 col-xl-3">Enter Your Name</div>

                <div class="col-md-1 col-sm-1 col-lg-1 col-xl-1"><b>&nbsp</b></div>

                <div class="col-md-6 col-sm-6 col-lg-6 col-xl-6">

                    <input type="text" id="name" name="name" class="form-control" required>

                </div>

                <div class="col-md-2 col-sm-2 col-lg-2 col-xl-2">

                    &nbsp;

                </div>

                </div>

                <div class="row form-group">

                <div class="col-md-3 col-sm-3 col-lg-3 col-xl-3">Enter Your Mobile Number</div>

                <div class="col-md-1 col-sm-1 col-lg-1 col-xl-1"><b>&nbsp</b></div>

                <div class="col-md-6 col-sm-6 col-lg-6 col-xl-6">

                    <input type="text" id="mobile" name="mobile" class="form-control" required>

                </div>

                <div class="col-md-2 col-sm-2 col-lg-2 col-xl-2">

                    &nbsp;

                </div>

                </div>

                <div class="row form-group">

                <div class="col-md-3 col-sm-3 col-lg-3 col-xl-3">Enter Your Email Id</div>

                <div class="col-md-1 col-sm-1 col-lg-1 col-xl-1"><b>&nbsp</b></div>

                <div class="col-md-6 col-sm-6 col-lg-6 col-xl-6">

                    <input type="text" id="email" name="email" class="form-control" required>

                </div>

                <div class="col-md-2 col-sm-2 col-lg-2 col-xl-2">

                    &nbsp;

                </div>

                </div>

                <div class="row form-group">

                <div class="col-md-3 col-sm-3 col-lg-3 col-xl-3">Enter Your Feedback</div>

                <div class="col-md-1 col-sm-1 col-lg-1 col-xl-1"><b>&nbsp</b></div>

                <div class="col-md-6 col-sm-6 col-lg-6 col-xl-6">

                    <textarea id="msg" name="msg" rows="10" class="form-control" required></textarea>

                </div>

                <div class="col-md-2 col-sm-2 col-lg-2 col-xl-2">

                    &nbsp;

                </div>

                </div>

                <div class="row form-group">

                <div class="col-md-4 col-sm-4 col-lg-4 col-xl-4"></div>

                <div class="col-md-8 col-sm-8 col-lg-8 col-xl-8">

                   <input type="submit" value="Submit" id="SubmitBtn" name="SubmitBtn" class="btn btn-primary">

                   <input type="reset" value="Reset" class="btn btn-primary">

                </div>

                </div>

            </from>

        </div>

    </div>

</div>

</div><br>

<?php include 'Footer.php'; ?>

Monday, 7 August 2023

API IN PHP

 



Connection.php


<?php 

// Create connection

$conn = mysqli_connect("localhost","root" , "","testdb");

// Check connection

if (!$conn) {

  die("Connection failed: " . mysqli_connect_error());

}

?>


---

Index.php


<?php

header("Access-Control-Allow-Origin: *");

header("Access-Control-Allow-Headers: *");

header("Access-Control-Allow-Methods: *");

include "Connection.php";

$json = file_get_contents("php://input");

$obj= json_decode($json,true);

$mark= $obj["mark"];

if ($mark==1)

{

$result=mysqli_query($conn,"Select * from emp");

if (mysqli_num_rows($result) > 0) {

    while($row[] = mysqli_fetch_assoc($result)) {

      $data=json_encode($row);

    }

    echo $data;

}

else

{

    echo json_encode("result not found.");

}

}

elseif($mark==2)

{

    $eid=$obj["eid"];

    $result=mysqli_query($conn,"Select * from emp where EID='$eid'");

    if (mysqli_num_rows($result) > 0) {

        while($row = mysqli_fetch_assoc($result)) {

          $data=json_encode($row);

        }

        echo $data;

    }

    else

    {

        echo json_encode("result not found.");

    }


}

elseif($mark==3)

{

    $name=$obj["name"];

    $email=$obj["email"];

    $gender=$obj["gender"];

    $result=mysqli_query($conn,"INSERT INTO emp (`NAME`, `EMAIL`, `GENDER`) VALUES ('$name', '$email','$gender')");

    if($result)

    {

        echo json_encode("Data Inserted successfully.");

    }

    else

    {

        echo json_encode("Something went wrong.");

    }

}

elseif($mark==4)

{

    $eid=$obj["eid"];

    $name=$obj["name"];

    $email=$obj["email"];

    $gender=$obj["gender"];

    $result=mysqli_query($conn,"update emp set NAME='$name',EMAIL='$email',GENDER='$gender' where EID='$eid'");

    if($result)

    {

        echo json_encode("Data updated successfully.");

    }

    else

    {

        echo json_encode("Something went wrong.");

    }

}

elseif($mark==5)

{

    $eid=$obj["eid"];

    $result=mysqli_query($conn,"delete from  emp where EID='$eid'");

    if($result)

    {

        echo json_encode("Data deleted successfully.");

    }

    else

    {

        echo json_encode("Something went wrong.");

    }

}

mysqli_close($conn);

?>

Friday, 9 December 2022

How to add audio in website


<audio controls autoplay unmuted>

<source src="horse.ogg" type="audio/ogg">

<source src="Image/xxx.mp3" type="audio/mpeg">

</audio>


or


<embed src="Image/xxx.mp3" loop="true" autostart="true" width="0" height="0">

Sunday, 4 December 2022

CRUD operations using php api & mysql

 


.htaccess :


RewriteEngine On


 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteCond %{REQUEST_FILENAME} !-f

 RewriteRule ^ Index.php [L]


DB.php :

<?php 

class DbConnect {

private $server = 'localhost';

private $dbname = 'hanuman';

private $user = 'root';

private $pass = '';


public function connect() {

try {

$conn = new PDO('mysql:host=' .$this->server .';dbname=' . $this->dbname, $this->user, $this->pass);

$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

return $conn;

} catch (\Exception $e) {

echo "Database Error: " . $e->getMessage();

}

}

}

 ?>

Index.php


<?php

error_reporting(E_ALL); 

ini_set('display_errors',1);

header('Access-Control-Allow-Origin: *');

header('Access-Control-Allow-Methods: *');

header('Access-Control-Allow-Headers: *');

header("Content-Type: application/json; charset=UTF-8");

header("Access-Control-Max-Age: 3600");

include("DB.php");

$dbConnect = new DbConnect();

$conn= $dbConnect->connect();

$method=$_SERVER['REQUEST_METHOD'];

switch ($method) {

    case 'GET' : 

        $sql="select * from emp";

        $path=explode('/',$_SERVER['REQUEST_URI']);

        if(isset($path[2]) && is_numeric($path[2])){

        $sql .=" where eid =:eid order by eid desc";

        $stmt = $conn->prepare($sql);

        $stmt ->bindParam(':eid',$path[2]);

        $stmt->execute();

        $emp= $stmt->fetch(PDO::FETCH_ASSOC);

        }else {

            $stmt=$conn->prepare($sql);

            $stmt->execute();

            $emp= $stmt->fetchAll(PDO::FETCH_ASSOC);

        }

        echo json_encode($emp);

        break;

    case 'POST':

        $emp= json_decode(file_get_contents('php://input'));

        $sql="INSERT INTO `emp`(`NAME`, `ADDRESS`) VALUES (:name,:address)";

        $stmt = $conn->prepare($sql);

        $stmt->bindParam(':name',$emp->name);

        $stmt->bindParam(':address',$emp->address);

        if($stmt->execute()) { 

            $response= ['status' =>200, 'message' => 'Data Saved.'];

        }

        else {

            $response= ['status' =>500, 'message' => 'Internal server error.'];

        }

        return json_encode($response);

        break;

        case 'PUT':

            $emp= json_decode(file_get_contents('php://input'));

            $sql="UPDATE emp SET NAME=:name,ADDRESS=:address WHERE  EID=:eid";

            $stmt = $conn->prepare($sql);

            $stmt->bindParam(':eid',$emp->eid);

            $stmt->bindParam(':name',$emp->name);

            $stmt->bindParam(':address',$emp->address);

            if($stmt->execute()) { 

                $response= ['status' =>200, 'message' => 'Data Updated.'];

            }

            else {

                $response= ['status' =>500, 'message' => 'Internal server error.'];

            }

            return json_encode($response);

            break;

            case 'DELETE':

                $path=explode('/',$_SERVER['REQUEST_URI']);

                $sql="delete from emp where eid=:eid";

                $stmt = $conn->prepare($sql);

                $stmt ->bindParam(':eid',$path[2]);

                if($stmt->execute()) { 

                    $response= ['status' =>200, 'message' => 'Data deleted.'];

                }

                else {

                    $response= ['status' =>500, 'message' => 'Internal server error.'];

                }

                break;

    default:

        echo 'Something went wrong.';

        break;

}

?>

How call jquery ajax in php


Emp.php


<?php
if(isset($_POST['Name']))
{
 $name=$_POST['Name'];
 $addr=$_POST['Addr'];
 $conn=mysqli_connect("localhost","root","","hanuman");
 $sql="INSERT INTO `emp`( `NAME`, `ADDRESS`) VALUES ('$name','$addr')";
 $result=mysqli_query($conn,$sql);
 if($result)
 {
    echo "Data saved successfully.";
 }
 else
 {
    echo "Data can not saved.";
 }
}
?>

Index.html

<!DOCTYPE html>
<html>
<header>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</header>
<body style="margin-top:10px ;">
<div class="container">
    <form>
        <div class="row">
            <div class="col-md-4 text-right">
                <label for="txtname">Name</label>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <input type="text" id="txtname" name="txtname" class="form-control">
                </div>
            </div>
            <div class="col-md-4"></div>
            
        </div>
        <div class="row">
            <div class="col-md-4 text-right">
                <label for="txtadd">Address</label>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <textarea id="txtadd" name="txtadd" class="form-control"></textarea>
                </div>
            </div>
            <div class="col-md-4"></div>
            
        </div>
        <div class="row">
            <div class="col-md-4">
               
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <input type="button" id="btnsave" value="Submit" class="btn btn-primary">
                    <input type="reset" id="btnsave" value="Reset" class="btn btn-primary">
                </div>
            </div>
            <div class="col-md-4">

            </div>
        </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    $(function(){
        $('#btnsave').click(function(){
         var name=$('#txtname').val();
         var addr=$('#txtadd').val();
         $.post("Emp.php",{
            "Name":name,
            "Addr":addr 
         },function(data,status){
            alert(data);
         });
})
});
</script>

Call Api In Php :

<!DOCTYPE html>
<html>
<header>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</header>
<body style="margin-top:10px ;">
<div class="container">
    <form>
        <div class="row">
            <div class="col-md-4 text-right">
                <label for="txtname">Name</label>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <input type="text" id="txtname" name="txtname" class="form-control">
                </div>
            </div>
            <div class="col-md-4"></div>
            
        </div>
        <div class="row">
            <div class="col-md-4 text-right">
                <label for="txtadd">Address</label>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <textarea id="txtadd" name="txtadd" class="form-control"></textarea>
                </div>
            </div>
            <div class="col-md-4"></div>
            
        </div>
        <div class="row">
            <div class="col-md-4">
               
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <input type="button" id="btnsave" value="Submit" class="btn btn-primary">
                    <input type="reset" id="btnsave" value="Reset" class="btn btn-primary">
                </div>
            </div>
            <div class="col-md-4">

            </div>
        </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    $(function(){
        $('#btnsave').click(function(){
         var name=$('#txtname').val();
         var addr=$('#txtadd').val();
         $.post("http://localhost:8080/rabiapi/Index/Save",JSON.stringify({
            "name":name,
            "address":addr 
         }),function(data,status){
            alert(data);
         });
})
});
</script>


Saturday, 19 March 2022

CRUD operations using MVC & WebApi2

 


Web Api Code:


using System;

using System.Collections.Generic;

using System.ComponentModel.DataAnnotations;

using System.Linq;

using System.Web;


namespace WebApplication4.Models

{

    public class EMP

    {

        [Key]

        public int Eid { get; set; }

        public string Name { get; set; }

        public string Address { get; set; }

    }

}

---

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Data.Entity;


namespace WebApplication4.Models

{

    public class AppdbContext:DbContext

    {

        public AppdbContext() : base("name=AppDbConnection")

        {

        }

           public DbSet<EMP> Emps { get; set; }

    

    }

}

--

In web.config file u add the connection string

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <connectionStrings>
    <add name="AppDbConnection"
    connectionString="Data Source=(localdb)\ProjectsV13;Initial Catalog=Mahadev;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
    providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>
  1. Enable-Migrations: Enables the migration in your project by creating a Configuration class.
  2. Add-Migration: Creates a new migration class as per specified name with the Up() and Down() methods.
  3. Update-Database: Executes the last migration file created by the Add-Migration command and applies changes to the database schema.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using WebApplication4.Models;
using System.Data.Entity;
using System.Web.Http.Description;

namespace WebApplication4.Controllers
{
    [RoutePrefix("api/Emps")]
    public class EmpsController : ApiController
    {
        [HttpGet]
        public async Task<IHttpActionResult> Gets()
        {
            try
            {
                using (AppdbContext obj = new AppdbContext())
                {
                    return Ok(await obj.Emps.ToListAsync());
                }
                    
            }
            catch (Exception ex)
            {

                return StatusCode(HttpStatusCode.InternalServerError);
            }
        }
        [HttpGet]
        [ResponseType(typeof(EMP))]
        [Route("Get/{id}",Name ="Get")]
        public async Task<IHttpActionResult> Get(int Id)
        {
            try
            {
                using (AppdbContext obj = new AppdbContext())
                {
                    return Ok(await obj.Emps.FirstOrDefaultAsync(m=>m.Eid==Id));
                }

            }
            catch (Exception ex)
            {

                return StatusCode(HttpStatusCode.InternalServerError);
            }
        }
        [HttpPost]
        [ResponseType(typeof(EMP))]
        public async Task<IHttpActionResult> Post(EMP eMP)
        {
            try
            {
                using (AppdbContext obj = new AppdbContext())
                {
                    obj.Emps.Add(eMP);
                    await obj.SaveChangesAsync();
                    return CreatedAtRoute("Get", new { Id = eMP.Eid }, eMP);
                   
                }

            }
            catch (Exception ex)
            {

                return StatusCode(HttpStatusCode.InternalServerError);
            }
        }
        [HttpPut]
        [ResponseType(typeof(void))]
        public async Task<IHttpActionResult> Put(EMP eMP)
        {
            try
            {
                using (AppdbContext obj = new AppdbContext())
                {
                    EMP Emp = obj.Emps.Find(eMP.Eid);
                    Emp.Name = eMP.Name;
                    Emp.Address = eMP.Address;
                    await obj.SaveChangesAsync();
                    return StatusCode(HttpStatusCode.NoContent);

                }

            }
            catch (Exception ex)
            {

                return StatusCode(HttpStatusCode.InternalServerError);
            }
        }
        [HttpDelete]
        [ResponseType(typeof(EMP))]
        public async Task<IHttpActionResult> Delete(int Id)
        {
            try
            {
                using (AppdbContext obj = new AppdbContext())
                {
                    EMP Emp = obj.Emps.Find(Id);
                    obj.Emps.Remove(Emp);
                    await obj.SaveChangesAsync();
                    return Ok(Emp);
                }

            }
            catch (Exception ex)
            {

                return StatusCode(HttpStatusCode.InternalServerError);
            }
        }

    }
}

MVC code :

IIn order to create a Web API client.

Add Microsoft.AspNet.Webapi.Client using NuGet package manager.

using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
{
    public class EmpsController : Controller
    {
        private string Baseurl = string.Empty;
        public EmpsController()
        {
            Baseurl = "http://localhost:55419/api/Emps";
        }
        [HttpGet]
        public ActionResult Index()
        {
            using (HttpClient webClient = new HttpClient())
            {
                HttpResponseMessage webResponse = webClient.GetAsync(Baseurl).Result;
                return View(webResponse.Content.ReadAsAsync<List<Empvm>>().Result);
            }
        }
        [HttpGet]
        public ActionResult Create()
        {
            return View(new Empvm());
        }
        [HttpPost]
        public ActionResult Create(Empvm empvm)
        {
            using (HttpClient webClient = new HttpClient())
            {
                HttpResponseMessage webResponse = webClient.PostAsJsonAsync(Baseurl, empvm).Result;
                return RedirectToAction("Index");
            }
        }
        [HttpGet]
        public ActionResult Edit(int id)
        {
            using (HttpClient webClient = new HttpClient())
            {

                HttpResponseMessage webResponse = webClient.GetAsync(Baseurl + "/Get/" + id).Result;
                Empvm empvm1 = webResponse.Content.ReadAsAsync<Empvm>().Result;
                Empvm empvm = new Empvm();
                empvm.Eid = empvm1.Eid;
                empvm.Name = empvm1.Name;
                empvm.Address = empvm1.Address;
                return View(empvm);
            }
        }
        [HttpPost]
        public ActionResult Edit(Empvm empvm)
        {
            using (HttpClient webClient = new HttpClient())
            {
                HttpResponseMessage webResponse = webClient.PutAsJsonAsync(Baseurl, empvm).Result;
                return RedirectToAction("Index");
            }
        }
        [HttpGet]
        public  ActionResult Delete(int id)
        {
            using (HttpClient webClient = new HttpClient())
            {
                HttpResponseMessage httpResponseMessage = webClient.DeleteAsync(Baseurl + "/" + id).Result;
                return RedirectToAction("Index");
            }
        }
    }

}