I'm fairly new to C# and i'm completely stumped as to what I should be doing next to be processing inputs from a user inside of an input form I've created with Bootstrap and Html along with a AngularJS controller.
Every time I try to return values with my Get methods for my api, my whole controller breaks.
I've read so many tutorials and know-hows on RESTful api web methods and i'm beginning to confuse myself far too much and over thinking it, because I understand it's a simple process.
Here is the code for my Controller below:
public class FeedbackController : ApiController
{
// GET: api/Feedback
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET: api/Feedback/
public string (Feedback id);
{
}
// POST: api/Feedback
public void Post([FromBody]Feedback value)
{
}
// PUT: api/Feedback
public void Put( [FromBody]Feedback value)
{
var test = value.FeedbackRating;
}
// DELETE: api/Feedback/
public void Delete(Feedback id)
{
}
public string post([FromUri]Feedback value)
{
return "Put returning: " + value;
}
//angular js
commonModule.controller('feedbackController', ['$scope', '$modal', ' $timeout', 'authenticationService',
function ($scope, $modal, $timeout, authenticationService) {
var init = function () {
$scope.feedbackPopup();
}
$scope.feedbackPopup = function () {
var modalInstance = $modal.open({
templateUrl: '/Scripts/app/common/views/popup.tpl.html',
resolve: {
},
controller: function ($scope, $modalInstance) {
$scope.close = function () {
$modalInstance.close();
};
$scope.submitFeedback = function () {
$scope.feedback = {
FeedbackRating: 1,
FeedbackSubject: 1,
FeedbackUpload: 1,
FeedbackDescription:1
};
authenticationService.submitFeedback($scope.feedback).then(
// Success Handler
function (result) {
$modalInstance.close();
$scope.message = "Feedback submitted";
$timeout(function () {
$scope.message = "";
}, 3000);
},
// Failure Handler
function () {
$scope.message = "Error updating specialization";
});
}
}
});
}
init();
}]);
})();
Feedback class
{
public class Feedback
{
public int FeedbackRating { get; set; }
private string EncryptedHexPuid { get; set; }
public string FeedbackDescription { get; set; }
public string FeedbackSubject { get; set; }
}
}
$httpcall, but preferably moreevery time I try to return values with my Get methods for my api, my whole controller breaks.do you mean your angular.js controller that is making the $http call or do you mean your wep api controller that is handling the request?