Esempio n. 1
0
        public GetAllCustomFieldsResponse GetAllCustomFieldsForForms(GetAllCustomFieldsRequest request)
        {
            Logger.Current.Verbose("Request received to fetch all custom fields for forms for account : " + request.AccountId);
            GetAllCustomFieldsResponse response = new GetAllCustomFieldsResponse();

            Logger.Current.Verbose("Request received to get CustomFields for forms.");
            IEnumerable <Field>          customFields = customFieldRepository.GetAllCustomFieldsForForms(request.AccountId);
            IEnumerable <FieldViewModel> customfields = Mapper.Map <IEnumerable <Field>, IEnumerable <FieldViewModel> >(customFields);

            response.CustomFields = new List <FieldViewModel>(customfields);
            return(response);
        }
Esempio n. 2
0
        public ActionResult SaveFormAs(int formId)
        {
            GetAllContactFieldsRequest  fieldsRequest  = new GetAllContactFieldsRequest();
            GetAllContactFieldsResponse fieldsResponse = formService.GetAllContactFields(fieldsRequest);
            GetFormResponse             response       = formService.GetForm(new GetFormRequest(formId)
            {
                AccountId   = this.Identity.ToAccountID(),
                RequestedBy = this.Identity.ToUserID(),
                RoleId      = this.Identity.ToRoleID()
            });

            response.FormViewModel.Fields = fieldsResponse.ContactFields.Where(c => c.FieldId != (int)ContactFields.PartnerTypeField && c.FieldId != (int)ContactFields.LifecycleStageField && c.FieldId != (int)ContactFields.LeadScore && c.FieldId != (int)ContactFields.DonotEmail && c.FieldId != (int)ContactFields.Owner).ToList();
            GetAllCustomFieldsRequest  customFieldRequest  = new GetAllCustomFieldsRequest(this.Identity.ToAccountID());
            GetAllCustomFieldsResponse customFieldResponse = customFieldService.GetAllCustomFieldsForForms(customFieldRequest);

            response.FormViewModel.CustomFields = customFieldResponse.CustomFields.Where(c => c.StatusId == FieldStatus.Active).ToList();
            var customFieldIds = response.FormViewModel.CustomFields.Select(f => f.FieldId).ToList();
            var communityField = response.FormViewModel.Fields.Where(c => c.FieldId == (int)ContactFields.Community).FirstOrDefault();

            communityField.FieldInputTypeId = FieldType.dropdown;
            var communityFormField = response.FormViewModel.FormFields.Where(c => c.FieldId == (int)ContactFields.Community).FirstOrDefault();

            if (communityFormField != null)
            {
                communityFormField.FieldInputTypeId = FieldType.dropdown;
            }
            var contactFieldIds = Enum.GetValues(typeof(ContactFields)).Cast <ContactFields>().ToList();

            response.FormViewModel.FormFields = response.FormViewModel.FormFields.Where(f => customFieldIds.Contains(f.FieldId) || contactFieldIds.Contains((ContactFields)f.FieldId)).OrderBy(f => f.SortId).ToList();
            foreach (FormFieldViewModel formField in response.FormViewModel.FormFields)
            {
                FieldViewModel fieldViewModel = response.FormViewModel.CustomFields.Where(c => c.FieldId == formField.FieldId).FirstOrDefault();
                if (fieldViewModel != null && fieldViewModel.ValueOptions.IsAny())
                {
                    formField.ValueOptions = fieldViewModel.ValueOptions;
                }
            }
            response.FormViewModel.FormId            = 0;
            response.FormViewModel.Status            = Entities.FormStatus.Active;
            response.FormViewModel.Name              = "";
            response.FormViewModel.CreatedDate       = DateTime.Now.ToUniversalTime();
            response.FormViewModel.AllSubmissions    = 0;
            response.FormViewModel.Submissions       = 0;
            response.FormViewModel.UniqueSubmissions = 0;
            var dateFormat = this.Identity.ToDateFormat();

            response.FormViewModel.DateFormat = dateFormat;
            ViewBag.SaveAs    = true;
            ViewBag.AccountID = UserExtensions.ToAccountID(this.Identity);
            return(View("AddForm", response.FormViewModel));
        }
Esempio n. 3
0
        public ActionResult EditForm(int formId)
        {
            int             accountId = this.Identity.ToAccountID();
            GetFormResponse response  = formService.GetForm(new GetFormRequest(formId)
            {
                AccountId   = accountId,
                RequestedBy = this.Identity.ToUserID(),
                RoleId      = this.Identity.ToRoleID()
            });
            GetAllContactFieldsRequest  fieldsRequest  = new GetAllContactFieldsRequest();
            GetAllContactFieldsResponse fieldsResponse = formService.GetAllContactFields(fieldsRequest);

            response.FormViewModel.Fields = fieldsResponse.ContactFields.ToList();
            GetAllCustomFieldsRequest  customFieldRequest  = new GetAllCustomFieldsRequest(this.Identity.ToAccountID());
            GetAllCustomFieldsResponse customFieldResponse = customFieldService.GetAllCustomFieldsForForms(customFieldRequest);

            response.FormViewModel.CustomFields = customFieldResponse.CustomFields.Where(c => c.StatusId == FieldStatus.Active).ToList();
            var communityField = response.FormViewModel.Fields.Where(c => c.FieldId == (int)ContactFields.Community).FirstOrDefault();

            communityField.FieldInputTypeId = FieldType.dropdown;
            var communityFormField = response.FormViewModel.FormFields.Where(c => c.FieldId == (int)ContactFields.Community).FirstOrDefault();

            if (communityFormField != null)
            {
                communityFormField.FieldInputTypeId = FieldType.dropdown;
            }
            var customFieldIds  = response.FormViewModel.CustomFields.Where(c => c.StatusId == FieldStatus.Active).Select(f => f.FieldId).ToList();
            var contactFieldIds = Enum.GetValues(typeof(ContactFields)).Cast <ContactFields>().ToList();

            response.FormViewModel.FormFields = response.FormViewModel.FormFields.Where(f => customFieldIds.Contains(f.FieldId) || contactFieldIds.Contains((ContactFields)f.FieldId)).OrderBy(f => f.SortId).ToList();
            foreach (FormFieldViewModel formField in response.FormViewModel.FormFields)
            {
                FieldViewModel fieldViewModel = response.FormViewModel.CustomFields.Where(c => c.FieldId == formField.FieldId).FirstOrDefault();
                if (fieldViewModel != null && fieldViewModel.ValueOptions.IsAny())
                {
                    formField.ValueOptions = fieldViewModel.ValueOptions;
                }
            }
            ViewBag.SaveAs    = false;
            ViewBag.AccountID = UserExtensions.ToAccountID(this.Identity);
            var timeZone = this.Identity.ToTimeZone();
            var value    = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
            var newDate  = TimeZoneInfo.ConvertTime(response.FormViewModel.CreatedDate, value);

            response.FormViewModel.LastModifiedOn = newDate;
            var dateFormat = this.Identity.ToDateFormat();

            response.FormViewModel.DateFormat = dateFormat;
            ViewBag.TagPopup = true;
            return(View("AddForm", response.FormViewModel));
        }
        private PersonViewModel GetUpdatedPersonData(PersonViewModel existingModel, PersonViewModel newModel)
        {
            Person person         = new Person();
            var    dropdownValues = _cachingService.GetDropdownValues(newModel.AccountID);

            existingModel.FirstName   = !string.IsNullOrEmpty(newModel.FirstName) ? newModel.FirstName : existingModel.FirstName;
            existingModel.LastName    = !string.IsNullOrEmpty(newModel.LastName) ? newModel.LastName : existingModel.LastName;
            existingModel.CompanyName = !string.IsNullOrEmpty(newModel.CompanyName) ? newModel.CompanyName : existingModel.CompanyName;
            existingModel.Title       = !string.IsNullOrEmpty(newModel.Title) ? newModel.Title : existingModel.Title;

            List <short> phoneTypeIds        = newModel.Phones.IsAny() ? newModel.Phones.Select(p => p.PhoneType).ToList() : new List <short>();
            List <short> dropdownValueTyeIds = new List <short>();

            if (phoneTypeIds.IsAny())
            {
                dropdownValueTyeIds = _formRepository.GetDropdownValueTypeIdsByPhoneTypes(phoneTypeIds, newModel.AccountID);
            }

            var mobilePhoneNumber = dropdownValueTyeIds.Contains((short)DropdownValueTypes.MobilePhone) ? newModel.Phones.Select(m => m.Number).FirstOrDefault() : null;
            var homePhoneNumber   = dropdownValueTyeIds.Contains((short)DropdownValueTypes.Homephone) ? newModel.Phones.Select(m => m.Number).FirstOrDefault() : null;
            var workPhoneNumber   = dropdownValueTyeIds.Contains((short)DropdownValueTypes.WorkPhone) ? newModel.Phones.Select(m => m.Number).FirstOrDefault() : null;

            var phoneTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.PhoneNumberType)
                             .Select(s => s.DropdownValuesList).FirstOrDefault().Where(d => d.IsActive == true);


            existingModel.Phones = new List <Phone>();

            Log.Informational("While Updating phones.");

            IEnumerable <Phone> existingPhones = _formRepository.GetPhoneFields(existingModel.ContactID);

            Phone mobilePhone = existingPhones.Where(w => w.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).FirstOrDefault();

            if (!string.IsNullOrEmpty(mobilePhoneNumber) && !(mobilePhoneNumber.Length < 10 || mobilePhoneNumber.Length > 15))
            {
                string number = mobilePhoneNumber.TrimStart(new char[] { '0', '1' });
                Phone  phone  = new Phone();
                phone.Number    = number;
                phone.AccountID = existingModel.AccountID;
                phone.IsPrimary = mobilePhone != null ? mobilePhone.IsPrimary : (homePhoneNumber == null && workPhoneNumber == null && !existingPhones.IsAny()) ||
                                  phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).Select(c => c.IsDefault).FirstOrDefault();
                phone.PhoneType     = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).Select(c => c.DropdownValueID).FirstOrDefault();
                phone.PhoneTypeName = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).Select(c => c.DropdownValue).FirstOrDefault();
                if (person.IsValidPhoneNumberLength(number))
                {
                    existingModel.Phones.Add(phone);
                }
            }
            else if (mobilePhone != null)
            {
                existingModel.Phones.Add(mobilePhone);
            }

            Phone homePhone = existingPhones.Where(w => w.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).FirstOrDefault();

            if (!string.IsNullOrEmpty(homePhoneNumber) && !(homePhoneNumber.Length < 10 || homePhoneNumber.Length > 15))
            {
                string number = homePhoneNumber.TrimStart(new char[] { '0', '1' });
                Phone  phone  = new Phone();
                phone.Number    = number;
                phone.AccountID = existingModel.AccountID;
                phone.IsPrimary = homePhone != null ? homePhone.IsPrimary : (mobilePhoneNumber == null && workPhoneNumber == null && !existingPhones.IsAny()) ||
                                  phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).Select(c => c.IsDefault).FirstOrDefault();
                phone.PhoneType     = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).Select(c => c.DropdownValueID).FirstOrDefault();
                phone.PhoneTypeName = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).Select(c => c.DropdownValue).FirstOrDefault();
                if (person.IsValidPhoneNumberLength(number))
                {
                    existingModel.Phones.Add(phone);
                }
            }
            else if (homePhone != null)
            {
                existingModel.Phones.Add(homePhone);
            }

            Phone workPhone = existingPhones.Where(w => w.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).FirstOrDefault();

            if (!string.IsNullOrEmpty(workPhoneNumber) && !(workPhoneNumber.Length < 10 || workPhoneNumber.Length > 15))
            {
                string number = workPhoneNumber.TrimStart(new char[] { '0', '1' });
                Phone  phone  = new Phone();
                phone.Number    = number;
                phone.AccountID = existingModel.AccountID;
                phone.IsPrimary = workPhone != null ? workPhone.IsPrimary : (mobilePhoneNumber == null && homePhoneNumber == null && !existingPhones.IsAny()) ||
                                  phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).Select(c => c.IsDefault).FirstOrDefault();
                phone.PhoneType     = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).Select(c => c.DropdownValueID).FirstOrDefault();
                phone.PhoneTypeName = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).Select(c => c.DropdownValue).FirstOrDefault();
                if (person.IsValidPhoneNumberLength(number))
                {
                    existingModel.Phones.Add(phone);
                }
            }
            else if (workPhone != null)
            {
                existingModel.Phones.Add(workPhone);
            }

            IEnumerable <Phone> existingNonDefaultPhones = existingPhones.Where(w => w.DropdownValueTypeID != 9 && w.DropdownValueTypeID != 10 && w.DropdownValueTypeID != 11 && !w.IsDeleted);

            if (existingNonDefaultPhones.IsAny())
            {
                existingNonDefaultPhones.Each(e =>
                {
                    if (phoneTypeIds.IsAny())
                    {
                        if (phoneTypeIds.Contains(e.PhoneType))
                        {
                            var nonDefaultPhone = newModel.Phones.Where(p => p.PhoneType == e.PhoneType).FirstOrDefault();//workPhoneNumber.TrimStart(new char[] { '0', '1' });
                            string number       = nonDefaultPhone.Number.TrimStart(new char[] { '0', '1' });
                            if (e.Number != number)
                            {
                                e.IsPrimary         = false;
                                Phone phone         = new Phone();
                                phone.Number        = number;
                                phone.AccountID     = existingModel.AccountID;
                                phone.IsPrimary     = true;
                                phone.PhoneType     = nonDefaultPhone.PhoneType;
                                phone.PhoneTypeName = nonDefaultPhone.PhoneTypeName;
                                if (person.IsValidPhoneNumberLength(number.TrimStart(new char[] { '0', '1' })))
                                {
                                    existingModel.Phones.Add(phone);
                                }
                            }
                        }
                    }
                    existingModel.Phones.Add(e);
                });
            }

            Log.Informational("While Updating Addresses.");
            existingModel.Addresses = new List <AddressViewModel>();
            var addressLine1 = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.AddressLine1).FirstOrDefault() : null;
            var addressLine2 = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.AddressLine2).FirstOrDefault() : null;
            var city         = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.City).FirstOrDefault() : null;
            var state        = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.State).FirstOrDefault() : null;
            var zip          = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.ZipCode).FirstOrDefault() : null;
            var country      = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.Country).FirstOrDefault() : null;

            if (addressLine1 != null || addressLine2 != null || city != null || zip != null || country != null || state != null)
            {
                existingModel.AddressTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.AddressType)
                                             .Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true);

                AddressViewModel newAddress = new AddressViewModel();
                newAddress.AddressTypeID = existingModel.AddressTypes.SingleOrDefault(a => a.IsDefault).DropdownValueID;
                newAddress.AddressLine1  = addressLine1 != null && !string.IsNullOrEmpty(addressLine1) ? addressLine1 : "";
                newAddress.AddressLine2  = addressLine2 != null && !string.IsNullOrEmpty(addressLine2) ? addressLine2 : "";
                newAddress.City          = city != null && !string.IsNullOrEmpty(city) ? city : "";
                if (state != null)
                {
                    newAddress.State = new State()
                    {
                        Code = state.Code
                    }
                }
                ;
                else
                {
                    newAddress.State = new State();
                }
                if (country != null)
                {
                    newAddress.Country = new Country()
                    {
                        Code = country.Code
                    }
                }
                ;
                else
                {
                    newAddress.Country = new Country();
                }

                var zipCode = zip != null && !string.IsNullOrEmpty(zip) ? zip : "";
                newAddress.ZipCode   = zipCode;
                newAddress.IsDefault = true;

                if ((newAddress.State != null && !string.IsNullOrEmpty(newAddress.State.Code)) &&
                    (newAddress.Country == null || string.IsNullOrEmpty(newAddress.Country.Code)))
                {
                    newAddress.Country      = new Country();
                    newAddress.Country.Code = newAddress.State.Code.Substring(0, 2);
                }
                existingModel.Addresses.Add(newAddress);
            }

            existingModel.ContactType     = Entities.ContactType.Person.ToString();
            existingModel.SecondaryEmails = new List <dynamic>();

            Log.Informational("While Updating Life Cycle Stage.");
            existingModel.LifecycleStages = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LifeCycle)
                                            .Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true);
            var defaultLifeCycleType = existingModel.LifecycleStages.SingleOrDefault(a => a.IsDefault);

            if (newModel.LifecycleStage > 0)
            {
                if (!existingModel.LifecycleStages.Where(l => l.DropdownValueID == newModel.LifecycleStage).IsAny())
                {
                    newModel.LifecycleStage = existingModel.LifecycleStages.Where(l => l.IsDefault).Select(s => s.DropdownValueID).FirstOrDefault();
                }
            }
            existingModel.LifecycleStage = newModel.LifecycleStage > 0 ? newModel.LifecycleStage : defaultLifeCycleType.DropdownValueID;

            existingModel.AccountID     = newModel.AccountID;
            existingModel.LastUpdatedOn = DateTime.Now.ToUniversalTime();
            GetAllCustomFieldsResponse accountCustomFields = new GetAllCustomFieldsResponse();
            GetAllCustomFieldsRequest  request             = new GetAllCustomFieldsRequest(newModel.AccountID);

            accountCustomFields.CustomFields = _customFieldService.GetAllCustomFields(request).CustomFields;
            if (newModel.CustomFields.IsAny())
            {
                Log.Informational("While Updating Custom fields.");
                foreach (ContactCustomFieldMapViewModel submittedField in newModel.CustomFields)
                {
                    try
                    {
                        var isCustomField = accountCustomFields.CustomFields.Where(c => c.FieldId == submittedField.CustomFieldId).FirstOrDefault();
                        if (isCustomField != null)
                        {
                            ContactCustomFieldMapViewModel contactCustomField = new ContactCustomFieldMapViewModel();
                            contactCustomField.CustomFieldId    = submittedField.CustomFieldId;
                            contactCustomField.Value            = submittedField.Value;
                            contactCustomField.FieldInputTypeId = (int)isCustomField.FieldInputTypeId;
                            contactCustomField.ContactId        = existingModel.ContactID;
                            var existingCustomField = existingModel.CustomFields.Where(c => c.CustomFieldId == isCustomField.FieldId).FirstOrDefault();
                            if (existingCustomField == null)
                            {
                                existingModel.CustomFields.Add(contactCustomField);
                            }
                            else
                            {
                                existingCustomField.Value = submittedField.Value;
                            }
                        }
                    }
                    catch
                    {
                        Log.Informational("While Update: Submitted customfieldId: " + submittedField.CustomFieldId + " cannot be Updated. Value: " + submittedField.Value);
                    }
                }
            }

            return(existingModel);
        }
Esempio n. 5
0
        public ActionResult AddForm()
        {
            ViewBag.AccountId = this.Identity.ToAccountID();
            GetAllContactFieldsRequest  request  = new GetAllContactFieldsRequest();
            GetAllContactFieldsResponse response = formService.GetAllContactFields(request);
            var fieldsToBeRemoved = new List <int>();

            fieldsToBeRemoved.Add((int)ContactFields.PartnerTypeField);
            fieldsToBeRemoved.Add((int)ContactFields.DonotEmail);
            fieldsToBeRemoved.Add((int)ContactFields.LifecycleStageField);
            fieldsToBeRemoved.Add((int)ContactFields.LeadScore);
            fieldsToBeRemoved.Add((int)ContactFields.Owner);
            fieldsToBeRemoved.Add((int)ContactFields.WebPage);
            fieldsToBeRemoved.Add((int)ContactFields.WebPageDuration);
            fieldsToBeRemoved.Add((int)ContactFields.ContactTag);
            fieldsToBeRemoved.Add((int)ContactFields.FormName);
            fieldsToBeRemoved.Add((int)ContactFields.FormsubmittedOn);
            fieldsToBeRemoved.Add((int)ContactFields.FirstSourceType);
            fieldsToBeRemoved.Add((int)ContactFields.NoteSummary);
            fieldsToBeRemoved.Add((int)ContactFields.LastNoteDate);
            FormViewModel formViewModel = new FormViewModel();

            formViewModel.Fields     = response.ContactFields.Where(c => !fieldsToBeRemoved.Contains(c.FieldId)).ToList();
            formViewModel.FormFields = new List <FormFieldViewModel>();
            FieldViewModel firstNameField    = formViewModel.Fields.Where(f => f.FieldId == (int)ContactFields.FirstNameField).FirstOrDefault();
            FieldViewModel lastNameField     = formViewModel.Fields.Where(f => f.FieldId == (int)ContactFields.LastNameField).FirstOrDefault();
            FieldViewModel primaryEmailField = formViewModel.Fields.Where(f => f.FieldId == (int)ContactFields.PrimaryEmail).FirstOrDefault();
            FieldViewModel mobilePhoneField  = formViewModel.Fields.Where(f => f.FieldId == (int)ContactFields.MobilePhoneField).FirstOrDefault();
            FieldViewModel leadSourceField   = formViewModel.Fields.Where(f => f.FieldId == (int)ContactFields.LeadSource).FirstOrDefault();
            var            communityField    = formViewModel.Fields.Where(c => c.FieldId == (int)ContactFields.Community).FirstOrDefault();

            communityField.FieldInputTypeId = FieldType.dropdown;
            formViewModel.FormFields.Add(new FormFieldViewModel()
            {
                DisplayName      = firstNameField.Title,
                FieldId          = firstNameField.FieldId,
                FieldInputTypeId = firstNameField.FieldInputTypeId,
                IsMandatory      = firstNameField.IsMandatory,
                StatusId         = firstNameField.StatusId,
                Title            = firstNameField.Title,
                Value            = firstNameField.Value,
                ValueOptions     = firstNameField.ValueOptions
            });
            formViewModel.FormFields.Add(new FormFieldViewModel()
            {
                DisplayName      = lastNameField.Title,
                FieldId          = lastNameField.FieldId,
                FieldInputTypeId = lastNameField.FieldInputTypeId,
                IsMandatory      = lastNameField.IsMandatory,
                StatusId         = lastNameField.StatusId,
                Title            = lastNameField.Title,
                Value            = lastNameField.Value,
                ValueOptions     = lastNameField.ValueOptions
            });
            formViewModel.FormFields.Add(new FormFieldViewModel()
            {
                DisplayName      = primaryEmailField.Title,
                FieldId          = primaryEmailField.FieldId,
                FieldInputTypeId = primaryEmailField.FieldInputTypeId,
                IsMandatory      = true,
                StatusId         = primaryEmailField.StatusId,
                Title            = primaryEmailField.Title,
                Value            = primaryEmailField.Value,
                ValueOptions     = primaryEmailField.ValueOptions
            });
            formViewModel.FormFields.Add(new FormFieldViewModel()
            {
                DisplayName      = mobilePhoneField.Title,
                FieldId          = mobilePhoneField.FieldId,
                FieldInputTypeId = mobilePhoneField.FieldInputTypeId,
                IsMandatory      = false,
                StatusId         = mobilePhoneField.StatusId,
                Title            = mobilePhoneField.Title,
                Value            = mobilePhoneField.Value,
                ValueOptions     = mobilePhoneField.ValueOptions
            });
            formViewModel.FormFields.Add(new FormFieldViewModel()
            {
                DisplayName      = leadSourceField.Title,
                FieldId          = leadSourceField.FieldId,
                FieldInputTypeId = leadSourceField.FieldInputTypeId,
                IsMandatory      = true,
                StatusId         = leadSourceField.StatusId,
                Title            = leadSourceField.Title,
                Value            = leadSourceField.Value
            });
            //formViewModel.FormFields.Add(new FormFieldViewModel()
            //{
            //    DisplayName = "",
            //    FieldId = (int)ContactFields.FormURLField,
            //    FieldInputTypeId = FieldType.text,
            //    IsMandatory = false,
            //    StatusId = FieldStatus.Active,
            //    Title = "redirect-override",
            //    Value = null
            //});
            GetAllCustomFieldsRequest  customFieldRequest  = new GetAllCustomFieldsRequest(this.Identity.ToAccountID());
            GetAllCustomFieldsResponse customFieldResponse = customFieldService.GetAllCustomFieldsForForms(customFieldRequest);

            formViewModel.CustomFields        = customFieldResponse.CustomFields.Where(c => c.StatusId == FieldStatus.Active).ToList();
            formViewModel.FormId              = 0;
            formViewModel.Name                = "";
            formViewModel.Status              = Entities.FormStatus.Active;
            formViewModel.AcknowledgementType = Entities.AcknowledgementType.Url;
            formViewModel.CreatedBy           = this.Identity.ToUserID();
            formViewModel.LastModifiedBy      = this.Identity.ToUserID();
            formViewModel.AccountId           = this.Identity.ToAccountID();
            ViewBag.TagPopup = true;
            return(View("AddForm", formViewModel));
        }