PDA

View Full Version : How to pass a parameter from model to a web service?



AesonErryl
10 Oct 2012, 5:27 AM
I am working on this.

In my CONTROLLER JS:


//more codes above
var isPublic = myAddNewTaskProject.down('[name=chbIsPublic]').getRawValue();


var record = new App.model.Project.prototype.newRecord(isPublic); //I want to pass the IsPublic value
record.data.title = projName;
record.data.description = descrip;


record.save();
//more codes below


In my Model JS:


Ext.define('App.model.Project', {
extend: 'Ext.data.Model',
fields: [
{ name: 'projectid', type: 'string' },
{ name: 'title', type: 'string' },
{ name: 'description', type: 'string' },
{ name: 'ownerPersonid', type: 'string' }
],
proxy: {
type: 'rest',
url: 'services/project/'
},
newRecord: function (isPublic) { //I don't know what's next.
var record = App.model.Project.create();
return record;
}
});



In my WebService.cs File:


[Post(UriTemplate = "/project/")]
public SingleResult<Project> SaveProject(Project project, bool isPublic) { //this is where I'll use my isPublic value


if(isPublic) {
project.OwnerPersonID = null; //do not assign owner
} else {
project.OwnerPersonID = ContextPersonID; //assign an owner of the project
}


TimeTrackerController.Save(project);
return new SingleResult<Project>(project);
}


I want to pass the value of the 'IsPublic'. But how can I do that inside my Model?

mitchellsimoens
15 Oct 2012, 7:39 AM
Set it as a parameter