public JsonResult UpdateProduct(CPProductInsertViewModel input) { CPProductInsertModel model = new CPProductInsertModel(); List <CPProductInsertProductItemModel> productList = new List <CPProductInsertProductItemModel>(); List <CPProductInsertCommisionItemModel> commisionList = new List <CPProductInsertCommisionItemModel>(); List <CPProductInsertAttachmenItemModel> fileList = new List <CPProductInsertAttachmenItemModel>(); Library.TransferData(input, ref model); Library.TransferData(input.fileList, ref fileList); Library.TransferData(input.productList, ref productList); Library.TransferData(input.commisionList, ref commisionList); model.productList = productList; model.fileList = fileList; model.commisionList = commisionList; model.userId = RDAuthorize.UserId; model.branchCode = RDAuthorize.BranchCode; model.jsonProductList = model.productList.Count > 0 ? JsonConvert.SerializeObject(model.productList): null; model.jsonCommisionList = model.commisionList.Count > 0 ? JsonConvert.SerializeObject(model.commisionList) : null; model.jsonFileList = model.fileList.Count > 0 ? JsonConvert.SerializeObject(model.fileList) : null; var result = _cPProductService.updateCpProdCommis(model).readResult(); return(Json(result)); }
public ResultModel updateCpProdCommis(CPProductInsertModel model) { try { ResultModel result = new ResultModel(); if (model.counterPartyGroup.ToUpper() == "UNCONTRACT") { SqlParameter[] prms = new SqlParameter[] { new SqlParameter { ParameterName = "counterPartyId ", DbType = DbType.Int64, Value = model.counterPartyId, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "counterPartyGroup", DbType = DbType.String, Value = model.counterPartyGroup == null ? (object)DBNull.Value : model.counterPartyGroup, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "status", DbType = DbType.String, Value = model.counterPartyStatus == null ? (object)DBNull.Value : model.counterPartyStatus, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "userId", DbType = DbType.String, Value = model.userId, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "branchCode", DbType = DbType.String, Value = model.branchCode, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "productList", DbType = DbType.String, Value = model.jsonProductList == null ? (object)DBNull.Value : model.jsonProductList, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "fileList", DbType = DbType.String, Value = model.jsonFileList == null ? (object)DBNull.Value : model.jsonFileList, 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 } }; result = _Repository.ExecWithStoreProcedureCommand(Store_updateCpUncontractProd, prms); } else { SqlParameter[] prms = new SqlParameter[] { new SqlParameter { ParameterName = "counterPartyId ", DbType = DbType.Int64, Value = model.counterPartyId, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "counterPartyGroup", DbType = DbType.String, Value = model.counterPartyGroup == null ? (object)DBNull.Value : model.counterPartyGroup, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "status", DbType = DbType.String, Value = model.counterPartyStatus == null ? (object)DBNull.Value : model.counterPartyStatus, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "userId", DbType = DbType.String, Value = model.userId, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "branchCode", DbType = DbType.String, Value = model.branchCode, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "isInau ", DbType = DbType.Int64, Value = model.isInau, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "productList", DbType = DbType.String, Value = model.jsonProductList == null ? (object)DBNull.Value : model.jsonProductList, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "commisionList", DbType = DbType.String, Value = model.jsonCommisionList == null ? (object)DBNull.Value : model.jsonCommisionList, Size = Int32.MaxValue }, new SqlParameter { ParameterName = "fileList", DbType = DbType.String, Value = model.jsonFileList == null ? (object)DBNull.Value : model.jsonFileList, 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 } }; result = _Repository.ExecWithStoreProcedureCommand(Store_updateCpProdCommis, prms); } return(result); } catch (Exception ex) { HDBH.Log.WriteLog.Error("CPProductService => updateCpProdCommis", ex); return(null); } }