public List<CustomerProspectOptionAttributeValue> GetAttributValueFromPostData(RegulatoryDocumentModel _dataModel, int idOption) { List<CustomerProspectOptionAttributeValue> retVal = new List<CustomerProspectOptionAttributeValue>(); Option targetOption = _dataModel.Option.Where(o => o.idOption.Equals(idOption)).FirstOrDefault(); if (targetOption.OptionAttribute != null) { foreach (var optAttr in targetOption.OptionAttribute) { string idPrefix = string.Empty; string dataType = optAttr.Datatype.ToLower(); if (dataType.Equals("string") || dataType.Equals("multiline")) idPrefix = "txt_{0}_{1}"; else if (dataType.Equals("int") || dataType.Equals("float")) idPrefix = "txt_{0}_{1}"; else if (dataType.Equals("datetime")) idPrefix = "dt_{0}_{1}"; else if (dataType.Equals("paymenttype")) idPrefix = "enum_{0}_{1}"; string ParamName = string.Format(idPrefix, optAttr.idOption, optAttr.idOptionAttribute); if (!string.IsNullOrEmpty(Request.Params[ParamName])) { string strVal = Request.Params[ParamName]; CustomerProspectOptionAttributeValue newVal = new CustomerProspectOptionAttributeValue(); newVal.idOptionAttribute = optAttr.idOptionAttribute; newVal.idCustomerProspect = _dataModel.TargetCustomerProspect.idCustomer; newVal.Value = strVal; retVal.Add(newVal); } } } return retVal; }
private RegulatoryDocumentModel GetOptionAttributeValueFromLMtoRM(int idOptionLM, int idOptionAttributeLM, int idOptionRM, int idOptionAttributeRM, RegulatoryDocumentModel regulatoryDocumentModel) { List<CustomerProspectOptionValue> lstRMValues = regulatoryDocumentModel.OptionValue; List<CustomerProspectOptionValue> lstLMValues = regulatoryDocumentModel.LM_RemunerationOptionValues; //Get from RM string RM_AttributeValue = CustomerProspectOptionBL.GetAttributeValue(idOptionRM, idOptionAttributeRM, lstRMValues); if (!string.IsNullOrEmpty(RM_AttributeValue)) { //Remove old option and attribute values CustomerProspectOptionValue rmOptValue = lstRMValues.Where(ov => ov.idOption == idOptionRM).FirstOrDefault(); IList<CustomerProspectOptionAttributeValue> lstOptionAttributeValues = new List<CustomerProspectOptionAttributeValue>(rmOptValue.CustomerProspectOptionAttributeValue); foreach (var item in lstOptionAttributeValues) { var optionAttrValueToBeDel = rmOptValue.CustomerProspectOptionAttributeValue.Where(oa => oa.idCustomerProspectOptionAttributeValue == item.idCustomerProspectOptionAttributeValue).FirstOrDefault(); rmOptValue.CustomerProspectOptionAttributeValue.Remove(optionAttrValueToBeDel); } lstRMValues.Remove(rmOptValue); } //Get from LM string LM_AttributeValue = CustomerProspectOptionBL.GetAttributeValue(idOptionLM, idOptionAttributeLM, lstLMValues); if (!string.IsNullOrEmpty(LM_AttributeValue)) { //exist optionvalue from RM ? CustomerProspectOptionValue rmOptValue = lstRMValues.Where(ov => ov.idOption == idOptionRM).FirstOrDefault(); if (rmOptValue == null) { rmOptValue = new CustomerProspectOptionValue() { idCustomerProspectOptionValue = 0, //?? idOption = idOptionRM, idCustomerProspect = regulatoryDocumentModel.TargetCustomerProspect.idCustomer, Value = string.Empty }; lstRMValues.Add(rmOptValue); } CustomerProspectOptionAttributeValue newOptAttributeValue = new CustomerProspectOptionAttributeValue() { idCustomerProspectOptionAttributeValue = 0, //?? idOptionAttribute = idOptionAttributeRM, idCustomerProspect = regulatoryDocumentModel.TargetCustomerProspect.idCustomer, Value = LM_AttributeValue, }; //Add optionattribute to optionvalue rmOptValue.CustomerProspectOptionAttributeValue.Add(newOptAttributeValue); } return regulatoryDocumentModel; }