Hi,
based upon above url i am going to do save functionality
based uponRId i am going to save grid View records into another table
SId CName Ctype Date RId
1 Fromdate datepicker Today 1
2 ToDate datepicker Yesday 1
3 RAI_Item Dropdown One month 1
https://ibb.co/Lzqrvpf
if you can look into my screenshot initially i have one grid view
after clicking of setting button based upon RId i am going to display one more grid view
after that i am going to enter some values
at last finally after clicking of save button need to save grid view records into based upon RId
$scope.Save = function () {
var orders = {};
orders.RId = $scope.RId;
var details = new Array();
for (var j = 0; j < $scope.Details.length; j++) {
var detail = {};
var tax = {};
tax.CName = $scope.Details[j].CName;
tax.CType = $scope.Details[j].CType;
tax.Date = $scope.Details[j].Date;
tax.FromTable = $scope.Details[j].FromTable;
tax.DisplayCName = $scope.Details[j].DisplayCName;
tax.ValueCName = $scope.Details[j].ValueCName;
details.push(tax);
}
orders.details = details;
$http({
method: "Post",
url: "/jobcode/SaveOrder",
dataType: 'json',
headers: { "Content-Type": "application/json" },
data: '{orders: ' + JSON.stringify(orders) + '}'
}).success(function (data) {
alert(data);
clearfields();
}).error(function (err) {
$scope.Message = err.Message;
})
};
} ]);
[HttpPost]
public ActionResult SaveOrder(Report1 orders)
{
string result = "Error! Order Is Not Complete!";
bool isOrderExist = db.Report1.Where(x => x.RId == orders.RId).ToList().Count > 0 ? true : false;
var oldOrder = db.Report1.Where(x => x.RId == orders.RId).FirstOrDefault();
if (isOrderExist)
{
int orderId = orders.RId;
foreach (ReportSetting taxes in orders.details)
{
ReportSetting subitem = new ReportSetting();
subitem.RId = orderId;
subitem.CName = taxes.CName;
subitem.CType = taxes.CType;
subitem.DisplayCName = taxes.DisplayCName;
subitem.ValueCName = taxes.ValueCName;
subitem.FromTable = taxes.FromTable;
subitem.Date = taxes.Date;
db.ReportSettings.Add(subitem);
db.SaveChanges();
}
result = "Success! Order Is InComplete!";
}
return Json(result, JsonRequestBehavior.AllowGet);
}