Click here to Skip to main content
15,897,371 members

Comments by jj1992 (Top 14 by date)

jj1992 21-Jan-15 3:18am View    
when i put breakpoint in Device Controller post method and run the application it gets hit there with string id null
jj1992 21-Jan-15 3:17am View    
so please help where to define hat in my code
jj1992 21-Jan-15 3:16am View    
i'm using web api for the first time
jj1992 21-Jan-15 2:48am View    
this is my full server side code
================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DeviceCollection.Models;
namespace DeviceCollection.Controllers
{
public class DeviceController : ApiController
{
// GET api/HelloWorld
public IEnumerable<clsdevice> Get()
{
return new clsDevice[] { };
}

// GET api/values/5
public string Get(int id)
{
return null;
}

// POST api/values

public string Post([FromBody] string id)
{
ClsDeviceDL obj = new ClsDeviceDL();
return obj.SaveDevice(id);
}
==============================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

namespace DeviceCollection.Models
{
public class ClsDeviceDL
{
public string SaveDevice(string Value)
{
var jss = new JavaScriptSerializer();
var obj = jss.Deserialize<clsdevice>(Value);
clsDevice objTest = (clsDevice)obj;
string command = @"CALL SP_DeviceMaster( " + objTest.id+ ",'" + objTest.DeviceId+ "','" + objTest.Latitude + "'," + objTest.Longitude + "')";
string returnValue = "Error! Please try again";
DataSet ds = ClsDbTask.GetDataSet(command);

if (ds != null)
{
returnValue="saved Successfully";

}
return returnValue;

}
}
}
jj1992 21-Jan-15 2:38am View    
when i passing the data in client the controller post method in web api gets a null value