public ActionResult Update(string counterPartyGroup, long counterPartyId, string cifCounterParty, int isInau) { TheSession.Remove(_strSectionProduct); //xóa section list product CPProductGetDetailViewModel input = new CPProductGetDetailViewModel(); input.cifCounterParty = cifCounterParty; input.counterPartyGroup = counterPartyGroup; input.counterPartyId = counterPartyId; input.isInau = isInau; input.userId = RDAuthorize.UserId; var result = _cPProductService.getDetailCpProdCommis(input); #region CPProductViewModel model = new CPProductViewModel(); List <CPProductImportProductModel> productList = new List <CPProductImportProductModel>(); List <CPProductImportCommisionListModel> commisionList = new List <CPProductImportCommisionListModel>(); List <AttachmentViewModel> fileList = new List <AttachmentViewModel>(); if (result != null) { Library.TransferData(result, ref model);//main } if (result.fileList != null && result.fileList.Any()) { Library.TransferData(result.fileList, ref fileList); } if (result.productList != null && result.productList.Any()) { Library.TransferData(result.productList, ref productList); foreach (var item in result.productList) { if (item.commisionList != null && item.commisionList.Any()) { foreach (var item1 in item.commisionList) { CPProductImportCommisionListModel tempModel = new CPProductImportCommisionListModel(); Library.TransferData(item1, ref tempModel); tempModel.SelectList = productList; tempModel.productCode = productList.SingleOrDefault(x => x.productId == tempModel.productId).productCode; commisionList.Add(tempModel); } } } } model.commisionList = commisionList; model.productList = productList; model.viewMode = ViewModeCons.UPDATE; ViewBag.viewMode = ViewModeCons.UPDATE; ViewBag.fileList = fileList; #endregion return(View("Create", model)); }
public CPProductDetailModel getDetailCpProdCommis(CPProductGetDetailViewModel input) { try { CPProductDetailModel resultObject = new CPProductDetailModel(); SqlParameter[] prms = new SqlParameter[] { new SqlParameter { ParameterName = "counterPartyId", DbType = DbType.Int64, Value = input.counterPartyId, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "cifCounterParty", DbType = DbType.String, Value = string.IsNullOrEmpty(input.cifCounterParty) ? (object)DBNull.Value : input.cifCounterParty, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "counterPartyGroup", DbType = DbType.String, Value = string.IsNullOrEmpty(input.counterPartyGroup) ? (object)DBNull.Value : input.counterPartyGroup, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "isInau", DbType = DbType.Int32, Value = input.isInau, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "userId", DbType = DbType.String, Value = input.userId == null ? (object)DBNull.Value : input.userId, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "resultMessage", DbType = DbType.String, Direction = ParameterDirection.Output, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "resultCode", DbType = DbType.Int32, Direction = ParameterDirection.Output, Size = Int32.MaxValue } }; var result = _Repository.ExecWithStoreProcedureCommand(Store_getDetailCpProdCommis, prms); if (result.errorCode == 0) { resultObject = JsonConvert.DeserializeObject <CPProductDetailModel>(result.errorMessage); } else { HDBH.Log.WriteLog.Error("CPProductService => getDetailCpProdCommis => Detail" + result.errorMessage); } return(resultObject); } catch (Exception ex) { HDBH.Log.WriteLog.Error("CPProductService => getDetailCpProdCommis", ex); return(null); } }