public ActionResult UpdateInvestorInformation(FormCollection collection) { InvestorInformation model = new InvestorInformation(); this.TryUpdateModel(model, collection); ResultModel resultModel = new ResultModel(); string ErrorMessage = InvestorNameAvailable(model.InvestorName, model.InvestorId); if (String.IsNullOrEmpty(ErrorMessage) == false) { ModelState.AddModelError("InvestorName", ErrorMessage); } if (ModelState.IsValid) { // Attempt to update investor. DeepBlue.Models.Entity.Investor investor = InvestorRepository.FindInvestor(model.InvestorId); if (investor != null) { investor.InvestorName = model.InvestorName; investor.IsDomestic = model.DomesticForeign; investor.Alias = model.Alias; investor.Notes = model.Notes; investor.Source = model.Source; investor.FOIA = model.FOIA; investor.ERISA = model.ERISA; investor.ResidencyState = model.StateOfResidency; investor.InvestorEntityTypeID = model.EntityType; investor.LastUpdatedBy = Authentication.CurrentUser.UserID; investor.LastUpdatedDate = DateTime.Now; if (string.IsNullOrEmpty(investor.FirstName)) investor.FirstName = "n/a"; if (string.IsNullOrEmpty(investor.LastName)) investor.LastName = "n/a"; IEnumerable<ErrorInfo> errorInfo = InvestorRepository.SaveInvestor(investor); if (errorInfo != null) { foreach (var err in errorInfo.ToList()) { resultModel.Result += err.ErrorMessage + "\n"; } } else { // Update custom field Values resultModel.Result += SaveCustomValues(collection, investor.InvestorID); } if (string.IsNullOrEmpty(resultModel.Result)) resultModel.Result += "True||" + investor.InvestorID; } } else { foreach (var values in ModelState.Values.ToList()) { foreach (var err in values.Errors.ToList()) { if (string.IsNullOrEmpty(err.ErrorMessage) == false) { resultModel.Result += err.ErrorMessage + "\n"; } } } } return View("Result", resultModel); }
public void LoadCustomFieldValues(ref InvestorInformation model) { model.CustomField = new CustomFieldModel(); List<CustomFieldValue> customFieldValues = AdminRepository.GetAllCustomFieldValues(model.InvestorId); model.CustomField.Fields = AdminRepository.GetAllCustomFields((int)DeepBlue.Models.Admin.Enums.Module.Investor); model.CustomField.Values = new List<CustomFieldValueDetail>(); if (model.CustomField.Fields != null) { foreach (var field in model.CustomField.Fields) { var value = customFieldValues.SingleOrDefault(fieldValue => fieldValue.CustomFieldID == field.CustomFieldId); if (value != null) { model.CustomField.Values.Add(new CustomFieldValueDetail { CustomFieldId = value.CustomFieldID, CustomFieldValueId = value.CustomFieldID, DataTypeId = value.CustomField.DataTypeID, BooleanValue = value.BooleanValue ?? false, CurrencyValue = (value.CurrencyValue ?? 0), DateValue = ((value.DateValue ?? Convert.ToDateTime("01/01/1900")).Year == 1900 ? string.Empty : (value.DateValue ?? Convert.ToDateTime("01/01/1900")).ToString("MM/dd/yyyy")), IntegerValue = value.IntegerValue ?? 0, TextValue = value.TextValue, Key = model.InvestorId }); } else { model.CustomField.Values.Add(new CustomFieldValueDetail { CustomFieldId = field.CustomFieldId, CustomFieldValueId = 0, DataTypeId = field.DataTypeId, BooleanValue = false, CurrencyValue = 0, DateValue = string.Empty, IntegerValue = 0, TextValue = string.Empty, Key = model.InvestorId }); } } } }