public ActionResult CreateContractWithMBAnalysis(vwCreateContractWithMBAnalysis model, List<int> IDList, string[] PaymentTypeID, string[] Price)
 {
     for (int i = 0; i < IDList.Count; i++)
     {
         ContractsAndMBAnalysisType obj = new ContractsAndMBAnalysisType();
         obj = db.GetContractsAndMBAnalysisType(IDList[i]);
         db.UpdateMBAnalysisInContract(obj, IDList[i], null, null, int.Parse(PaymentTypeID[i]), decimal.Parse(Price[i]));
     }
     return RedirectToAction("Index", new { message = "Контракт " + "'" + model.ContractItem.Description + "' с регистрационным номером " + model.ContractItem.AccountNumber + " добавлен в систему." });
 }
 public ActionResult CreateContractWithMBAnalysis(int id)
 {
     //ContractsAndMBAnalysisType obj = new ContractsAndMBAnalysisType();
     //Contract new_c = new Contract();
     //ViewData["ContractItem"] = db.GetContract(id);
     vwCreateContractWithMBAnalysis dataObj = new vwCreateContractWithMBAnalysis();
     var obj = db.GetMBAnalysisListForContract(id).ToList();
     List<int> analysisID = new List<int>();
     int countItems = 0;
     foreach (var item in obj)
     {
         analysisID.Add(item.ContractAndMBAnalysisTypeID);
         countItems++;
     }
     ViewData["ContractMBAnalysis"] = obj;
     dataObj.ContractMBAnalysis = obj;
     ViewData["CountMBAnalysis"] = countItems;
     dataObj.CountMBAnalysis = countItems;
     ViewData["MBContractMBAnalysisIDList"] = analysisID;
     dataObj.MBContractMBAnalysisIDList = analysisID;
     //var MBAnalysisList = db.GetMBAnalysisTypeListActive();
     //var PaymentTypes = db.GetPaymentTypeList();
     //foreach (var item in MBAnalysisList)
     //{
     //    MBAnalysisForContract newItem = new MBAnalysisForContract();
     //    newItem.MBAnalysisID = item.MBAnalysisTypeID;
     //    newItem.MBAnalysisDesc = item.DescriptionRus;
     //    newItem.PaymentTypeID = 2;
     //    newItem.Price = 0;
     //    List<tempPayment> newList = new List<tempPayment>();
     //    foreach (var itm in PaymentTypes)
     //    {
     //        newList.Add(new tempPayment { id = itm.PaymentTypeID, Text = itm.Description });
     //    }
     //    var selectList = new SelectList(newList, "Id", "Text", newItem.PaymentTypeID);
     //    newItem.PaymentTypeSelectList = selectList;
     //    tempList.Add(newItem);
     //}
     //obj.ContractMBAnalysis = tempList;
     var PaymentTypes = db.GetPaymentTypeList();
     List<tempSelectList> newSelectList = new List<tempSelectList>();
     foreach (var item in PaymentTypes)
     {
         newSelectList.Add(new tempSelectList { id = item.PaymentTypeID, Text = item.Description });
     }
     var selectList = new SelectList(newSelectList, "Id", "Text", 2);
     ViewBag.SelectList = selectList;
     ViewData["Contract"] = db.GetContract(id);
     dataObj.ContractItem = db.GetContract(id);
     ViewBag.CountItems = countItems;
     ViewBag.AnalysisID = analysisID;
     return View(dataObj);
 }