Hi guys,
I am trying to make a muti step jquery form for uploading resume,
and i send data to db by json and using Linq to Entity,
I have 4 tables:
1- Basic info
2- education info
3- work experience and
4- skills
when user click on submit button i need to add edu and work and skill info into another tables but i need the generated userid to insert into those tables as foreign keys,
dont know how to get id and how to pass it as parameters into those tables:
its my json code:
<script>
windows.onload = function () {
$.getFormObject = function (selector) {
var obj = {};
var propArr = $(selector).serializeArray();
$.each(propArr, function (i, p) {
obj[p.name] = p.value;
});
return obj;
};
};
</script>
<script>
// window.onload =
$(function () {
$('#btnSubmit').on('click', function () {
var formObj = $.getFormObject('#msform');
formObj.Id = 0;
var dataToSend = { resume: formObj };
$.ajax({
url: '/Resume.aspx/AddBaseResume',
contentType: 'application/json',
dataType: 'json',
type: 'post',
data: JSON.stringify(dataToSend),
success: function (id) {
var $messageContainer = $('.message-container');
$messageContainer.html('');
$('<div class="alert alert-success" />')
.html('Your ID is: ' + id.d)
.hide()
.fadeIn()
.appendTo($messageContainer);
//reloadGrid();
},
error: function () {
var $messageContainer = $('.message-container');
$messageContainer.html('');
$('<div class="alert alert-danger" />')
.html('Oops! Can not add you right now! :(')
.hide()
.fadeIn()
.appendTo($messageContainer);
}
});;
});
});
</script>
and its my webmethod:
[WebMethod]
public static string AddBaseResume(tblResume resume)
{
var db = new SHDBEntities1();
db.tblResumes.Add(resume);
db.SaveChanges();
return resume.Id.ToString();
}
[WebMethod]
public static string AddEducation(tblEducation edu)
{
var db = new SHDBEntities1();
db.tblEducations.Add(edu);
db.SaveChanges();
return edu.Id.ToString();
}
thanks in advance for any help or suggestion!