I have an input field where employee can enter one or more Customer number and when they hit button it will get values of input field and it will put values into an array and than post data to contorller and in the end it will retrieves some data based on customer numbers to employee.
Lets say employee enter following customer numbers: 10883,10886,10888
and than it will put values in an array: items[10883,10886,10888]
and it will retrieves data for only: 10883,10886
as you see there is no data for: 10888
Her is my Question, when data retrieves to employee how can i make a condtions to check and see if there is no data for one of customer numbers tell employee for example:. there is no data for 10888
HTML:
<label>Enter Customer number</label>
<input name="CustomerNumber" id="CustomerNumber">
<button type="button" onclick="BtnAddCustomers();">Add</button>
JavaScript:
function BtnAddCustomers() {
var holderHTML = '';
var items = [];
items = $("#CustomerNumber").val().split(",");
$.ajax({
type: "GET",
url: "/User/GetCustomerContactInfo",
data: { ids: items },
traditional: true,
dataType: 'json',
success: function (values) {
for (var i = 0; i < values.length; i++) {
value = values[i]
if (value != null) {
holderHTML += '<tr id="row' + value.CustomerNo + '">';
holderHTML += '<td><input type="text" id="NameOfCompany" name="[' + i + '].NameOfCompany" value="' + value.NameOfCompany + '" /></td>';
holderHTML += '<td><input type="text" id="CustomerNo" name="[' + i + '].CustomerNo" value="' + value.CustomerNo + '" /></td>';
holderHTML += '</tr>';
}
$('#output').html(holderHTML);
}
}
})
};
Controller:
[HttpGet]
public JsonResult GetCustomerContactInfo(string[] ids)
{
var CustomerContactInfo = db.SomeTable
.Join(db.SomeTable, v => v.No_, g => g.No_, (v, g) => new { g, v })
.Select(t => new CreateCustomers
{
CustomerNo = t.v.No_,
NameOfCompany = t.g.Name,
})
.Where(s => ids.Contains(s.CustomerNo))
.ToList();
return Json(CustomerContactInfo, JsonRequestBehavior.AllowGet);
}
Can anyone please help me or point me into the right direction ?! :)