@mortezaaghili wrote:
I wrote simple angularJs app for store data in Web api / entity framework. its fine and work very well. but when i want use Ionic for that purpose, i get an error while editing a record.
this is my Controller action:
public IHttpActionResult PutTblLocation(long id, TblLocation tbllocation) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tbllocation.LocationId) { return BadRequest(); } db.Entry(tbllocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TblLocationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
this is my Ionic controller for edit :
$scope.update = function (location) { var obj = { LocationId: $stateParams.LocationId, LocationName: location.LocationName, LocationDescription: location.LocationDescription }; $http.put(ServerPath + "/" + $stateParams.LocationId, $stateParams.LocationId, obj).success(function (data) { $state.go('tab.home'); }).error(function (data) { $scope.error = "An Error has occured while updating! " + data; }); };
i tried var json = JSON.stringify(obj) but nothing changed...
this is the error:
PUT url/api/locations/15 400 (Bad Request)
its seems has an error with that object i will send. I'd like to say, i have no error with get,add,delete operations. and even i have no any error with all operations in pure angularJS app
thanks
Posts: 1
Participants: 1