예제 #1
0
        /// <summary>
        /// Utility method to convert address information from the WinRT ContactAddress
        /// instance to the representation in the vCard library.
        /// No 1:1 matching is possible between both classes, the method tries to
        /// keep the conversion as accurate as possible.
        /// </summary>
        /// <param name="address">Address information from WinRT.</param>
        /// <returns>The address information from WinRT library converted to a
        /// vCard library class instance.</returns>
        private vCardDeliveryAddress ConvertAddressToVcard(ContactAddress address)
        {
            var newAddress = new vCardDeliveryAddress
            {
                Country     = address.Country,
                PostalCode  = address.PostalCode,
                Region      = address.Region,
                Street      = address.StreetAddress,
                City        = address.Locality,
                AddressType = ConvertAddressTypeToVcard(address.Kind)
            };

            return(newAddress);
        }
예제 #2
0
        public Guid UpdateContactAddress(ContactAddress address)
        {
            var original = _fakeObjectGenerator.ContactAddresses.FirstOrDefault(add => add.Id == address.Id);

            if (original == null)
            {
                throw new Exception("The address you are trying to update does not exist");
            }

            _fakeObjectGenerator.ContactAddresses.Remove(original);
            _fakeObjectGenerator.ContactAddresses.Add(address);

            return(address.Id);
        }
예제 #3
0
        private IResult SetAddresses(Contact contact, IEnumerable <SetContactAddressParameters> setAddresses)
        {
            if (contact == null)
            {
                throw new ArgumentNullException("contact");
            }
            if (setAddresses == null)
            {
                throw new ArgumentNullException("setAddresses");
            }

            var setAddressesWithKeys     = setAddresses.Where(s => s.ContactAddressKey != null);
            var contactAddressesToRemove = contact.Addresses.Where(a => !setAddressesWithKeys.Any(s => s.ContactAddressKey.Equals(a))).ToList();

            foreach (var address in contactAddressesToRemove)
            {
                contact.Addresses.Remove(address);
                CompanyUnitOfWork.ContactAddressRepository.Remove(address);
            }

            var lastAddressSequence = contact.Addresses.Any() ? contact.Addresses.Max(a => a.AddressId) : 0;

            foreach (var setAddress in setAddresses)
            {
                ContactAddress contactAddress;
                if (setAddress.ContactAddressKey != null)
                {
                    contactAddress = contact.Addresses.SingleOrDefault(a => setAddress.ContactAddressKey.Equals(a));
                    if (contactAddress == null)
                    {
                        return(new InvalidResult(string.Format(UserMessages.ContactAddressNotFound, setAddress.ContactAddressKey.KeyValue)));
                    }
                }
                else
                {
                    contactAddress = new ContactAddress
                    {
                        CompanyId = contact.CompanyId,
                        AddressId = ++lastAddressSequence
                    };
                    contact.Addresses.Add(contactAddress);
                    CompanyUnitOfWork.ContactAddressRepository.Add(contactAddress);
                }

                contactAddress.AddressDescription = setAddress.ContactAddress.AddressDescription ?? "";
                contactAddress.Address            = setAddress.ContactAddress.Address ?? new Address();
            }

            return(new SuccessResult());
        }
예제 #4
0
 public async Task <IActionResult> ContactAddresses([FromBody] ContactAddress address)
 {
     if (string.IsNullOrEmpty(address.Id))
     {
         var currentUser = User.CurrentId();
         address.User = currentUser;
         address.Id   = await _dbService.AddContactAddress(address);
     }
     else
     {
         await _dbService.UpdateContactAddress(address);
     }
     return(Json(address));
 }
예제 #5
0
        /// <summary>
        /// Utility method to convert address information from the vCard library to a
        /// WinRT ContactAddress instance.
        /// No 1:1 matching is possible between both classes, the method tries to
        /// keep the conversion as accurate as possible.
        /// </summary>
        /// <param name="address">Address information from the vCard library.</param>
        /// <returns>The address information from the vCard library converted to a
        /// WinRT ContactAddress instance.</returns>
        private ContactAddress ConvertVcardToAddress(vCardDeliveryAddress address)
        {
            var ca = new ContactAddress
            {
                Country       = address.Country,
                PostalCode    = address.PostalCode,
                Region        = address.Region,
                StreetAddress = address.Street,
                Locality      = address.City,
                Kind          = ConvertVcardToAddressType(address.AddressType)
            };

            return(ca);
        }
예제 #6
0
 public async Task <Client> AddClient(NewClient addClient)
 {
     return(await Task.Run(() =>
     {
         var newClientAddress = new ContactAddress {
             Id = "A" + _clientList.Count + 1, AddressLine1 = addClient.AddressLine1, AddressLine2 = addClient.AddressLine2, Suburb = addClient.Suburb, State = addClient.State, PostCode = addClient.PostCode, Country = addClient.Country
         };
         var newClient = new Client {
             Id = "C" + _clientList.Count + 1, Name = addClient.Name, ContactNumber = addClient.ContactNumber, Email = addClient.Email, BillingAddress = newClientAddress
         };
         _clientList.Add(newClient);
         return newClient;
     }));
 }
예제 #7
0
        private void BtnWriteBusinessCard_Click(object sender, RoutedEventArgs e)
        {
            var contact = new Contact
            {
                FirstName = "Andreas",
                LastName  = "Jakl"
            };
            // Add the personal email address to the Contact object’s emails vector
            var personalEmail = new ContactEmail {
                Address = "*****@*****.**", Kind = ContactEmailKind.Work
            };

            contact.Emails.Add(personalEmail);

            // Adds the home phone number to the Contact object’s phones vector
            var homePhone = new ContactPhone {
                Number = "+1234", Kind = ContactPhoneKind.Home
            };

            contact.Phones.Add(homePhone);

            // Adds the address to the Contact object’s addresses vector
            var workAddress = new ContactAddress
            {
                StreetAddress = "Street 1",
                Locality      = "Vienna",
                Region        = "Austria",
                PostalCode    = "1234",
                Kind          = ContactAddressKind.Work
            };

            contact.Addresses.Add(workAddress);

            contact.Websites.Add(new ContactWebsite {
                Uri = new Uri("http://www.nfcinteractor.com/")
            });

            contact.JobInfo.Add(new ContactJobInfo
            {
                CompanyName = "Andreas Jakl",
                Title       = "Mobility Evangelist"
            });
            contact.Notes = "Developer of the NFC Library";

            var record = new NdefVcardRecord(contact);

            // Publish the record using the proximity device
            PublishRecord(record, true);
        }
예제 #8
0
파일: LinkMan.cs 프로젝트: xuanximoming/key
 /// <summary>
 /// 初始化所有的属性,包括引用类型的属性自己的属性
 /// </summary>
 public override void ReInitializeAllProperties()
 {
     if (Relation != null)
     {
         Relation.ReInitializeAllProperties();
     }
     if (ContactAddress != null)
     {
         ContactAddress.ReInitializeAllProperties();
     }
     if (ContactDepartment != null)
     {
         ContactDepartment.ReInitializeAllProperties();
     }
 }
        public static ContactAddress ToContactAddress(this NGAddress address)
        {
            var winAddress = new ContactAddress()
            {
                Kind          = (ContactAddressKind)address.Kind,
                StreetAddress = address.Street,
                Locality      = address.Locality,
                Region        = address.Region,
                Country       = address.Country,
                PostalCode    = address.PostalCode,
                Description   = address.Description
            };

            return(winAddress);
        }
        public static NGAddress ToNGAddress(this ContactAddress address)
        {
            var ngAddress = new NGAddress()
            {
                Kind        = (NGAddressKind)address.Kind,
                Street      = address.StreetAddress,
                Locality    = address.Locality,
                Region      = address.Region,
                Country     = address.Country,
                PostalCode  = address.PostalCode,
                Description = address.Description
            };

            return(ngAddress);
        }
        internal static void AssertEqual(this ContactAddress contactAddress, IContactAddressReturn contactAddressReturn)
        {
            if (contactAddress == null)
            {
                throw new ArgumentNullException("contactAddress");
            }
            if (contactAddressReturn == null)
            {
                throw new ArgumentNullException("contactAddressReturn");
            }

            Assert.AreEqual(new ContactAddressKey(contactAddress).KeyValue, contactAddressReturn.ContactAddressKey);
            Assert.AreEqual(contactAddress.AddressDescription, contactAddressReturn.AddressDescription);
            contactAddress.Address.AssertEqual(contactAddressReturn.Address);
        }
        /// <summary>
        /// Adds an address to the contact
        /// </summary>
        /// <param name="contactAddress">Contact Address Object</param>
        /// <returns>String Success/Failure with respective Error</returns>
        public string AddAddress(ContactAddress contactAddress)
        {
            string result = string.Empty;

            try
            {
                _contactValidation.ValidateContactAddress(contactAddress);
                result = _iContactDAL.AddAddress(contactAddress);
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
예제 #13
0
        public void AddressValueObjectIsAssignableToContact()
        {
            var address = new ContactAddress
            {
                City    = "New York",
                Street1 = "890 Fifth Avenue",
                Street2 = "Borough of Manhattan",
                State   = "New York",
                Country = "United States",
                ZipCode = "10002"
            };

            _addressFixture.Contact.Address = address;

            _addressFixture.Contact.Address.City.ShouldBe("New York");
        }
        internal static ContactAddress SetCompany(this ContactAddress contactAddress, ICompanyKey companyKey)
        {
            if (contactAddress == null)
            {
                throw new ArgumentNullException("contactAddress");
            }

            contactAddress.CompanyId = companyKey.CompanyKey_Id;

            if (contactAddress.Contact != null)
            {
                contactAddress.Contact.ConstrainByKeys(companyKey);
            }

            return(contactAddress);
        }
예제 #15
0
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        txtError.Text = string.Empty;
        try
        {
            if (validateValues())
            {
                ContactInfo contactinfo = new ContactInfo();
                contactinfo.Title     = txtCbTitle.SelectedValue;
                contactinfo.FirstName = txtFirstName.Text;
                contactinfo.LastName  = txtLastName.Text;
                contactinfo.Email     = txtEmail.Text;
                contactinfo.Telephone = txtTelephone.Text;
                contactinfo.Mobile    = txtMobile.Text;
                contactinfo.CreatedOn = DateTime.Now;
                UserLogin userlogin = new UserLogin();
                userlogin.Username      = txtEmail.Text;
                userlogin.Password      = txtPassword.Text;
                userlogin.CreatedOn     = DateTime.Now;
                userlogin.Enable        = true;
                userlogin.UserLoginType = entities.UserLoginTypes.Where(ul => ul.LoginTypeName.ToLower().Equals("user")).FirstOrDefault();
                ContactAddress contactaddress = new ContactAddress();
                contactaddress.Address     = txtAddress.Text;
                contactaddress.City        = txtCity.Text;
                contactaddress.Zip         = txtZipCode.Text;
                contactaddress.State       = txtState.Text;
                contactaddress.Country     = txtCbCountry.SelectedValue;
                contactaddress.CreatedOn   = DateTime.Now;
                contactaddress.AddressType = entities.AddressTypes.Where(at => at.AddressTypeName.ToLower().Equals("billing")).FirstOrDefault();
                contactinfo.ContactAddresses.Add(contactaddress);
                contactinfo.UserLogins.Add(userlogin);

                using (TransactionScope transaction = new TransactionScope())
                {
                    entities.ContactInfoes.Add(contactinfo);
                    entities.SaveChanges();
                    transaction.Complete();
                    SessionMessage = "Your account has been created successfully. You can login now to order.";
                    Response.Redirect("~/Confirmation.aspx");
                }
            }
        }
        catch (Exception ex)
        {
            txtError.Text = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message;
        }
    }
예제 #16
0
        private async Task <Contact> DownloadContactDataAsync(Contact contact)
        {
            // Simulate the download latency by delaying the execution by 2 seconds.
            await Task.Delay(2000);

            if (!DownloadSucceeded.IsChecked.Value)
            {
                return(null);
            }

            // Add more data to the contact object.
            ContactEmail workEmail = new ContactEmail();

            workEmail.Address = "*****@*****.**";
            workEmail.Kind    = ContactEmailKind.Work;
            contact.Emails.Add(workEmail);

            ContactPhone homePhone = new ContactPhone();

            homePhone.Number = "(444) 555-0101";
            homePhone.Kind   = ContactPhoneKind.Home;
            contact.Phones.Add(homePhone);

            ContactPhone workPhone = new ContactPhone();

            workPhone.Number = "(245) 555-0123";
            workPhone.Kind   = ContactPhoneKind.Work;
            contact.Phones.Add(workPhone);

            ContactPhone mobilePhone = new ContactPhone();

            mobilePhone.Number = "(921) 555-0187";
            mobilePhone.Kind   = ContactPhoneKind.Mobile;
            contact.Phones.Add(mobilePhone);

            ContactAddress address = new ContactAddress();

            address.StreetAddress = "123 Main St";
            address.Locality      = "Redmond";
            address.Region        = "WA";
            address.Country       = "USA";
            address.PostalCode    = "00000";
            address.Kind          = ContactAddressKind.Home;
            contact.Addresses.Add(address);

            return(contact);
        }
        internal static ContactAddress SetContact(this ContactAddress address, IContactKey contactKey)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (contactKey == null)
            {
                throw new ArgumentNullException("contactKey");
            }

            address.Contact   = null;
            address.CompanyId = contactKey.CompanyKey_Id;
            address.ContactId = contactKey.ContactKey_Id;

            return(address);
        }
예제 #18
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 8, Configuration.FieldSeparator),
                       Id,
                       ContactRole != null ? string.Join(Configuration.FieldRepeatSeparator, ContactRole.Select(x => x.ToDelimitedString())) : null,
                       ContactName != null ? string.Join(Configuration.FieldRepeatSeparator, ContactName.Select(x => x.ToDelimitedString())) : null,
                       ContactAddress?.ToDelimitedString(),
                       ContactLocation?.ToDelimitedString(),
                       ContactCommunicationInformation != null ? string.Join(Configuration.FieldRepeatSeparator, ContactCommunicationInformation.Select(x => x.ToDelimitedString())) : null,
                       PreferredMethodOfContact?.ToDelimitedString(),
                       ContactIdentifiers != null ? string.Join(Configuration.FieldRepeatSeparator, ContactIdentifiers) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
예제 #19
0
        private XElement GetAddressElement(ContactAddress address)
        {
            var addressElement = new XElement("address", new XAttribute("type", address.Type.ToString().ToLower()));

            if (address.StreetLines != null && address.StreetLines.Any())
            {
                if (address.StreetLines.Count > 5)
                {
                    throw new AdfException("A contact address must not have more than 5 street lines.");
                }

                var lineNumber = 1;
                foreach (var line in address.StreetLines)
                {
                    addressElement.Add(new XElement("street", line, new XAttribute("line", lineNumber)));
                    lineNumber++;
                }
            }

            if (!string.IsNullOrEmpty(address.Apartment))
            {
                addressElement.Add(new XElement("apartment", address.Apartment));
            }

            if (!string.IsNullOrEmpty(address.City))
            {
                addressElement.Add(new XElement("city", address.City));
            }

            if (!string.IsNullOrEmpty(address.RegionCode))
            {
                addressElement.Add(new XElement("regioncode", address.RegionCode));
            }

            if (!string.IsNullOrEmpty(address.PostalCode))
            {
                addressElement.Add(new XElement("postalcode", address.PostalCode));
            }

            if (!string.IsNullOrEmpty(address.Country))
            {
                addressElement.Add(new XElement("country", address.Country));
            }

            return(addressElement);
        }
        public async Task UpdateAddress(int ukprn, ContactAddress address, double lat, double lon)
        {
            var providerRegistrationImport = await _dataContext
                                             .ProviderRegistrationImports
                                             .SingleOrDefaultAsync(c => c.Ukprn.Equals(ukprn));

            providerRegistrationImport.Lat      = lat;
            providerRegistrationImport.Long     = lon;
            providerRegistrationImport.Address1 = address.Address1;
            providerRegistrationImport.Address2 = address.Address2;
            providerRegistrationImport.Address3 = address.Address3;
            providerRegistrationImport.Address4 = address.Address4;
            providerRegistrationImport.Town     = address.Town;
            providerRegistrationImport.Postcode = address.PostCode;

            _dataContext.SaveChanges();
        }
예제 #21
0
        public Guid UpsertContactAddress(ContactAddress address)
        {
            var original = _fakeObjectGenerator.ContactAddresses.FirstOrDefault(add => add.Id == address.Id);

            if (original != null)
            {
                _fakeObjectGenerator.ContactAddresses.Remove(original);
                _fakeObjectGenerator.ContactAddresses.Add(address);

                return(address.Id);
            }

            address.Id = _fakeObjectGenerator.GetNewGuid();
            _fakeObjectGenerator.ContactAddresses.Add(address);

            return(address.Id);
        }
예제 #22
0
        public ContactInformation(XElement node, string @namespace)
        {
            var element = node.Element(XName.Get("ContactPersonPrimary", @namespace));
            if (element != null) ContactPersonPrimary = new ContactPersonPrimary(element, @namespace);

            element = node.Element(XName.Get("ContactPosition", @namespace));
            if (element != null) ContactPosition = element.Value;

            element = node.Element(XName.Get("ContactAddress", @namespace));
            if (element != null) ContactAddress = new ContactAddress(element, @namespace);

            element = node.Element(XName.Get("ContactVoiceTelephone", @namespace));
            if (element != null) ContactVoiceTelephone = element.Value;
            element = node.Element(XName.Get("ContactFacsimileTelephone", @namespace));
            if (element != null) ContactFacsimileTelephone = element.Value;
            element = node.Element(XName.Get("ContactElectronicMailAddress", @namespace));
            if (element != null) ContactElectronicMailAddress = element.Value;
        }
예제 #23
0
        public async Task <IActionResult> AddressEdit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ContactAddress contactAddress = await _context.ContactAddresses
                                            .Include(ca => ca.ContactPerson)
                                            .SingleAsync(ca => ca.Id == id);

            if (contactAddress == null)
            {
                return(NotFound());
            }

            return(View(contactAddress));
        }
예제 #24
0
        // GET: EthBook
        public async Task <ActionResult> Index()
        {
            ContractService  contractService = GetContactService();
            long             myBookCount     = -1;
            EthBookViewModel vm = new EthBookViewModel();

            if (User.Identity.IsAuthenticated)
            {
                var user = UserManager.FindById(User.Identity.GetUserId());

                myBookCount = Sync(contractService.GetMyBookCount(user.Address));

                vm.ContactAddresses = new List <ContactAddress>();
                for (int i = 0; i < myBookCount; i++)
                {
                    ContactAddress ca = await contractService.GetContact(i, user.Address);

                    vm.ContactAddresses.Add(ca);
                }

                vm.UserUnlocked = user.Unlocked.HasValue ? user.Unlocked.Value : false;
                if (!user.Unlocked.HasValue || (user.Unlocked.HasValue && !user.Unlocked.Value))
                {
                    if (contractService != null)
                    {
                        Task <bool> task     = contractService.IsUnlocked(user.Address);
                        bool        unlocked = Sync(task);
                        if (unlocked)
                        {
                            user.Unlocked   = true;
                            vm.UserUnlocked = true;
                            await UserManager.UpdateAsync(user);
                        }
                    }
                }

                vm.RefLink = user.RefLink;
                vm.Init    = user.Init.HasValue ? user.Init.Value : false;
            }

            return(View(vm));
        }
        private async Task<Contact> DownloadContactDataAsync(Contact contact)
        {
            // Simulate the download latency by delaying the execution by 2 seconds.
            await Task.Delay(2000);

            if (!DownloadSucceeded.IsChecked.Value)
            {
                return null;
            }

            // Add more data to the contact object.
            ContactEmail workEmail = new ContactEmail();
            workEmail.Address = "*****@*****.**";
            workEmail.Kind = ContactEmailKind.Work;
            contact.Emails.Add(workEmail);

            ContactPhone homePhone = new ContactPhone();
            homePhone.Number = "(444) 555-0101";
            homePhone.Kind = ContactPhoneKind.Home;
            contact.Phones.Add(homePhone);

            ContactPhone workPhone = new ContactPhone();
            workPhone.Number = "(245) 555-0123";
            workPhone.Kind = ContactPhoneKind.Work;
            contact.Phones.Add(workPhone);

            ContactPhone mobilePhone = new ContactPhone();
            mobilePhone.Number = "(921) 555-0187";
            mobilePhone.Kind = ContactPhoneKind.Mobile;
            contact.Phones.Add(mobilePhone);

            ContactAddress address = new ContactAddress();
            address.StreetAddress = "123 Main St";
            address.Locality = "Redmond";
            address.Region = "WA";
            address.Country = "USA";
            address.PostalCode = "00000";
            address.Kind = ContactAddressKind.Home;
            contact.Addresses.Add(address);

            return contact;
        }
예제 #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SessionUser != null)
     {
         BusinessObjects.ContactInfo contactinfo = (from C in entities.ContactInfoes
                                                    where C.ContactInfoId == SessionUser.ContactInfoId
                                                    select C).FirstOrDefault();
         txtFirstName.Text = contactinfo.FirstName;
         txtLastName.Text  = contactinfo.LastName;
         txtEmail.Text     = contactinfo.Email;
         txtTelephone.Text = contactinfo.Telephone;
         txtMobile.Text    = contactinfo.Mobile;
         ContactAddress address = contactinfo.ContactAddresses.Where(c => c.AddressType.AddressTypeName.ToLower().Equals("billing")).FirstOrDefault();
         txtAddress.Text            = address.Address;
         txtCity.Text               = address.City;
         txtZipCode.Text            = address.Zip;
         txtState.Text              = address.State;
         ViewState["ContactInfoId"] = contactinfo.ContactInfoId;
     }
 }
예제 #27
0
        /// <summary>
        /// Sets the full address of the contact
        /// </summary>
        /// <param name="nType">AddressType to specify which address to set</param>
        /// <returns>true on success</returns>
        public bool SetAddress(ContactAddress address, AddressType nType)
        {
            IntPtr pAddress;

            if (!ContactGetAddress(pObject, out pAddress, (int)nType))
            {
                return(false);
            }

            AddressSetStreet(pAddress, address.Street);
            AddressSetCity(pAddress, address.City);
            AddressSetStateOrProvince(pAddress, address.StateOrProvince);
            AddressSetPostalCode(pAddress, address.PostalCode);
            AddressSetCountry(pAddress, address.Country);

            bool bResult = ContactSetAddress(pObject, pAddress, (int)nType);

            AddressClose(pAddress);
            return(bResult);
        }
예제 #28
0
        public void Save(ContactAddress model)
        {
            var now = DateTime.Now;

            if (model.ContactAddressId != 0)
            {
                model.UpgradeDate         = now;
                model.Address.UpgradeDate = now;
                _context.ContactAddress.Update(model);
            }
            else
            {
                model.CreationDate         = now;
                model.Address.CreationDate = now;
                model.Address.StatusId     = StatusValues.Activo;
                model.StatusId             = StatusValues.Activo;
                _context.Add(model);
            }

            _context.SaveChanges();
        }
예제 #29
0
        public async Task <bool> AddAddress(AddAddressToContactDto dto)
        {
            using (var dbTran = _db.Database.BeginTransaction())
            {
                try
                {
                    var contact = _db.Contact.First(x => x.Id == dto.ContactId);

                    var address = new Address()
                    {
                        City     = dto.City,
                        PostCode = dto.PostCode,
                        Country  = dto.Country,
                        Line1    = dto.Line1,
                        Line2    = dto.Line2,
                        Line3    = dto.Line3,
                    };
                    _db.Address.Add(address);

                    var rel = new ContactAddress()
                    {
                        Address     = address,
                        Contact     = contact,
                        AddressType = dto.AddressType
                    };
                    _db.Set <ContactAddress>().Add(rel);

                    await _db.SaveChangesAsync();

                    dbTran.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    dbTran.Rollback();
                    //log exception
                    return(false);
                }
            }
        }
        /// <summary>
        /// Get Contact By ZipCode
        /// </summary>
        /// <returns>List of Contact Object</returns>
        public List <Contact> GetContactByZipCode(string zipCode)
        {
            List <Contact> contacts = new List <Contact>();

            if (zipCode == string.Empty)
            {
                return(null);
            }
            else
            {
                Guid addressID = Guid.NewGuid();
                Guid contactID = Guid.NewGuid();

                ContactAddress address = new ContactAddress(addressID,
                                                            contactID,
                                                            "Clive Lloyd Road",
                                                            "",
                                                            "NJ",
                                                            "12345",
                                                            DateTime.Now,
                                                            DateTime.Now);

                var addressList = new List <ContactAddress>();

                Contact contact = new Contact(contactID,
                                              ContactType.Business,
                                              "",
                                              "",
                                              "Business Name",
                                              DateTime.Now,
                                              DateTime.Now,
                                              addressList);
                contacts.Add(contact);
            }

            return(contacts);
        }
예제 #31
0
        private void myradwizard_Next(object sender, NavigationButtonsEventArgs e)
        {
            if (this.myradwizard.SelectedPage == Page0) // Check if this is the desired page
            {
                if (LastName.Text == "")
                {
                    errormessage.Text = "Last Name cannot be empty";
                    LastName.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (FirstName.Text == "")
                {
                    errormessage.Text = "First Name cannot be empty";
                    FirstName.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (CityName.SelectedValue == null || PermanentCityName.SelectedValue == null)
                {
                    errormessage.Text        = "Please complete address";
                    myradwizard.SelectedPage = Page1;
                }
                else if (ContactPerson.Text == "")
                {
                    errormessage.Text = "Contact Person cannot be empty";
                    ContactPerson.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (ContactPhone.Text == "")
                {
                    errormessage.Text = "Contact Phone cannot be empty";
                    ContactPhone.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (ContactAddress.Text == "")
                {
                    errormessage.Text = "Contact Address cannot be empty";
                    ContactAddress.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (BirthDate.DateTimeText == "")
                {
                    errormessage.Text = "BirthDay cannot be empty";
                    BirthDate.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (CivilStatus.SelectedValue == null)
                {
                    errormessage.Text = "Please select Civil Status";
                    CivilStatus.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (Nationality.SelectedValue == null)
                {
                    errormessage.Text = "Please select Nationality";
                    Nationality.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (Religion.SelectedValue == null)
                {
                    errormessage.Text = "Please select Religion";
                    Religion.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (Sex.SelectedValue == null)
                {
                    errormessage.Text = "Please select Gender";
                    Sex.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (HireDate.DateTimeText == "")
                {
                    errormessage.Text = "Please select Hire Date";
                    HireDate.Focus();
                    myradwizard.SelectedPage = Page1;
                }

                else if (Department.SelectedValue == null)
                {
                    errormessage.Text = "Please select Department";
                    Department.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (Section.SelectedValue == null)
                {
                    errormessage.Text = "Please select Section";
                    Section.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (Position.SelectedValue == null)
                {
                    errormessage.Text = "Please select Position";
                    Position.Focus();
                    myradwizard.SelectedPage = Page1;
                }
                else if (EmploymentStatus.SelectedValue == null)
                {
                    errormessage.Text = "Please select Employee Status";
                    EmploymentStatus.Focus();
                    myradwizard.SelectedPage = Page1;
                }

                if (EmailAddress.Text.Length == 0)
                {
                }
                else
                {
                    if (!Regex.IsMatch(EmailAddress.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
                    {
                        errormessage.Text = "Please enter a valid email.";
                        EmailAddress.Select(0, EmailAddress.Text.Length);
                        EmailAddress.Focus();
                        myradwizard.SelectedPage = Page1;
                    }
                    else
                    {
                    }
                }
            }
        }
예제 #32
0
        /// <summary>
        /// Sets the full address of the contact
        /// </summary>
        /// <param name="nType">AddressType to specify which address to set</param>
        /// <returns>true on success</returns>
        public bool SetAddress(ContactAddress address, AddressType nType)
        {
            IntPtr pAddress;
            if (!ContactGetAddress(pObject, out pAddress, (int)nType)) return false;

            AddressSetStreet(pAddress, address.Street);
            AddressSetCity(pAddress, address.City);
            AddressSetStateOrProvince(pAddress, address.StateOrProvince);
            AddressSetPostalCode(pAddress, address.PostalCode);
            AddressSetCountry(pAddress, address.Country);

            bool bResult = ContactSetAddress(pObject, pAddress, (int)nType);
            AddressClose(pAddress);
            return bResult;
        }
예제 #33
0
        /// <summary>
        /// Gets the full address of the contact
        /// </summary>
        /// <param name="nType">AddressType to specify which address to retrieve</param>
        /// <returns>true on success</returns>
        public bool GetAddress(out ContactAddress address, AddressType nType)
        {
            IntPtr pAddress;
            if (ContactGetAddress(pObject, out pAddress, (int)nType))
            {
                address = new ContactAddress();
                address.Type = nType;

                StringBuilder s = new StringBuilder(NetMAPI.DefaultBufferSize);
                AddressGetStreet(pAddress, s, s.Capacity);
                address.Street = s.ToString();
                AddressGetCity(pAddress, s, s.Capacity);
                address.City = s.ToString();
                AddressGetStateOrProvince(pAddress, s, s.Capacity);
                address.StateOrProvince = s.ToString();
                AddressGetPostalCode(pAddress, s, s.Capacity);
                address.PostalCode = s.ToString();
                AddressGetCountry(pAddress, s, s.Capacity);
                address.Country = s.ToString();

                AddressClose(pAddress);
                return true;
            }

            address = null;
            return false;
        }
예제 #34
0
        private void BtnWriteBusinessCard_Click(object sender, RoutedEventArgs e)
        {
            var contact = new Contact
            {
                FirstName = "Andreas",
                LastName = "Jakl"
            };
            // Add the personal email address to the Contact object’s emails vector
            var personalEmail = new ContactEmail { Address = "*****@*****.**", Kind = ContactEmailKind.Work };
            contact.Emails.Add(personalEmail);

            // Adds the home phone number to the Contact object’s phones vector
            var homePhone = new ContactPhone { Number = "+1234", Kind = ContactPhoneKind.Home };
            contact.Phones.Add(homePhone);

            // Adds the address to the Contact object’s addresses vector
            var workAddress = new ContactAddress
            {
                StreetAddress = "Street 1",
                Locality = "Vienna",
                Region = "Austria",
                PostalCode = "1234",
                Kind = ContactAddressKind.Work
            };
            contact.Addresses.Add(workAddress);

            contact.Websites.Add(new ContactWebsite { Uri = new Uri("http://www.nfcinteractor.com/") });

            contact.JobInfo.Add(new ContactJobInfo
            {
                CompanyName = "Andreas Jakl",
                Title = "Mobility Evangelist"
            });
            contact.Notes = "Developer of the NFC Library";

            //var record = new NdefVcardRecord(contact);

            //// Publish the record using the proximity device
            //PublishRecord(record, true);
        }
예제 #35
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 13, Configuration.FieldSeparator),
                       Id,
                       FacilityIdFac?.ToDelimitedString(),
                       FacilityType,
                       FacilityAddress != null ? string.Join(Configuration.FieldRepeatSeparator, FacilityAddress.Select(x => x.ToDelimitedString())) : null,
                       FacilityTelecommunication?.ToDelimitedString(),
                       ContactPerson != null ? string.Join(Configuration.FieldRepeatSeparator, ContactPerson.Select(x => x.ToDelimitedString())) : null,
                       ContactTitle != null ? string.Join(Configuration.FieldRepeatSeparator, ContactTitle) : null,
                       ContactAddress != null ? string.Join(Configuration.FieldRepeatSeparator, ContactAddress.Select(x => x.ToDelimitedString())) : null,
                       ContactTelecommunication != null ? string.Join(Configuration.FieldRepeatSeparator, ContactTelecommunication.Select(x => x.ToDelimitedString())) : null,
                       SignatureAuthority != null ? string.Join(Configuration.FieldRepeatSeparator, SignatureAuthority.Select(x => x.ToDelimitedString())) : null,
                       SignatureAuthorityTitle,
                       SignatureAuthorityAddress != null ? string.Join(Configuration.FieldRepeatSeparator, SignatureAuthorityAddress.Select(x => x.ToDelimitedString())) : null,
                       SignatureAuthorityTelecommunication?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
예제 #36
0
파일: Investor.cs 프로젝트: jsingh/DeepBlue
        public static List<DeepBlue.Models.Entity.Investor> ConvertBlueToDeepBlue()
        {
            Errors = new List<KeyValuePair<C7_20tblLPPaymentInstructions, Exception>>();
            TotalConversionRecords = 0;
            RecordsConvertedSuccessfully = 0;
            List<DeepBlue.Models.Entity.Investor> dbInvestors = new List<DeepBlue.Models.Entity.Investor>();
            using (BlueEntities context = new BlueEntities()) {
                List<C7_20tblLPPaymentInstructions> investors = context.C7_20tblLPPaymentInstructions.ToList();
                foreach (C7_20tblLPPaymentInstructions investor in investors) {
                    try {
                        TotalConversionRecords++;
                        DeepBlue.Models.Entity.Investor deepBlueInvestor = GetInvestorFromBlue(investor);
                        #region Investor Account
                        // Blue has only 1 account for 1 investor
                        InvestorAccount account = new InvestorAccount();
                        if (!string.IsNullOrEmpty(investor.ABANumber)) {
                            account.Routing = Convert.ToInt32(investor.ABANumber.Trim().Replace(" ", string.Empty).Replace("-", string.Empty));
                        }
                        if (!string.IsNullOrEmpty(investor.AccountNumber)) {
                            account.Account = investor.AccountNumber;
                        }
                        else {
                            account.Account = Globals.DefaultStringValue;
                        }
                        account.AccountOf = investor.Accountof;
                        account.Attention = investor.Attn;
                        account.BankName = investor.Bank;
                        account.Reference = investor.Reference;
                        account.CreatedBy = Globals.CurrentUser.UserID;
                        account.CreatedDate = DateTime.Now;
                        account.EntityID = Globals.DefaultEntityID;
                        account.IsPrimary = false;
                        account.LastUpdatedBy = Globals.CurrentUser.UserID;
                        account.LastUpdatedDate = DateTime.Now;
                        // WARNING: The following values are present in our database, but not present in Blue, so setting those to NULL
                        // FFC
                        // FFCNO
                        // IBAN
                        // ByOrderOf
                        // Swift
                        #endregion
                        deepBlueInvestor.InvestorAccounts.Add(account);

                        #region Contact Info
                        foreach (C7_25LPContactinfo contactInfo in investor.C7_25LPContactinfo) {
                            InvestorContact investorContact = new InvestorContact();
                            investorContact.CreatedBy = Globals.CurrentUser.UserID;
                            investorContact.CreatedDate = DateTime.Now;
                            investorContact.EntityID = Globals.DefaultEntityID;
                            investorContact.LastUpdatedBy = Globals.CurrentUser.UserID;
                            investorContact.LastUpdatedDate = DateTime.Now;
                            Contact contact = new Contact();
                            contact.ContactCompany = contactInfo.ContactCompany;
                            contact.ContactName = contactInfo.ContactName;
                            // WARNING: Deepblue has consolidated CallNotices/Distribution notices into one field.
                            if (contactInfo.DistributionNotices != null) {
                                contact.ReceivesDistributionNotices = contactInfo.DistributionNotices.Value;
                            }
                            if (contactInfo.Financials != null) {
                                contact.ReceivesFinancials = contactInfo.Financials.Value;
                            }
                            if (contactInfo.InvestorLetters != null) {
                                contact.ReceivesInvestorLetters = contactInfo.InvestorLetters.Value;
                            }
                            contact.CreatedBy = Globals.CurrentUser.UserID;
                            contact.CreatedDate = DateTime.Now;
                            contact.FirstName = contactInfo.ContactName;
                            contact.LastName = "n/a";
                            contact.LastUpdatedBy = Globals.CurrentUser.UserID;
                            contact.LastUpdatedDate = DateTime.Now;
                            contact.EntityID = Globals.DefaultEntityID;
                            investorContact.Contact = contact;

                            // WARNING: We dont have the following values in our database
                            // contactInfo.Dear; // This seems to be the first name from Contact Name
                            Address contactAddress = new Address();
                            if (contactInfo.ContactAddress != null) {
                                if (contactInfo.ContactAddress.Length > 40) {
                                    contactAddress.Address1 = contactInfo.ContactAddress.Substring(0, 40);
                                } else {
                                    contactAddress.Address1 = contactInfo.ContactAddress;
                                }
                            }
                            else {
                                contactAddress.Address1 = Globals.DefaultStringValue;
                            }
                            //contactInfo.Comments;
                            contactAddress.Address2 = contactInfo.ContactAddress2;
                            // Contact Info(Access) doesnt have the values for these properties, so using default values
                            contactAddress.Country = Globals.DefaultCountryID;
                            contactAddress.City = Globals.DefaultCity;
                            contactAddress.State = Globals.DefaultStateID;
                            contactAddress.PostalCode = Globals.DefaultZip;
                            try {
                                string[] parts = new string[3];
                                if (ParseAddress(contactInfo.ContactAddress2, out parts)) {
                                    contactAddress.City = parts[0];
                                    contactAddress.PostalCode = parts[2];
                                    int postalCode = 0;
                                    bool validZip = true;
                                    if (Int32.TryParse(contactAddress.PostalCode, out postalCode)) {
                                        if (contactAddress.PostalCode.Length > 5) {
                                            validZip = false;
                                        }
                                    } else {
                                        validZip = false;
                                    }
                                    if (!validZip) {
                                        contactAddress.PostalCode = Globals.DefaultZip;
                                    }
                                    contactAddress.State = Globals.States.Where(x => x.Abbr == parts[1].ToUpper().Trim()).First().StateID;
                                }
                                else {
                                    contactAddress.City = "dataerror: " + contactInfo.ContactAddress2;
                                }
                            }
                            catch {

                            }

                            AddCommunication(contact, Models.Admin.Enums.CommunicationType.Email, contactInfo.ContactEmail);
                            AddCommunication(contact, Models.Admin.Enums.CommunicationType.HomePhone, contactInfo.ContactPhone);
                            AddCommunication(contact, Models.Admin.Enums.CommunicationType.Fax, contactInfo.ContactFax);
                            contactAddress.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work;
                            contactAddress.CreatedBy = Globals.CurrentUser.UserID;
                            contactAddress.CreatedDate = DateTime.Now;
                            contactAddress.EntityID = Globals.DefaultEntityID;
                            contactAddress.LastUpdatedBy = Globals.CurrentUser.UserID;
                            contactAddress.LastUpdatedDate = DateTime.Now;

                            ContactAddress cntAddr = new ContactAddress();
                            cntAddr.CreatedBy = Globals.CurrentUser.UserID;
                            cntAddr.CreatedDate = DateTime.Now;
                            cntAddr.EntityID = Globals.DefaultEntityID;
                            cntAddr.LastUpdatedBy = Globals.CurrentUser.UserID;
                            cntAddr.LastUpdatedDate = DateTime.Now;
                            cntAddr.Address = contactAddress;

                            investorContact.Contact.ContactAddresses.Add(cntAddr);
                            deepBlueInvestor.InvestorContacts.Add(investorContact);
                        }
                        #endregion
                        dbInvestors.Add(deepBlueInvestor);
                        RecordsConvertedSuccessfully++;
                    }
                    catch (Exception ex) {
                        Errors.Add(new KeyValuePair<C7_20tblLPPaymentInstructions, Exception>(investor, ex));
                    }
                }
            }
            return dbInvestors;
        }
예제 #37
0
        public ActionResult ImportInvestorContactExcel(FormCollection collection)
        {
            ImportInvestorContactExcelModel model = new ImportInvestorContactExcelModel();
            ResultModel resultModel = new ResultModel();
            MemoryCacheManager cacheManager = new MemoryCacheManager();
            int totalPages = 0;
            int totalRows = 0;
            int completedRows = 0;
            int? succssRows = 0;
            int? errorRows = 0;
            this.TryUpdateModel(model);
            if (ModelState.IsValid) {
                string key = string.Format(EXCELINVESTORCONTACTERROR_BY_KEY, model.SessionKey);
                List<DeepBlue.Models.Deal.ImportExcelError> errors = cacheManager.Get(key, () => {
                    return new List<DeepBlue.Models.Deal.ImportExcelError>();
                });
                DataSet ds = ExcelConnection.ImportExcelDataset(model.SessionKey);
                if (ds != null) {
                    PagingDataTable importExcelTable = null;
                    if (ds.Tables[model.InvestorContactTableName] != null) {
                        importExcelTable = (PagingDataTable)ds.Tables[model.InvestorContactTableName];
                    }
                    if (importExcelTable != null) {
                        importExcelTable.PageSize = model.PageSize;
                        PagingDataTable table = importExcelTable.Skip(model.PageIndex);
                        totalPages = importExcelTable.TotalPages;
                        totalRows = importExcelTable.TotalRows;
                        if (totalPages > model.PageIndex) {
                            completedRows = (model.PageIndex * importExcelTable.PageSize);
                        }
                        else {
                            completedRows = totalRows;
                        }

                        int rowNumber = 0;

                        string investorName = string.Empty;
                        string contactPerson = string.Empty;
                        string designation = string.Empty;
                        string telephone = string.Empty;
                        string fax = string.Empty;
                        string email = string.Empty;
                        string webAddress = string.Empty;
                        string address = string.Empty;
                        string city = string.Empty;
                        string stateName = string.Empty;
                        string zip = string.Empty;
                        string countryName = string.Empty;
                        bool receivesDistributionCapitalCallNotices = false;
                        bool financials = false;
                        bool k1 = false;
                        bool investorLetters = false;

                        COUNTRY country = null;
                        STATE state = null;

                        DeepBlue.Models.Deal.ImportExcelError error;

                        DeepBlue.Models.Entity.Investor investor;
                        EmailAttribute emailValidation = new EmailAttribute();
                        ZipAttribute zipAttribute = new ZipAttribute();
                        WebAddressAttribute webAttribute = new WebAddressAttribute();
                        IEnumerable<ErrorInfo> errorInfo;

                        StringBuilder rowErrors;
                        foreach (DataRow row in table.Rows) {
                            int.TryParse(row.GetValue("RowNumber"), out rowNumber);

                            error = new DeepBlue.Models.Deal.ImportExcelError { RowNumber = rowNumber };
                            rowErrors = new StringBuilder();

                            investorName = row.GetValue(model.InvestorName);
                            contactPerson = row.GetValue(model.ContactPerson);
                            designation = row.GetValue(model.Designation);
                            telephone = row.GetValue(model.Telephone);
                            fax = row.GetValue(model.Fax);
                            email = row.GetValue(model.Email);
                            webAddress = row.GetValue(model.WebAddress);
                            address = row.GetValue(model.Address);
                            city = row.GetValue(model.City);
                            stateName = row.GetValue(model.State);
                            zip = row.GetValue(model.Zip);
                            countryName = row.GetValue(model.Country);
                            bool.TryParse(row.GetValue(model.ReceivesDistributionCapitalCallNotices), out receivesDistributionCapitalCallNotices);
                            bool.TryParse(row.GetValue(model.Financials), out financials);
                            bool.TryParse(row.GetValue(model.InvestorLetters), out investorLetters);
                            bool.TryParse(row.GetValue(model.K1), out k1);
                            investor = null;
                            country = null;
                            state = null;

                            if (string.IsNullOrEmpty(investorName) == false) {
                                investor = InvestorRepository.FindInvestor(investorName);
                            }

                            if (investor == null) {
                                error.Errors.Add(new ErrorInfo(model.InvestorName, "Investor does not exist"));
                            }
                            else {

                                if (string.IsNullOrEmpty(countryName) == false) {
                                    country = AdminRepository.FindCountry(countryName);
                                }

                                if (string.IsNullOrEmpty(stateName) == false) {
                                    state = AdminRepository.FindState(stateName);
                                }

                                // Attempt to create new investor contact.
                                InvestorContact investorContact = InvestorRepository.FindInvestorContact(investor.InvestorID,
                                      contactPerson,
                                      designation,
                                      receivesDistributionCapitalCallNotices,
                                      financials,
                                      k1,
                                      investorLetters
                                     );

                                if (investorContact == null) {
                                    investorContact = new InvestorContact();
                                    investorContact.CreatedBy = Authentication.CurrentUser.UserID;
                                    investorContact.CreatedDate = DateTime.Now;
                                }
                                else {
                                    error.Errors.Add(new ErrorInfo(model.InvestorName, "Investor contact already exist"));
                                }

                                if (error.Errors.Count() == 0) {

                                    investorContact.InvestorID = investor.InvestorID;
                                    investorContact.EntityID = Authentication.CurrentEntity.EntityID;
                                    investorContact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                                    investorContact.LastUpdatedDate = DateTime.Now;

                                    investorContact.Contact = new Contact();
                                    investorContact.Contact.CreatedBy = Authentication.CurrentUser.UserID;
                                    investorContact.Contact.CreatedDate = DateTime.Now;

                                    investorContact.Contact.ContactName = contactPerson;
                                    investorContact.Contact.FirstName = "n/a";
                                    investorContact.Contact.LastName = "n/a";
                                    investorContact.Contact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                                    investorContact.Contact.LastUpdatedDate = DateTime.Now;
                                    investorContact.Contact.ReceivesDistributionNotices = receivesDistributionCapitalCallNotices;
                                    investorContact.Contact.ReceivesFinancials = financials;
                                    investorContact.Contact.ReceivesInvestorLetters = investorLetters;
                                    investorContact.Contact.ReceivesK1 = k1;
                                    investorContact.Contact.Designation = designation;
                                    investorContact.Contact.EntityID = Authentication.CurrentEntity.EntityID;

                                    // Attempt to create new investor contact address.
                                    ContactAddress contactAddress = null;

                                    contactAddress = new ContactAddress();
                                    contactAddress.CreatedBy = Authentication.CurrentUser.UserID;
                                    contactAddress.CreatedDate = DateTime.Now;
                                    contactAddress.EntityID = Authentication.CurrentEntity.EntityID;
                                    contactAddress.LastUpdatedBy = Authentication.CurrentUser.UserID;
                                    contactAddress.LastUpdatedDate = DateTime.Now;

                                    contactAddress.Address = new Address();
                                    contactAddress.Address.CreatedBy = Authentication.CurrentUser.UserID;
                                    contactAddress.Address.CreatedDate = DateTime.Now;
                                    contactAddress.Address.Address1 = address;
                                    contactAddress.Address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work;
                                    contactAddress.Address.City = city;
                                    contactAddress.Address.Country = (country != null ? country.CountryID : 0);
                                    contactAddress.Address.EntityID = Authentication.CurrentEntity.EntityID;
                                    contactAddress.Address.LastUpdatedBy = Authentication.CurrentUser.UserID;
                                    contactAddress.Address.LastUpdatedDate = DateTime.Now;
                                    contactAddress.Address.PostalCode = zip;
                                    contactAddress.Address.State = (state != null ? state.StateID : 0);

                                    /* Add Investor Contact Communication Values */

                                    if (string.IsNullOrEmpty(contactAddress.Address.Address1) == false
                                       || string.IsNullOrEmpty(contactAddress.Address.Address2) == false
                                       || string.IsNullOrEmpty(contactAddress.Address.City) == false
                                        || string.IsNullOrEmpty(contactAddress.Address.PostalCode) == false
                                        || string.IsNullOrEmpty(investorContact.Contact.ContactName) == false
                                        || string.IsNullOrEmpty(fax) == false
                                        || string.IsNullOrEmpty(email) == false
                                        || string.IsNullOrEmpty(webAddress) == false
                                     ) {
                                        errorInfo = ValidationHelper.Validate(contactAddress.Address);
                                        errorInfo = errorInfo.Union(ValidationHelper.Validate(investorContact.Contact));

                                        if (errorInfo.Any()) {
                                            error.Errors.Add(new ErrorInfo(model.InvestorName, ValidationHelper.GetErrorInfo(errorInfo)));
                                        }
                                        if (emailValidation.IsValid(email) == false)
                                            error.Errors.Add(new ErrorInfo(model.Email, "Invalid Email"));
                                        if (webAttribute.IsValid(webAddress) == false)
                                            error.Errors.Add(new ErrorInfo(model.WebAddress, "Invalid Web Address"));
                                        if (zipAttribute.IsValid(contactAddress.Address.PostalCode) == false)
                                            error.Errors.Add(new ErrorInfo(model.Zip, "Invalid Zip"));

                                        if (error.Errors.Count() == 0) {
                                            investorContact.Contact.ContactAddresses.Add(contactAddress);
                                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.HomePhone, telephone);
                                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Fax, fax);
                                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Email, email);
                                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.WebAddress, webAddress);
                                        }
                                    }

                                    if (error.Errors.Count() == 0) {
                                        errorInfo = InvestorRepository.SaveInvestorContact(investorContact);
                                        if (errorInfo != null) {
                                            error.Errors.Add(new ErrorInfo(model.InvestorName, ValidationHelper.GetErrorInfo(errorInfo)));
                                        }
                                    }
                                }
                            }

                            StringBuilder sberror = new StringBuilder();
                            foreach (var e in error.Errors) {
                                sberror.AppendFormat("{0},", e.ErrorMessage);
                            }
                            importExcelTable.AddError(rowNumber - 1, sberror.ToString());
                            errors.Add(error);
                        }
                    }
                }
                if (errors != null) {
                    succssRows = errors.Where(e => e.Errors.Count == 0).Count();
                    errorRows = errors.Where(e => e.Errors.Count > 0).Count();
                }
            }
            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 Json(new {
                Result = resultModel.Result,
                TotalRows = totalRows,
                CompletedRows = completedRows,
                TotalPages = totalPages,
                PageIndex = model.PageIndex,
                SuccessRows = succssRows,
                ErrorRows = errorRows
            });
        }
예제 #38
0
        public ActionResult UpdateInvestorContact(FormCollection collection)
        {
            ContactInformation model = new ContactInformation();
            this.TryUpdateModel(model, collection);
            ResultModel resultModel = new ResultModel();
            if (ModelState.IsValid) {
                InvestorContact investorContact = null;
                if ((model.InvestorContactId ?? 0) > 0)
                    investorContact = InvestorRepository.FindInvestorContact(model.InvestorContactId ?? 0);
                if (investorContact == null) {
                    investorContact = new InvestorContact();
                    investorContact.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContact.CreatedDate = DateTime.Now;
                    investorContact.Contact = new Contact();
                    investorContact.Contact.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContact.Contact.CreatedDate = DateTime.Now;
                }
                investorContact.InvestorID = model.InvestorId;
                investorContact.EntityID = Authentication.CurrentEntity.EntityID;
                investorContact.LastUpdatedDate = DateTime.Now;
                investorContact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                // Assign contact details
                investorContact.Contact.EntityID = Authentication.CurrentEntity.EntityID;
                investorContact.Contact.ContactName = model.Person;
                if (string.IsNullOrEmpty(investorContact.Contact.FirstName)) investorContact.Contact.FirstName = "n/a";
                if (string.IsNullOrEmpty(investorContact.Contact.LastName)) investorContact.Contact.LastName = "n/a";
                investorContact.Contact.ReceivesDistributionNotices = model.DistributionNotices;
                investorContact.Contact.ReceivesFinancials = model.Financials;
                investorContact.Contact.ReceivesInvestorLetters = model.InvestorLetters;
                investorContact.Contact.ReceivesK1 = model.K1;
                investorContact.Contact.Designation = model.Designation;
                investorContact.Contact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investorContact.Contact.LastUpdatedDate = DateTime.Now;

                ContactAddress investorContactAddress = investorContact.Contact.ContactAddresses.SingleOrDefault(address => address.ContactAddressID == model.ContactAddressId);
                // Assign address details
                if (investorContactAddress == null) {
                    investorContactAddress = new ContactAddress();
                    investorContactAddress.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContactAddress.CreatedDate = DateTime.Now;
                    investorContactAddress.Address = new Address();
                    investorContactAddress.Address.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContactAddress.Address.CreatedDate = DateTime.Now;
                    investorContact.Contact.ContactAddresses.Add(investorContactAddress);
                }
                investorContactAddress.EntityID = Authentication.CurrentEntity.EntityID;
                investorContactAddress.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investorContactAddress.LastUpdatedDate = DateTime.Now;
                investorContactAddress.Address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work;
                investorContactAddress.Address.EntityID = Authentication.CurrentEntity.EntityID;
                investorContactAddress.Address.Address1 = model.Address1;
                investorContactAddress.Address.Address2 = model.Address2;
                investorContactAddress.Address.City = model.City;
                investorContactAddress.Address.PostalCode = model.Zip;
                investorContactAddress.Address.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investorContactAddress.Address.LastUpdatedDate = DateTime.Now;
                investorContactAddress.Address.Country = model.Country;
                investorContactAddress.Address.State = model.State;

                /* Add Communication Values */
                AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.HomePhone, model.Phone);
                AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Fax, model.Fax);
                AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Email, model.Email);
                AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.WebAddress, model.WebAddress);

                IEnumerable<ErrorInfo> errorInfo = InvestorRepository.SaveInvestorContact(investorContact);
                resultModel.Result += ValidationHelper.GetErrorInfo(errorInfo);
                if (string.IsNullOrEmpty(resultModel.Result))
                    resultModel.Result += "True||" + investorContact.InvestorContactID;
            }
            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);
        }
예제 #39
0
        public ActionResult Create(FormCollection collection)
        {
            CreateModel model = new CreateModel();
            ResultModel resultModel = new ResultModel();
            IEnumerable<ErrorInfo> errorInfo = null;
            this.TryUpdateModel(model);
            string ErrorMessage = InvestorNameAvailable(model.InvestorName, model.InvestorId);
            StringBuilder errors;
            EmailAttribute emailValidation = new EmailAttribute();
            ZipAttribute zipAttribute = new ZipAttribute();
            WebAddressAttribute webAttribute = new WebAddressAttribute();
            int count = 0;
            string errorTitle = string.Empty;
            if (String.IsNullOrEmpty(ErrorMessage) == false) {
                ModelState.AddModelError("InvestorName", ErrorMessage);
            }
            ErrorMessage = SocialSecurityTaxIdAvailable(model.SocialSecurityTaxId, model.InvestorId);
            if (String.IsNullOrEmpty(ErrorMessage) == false) {
                ModelState.AddModelError("SocialSecurityTaxId", ErrorMessage);
            }
            if (ModelState.IsValid) {
                // Attempt to create new deal.
                DeepBlue.Models.Entity.Investor investor = new DeepBlue.Models.Entity.Investor();
                investor.Alias = model.Alias;
                investor.IsDomestic = model.DomesticForeign;
                investor.InvestorEntityTypeID = model.EntityType;
                investor.InvestorName = model.InvestorName;
                investor.FirstName = model.Alias;
                investor.ResidencyState = model.StateOfResidency;
                investor.Social = model.SocialSecurityTaxId ?? "";
                investor.Notes = model.Notes;
                investor.Source = model.Source;
                investor.FOIA = model.FOIA;
                investor.ERISA = model.ERISA;

                investor.TaxID = 0;
                investor.FirstName = string.Empty;
                investor.LastName = "n/a";
                investor.ManagerName = string.Empty;
                investor.MiddleName = string.Empty;
                investor.PrevInvestorID = 0;
                investor.CreatedBy = Authentication.CurrentUser.UserID;
                investor.CreatedDate = DateTime.Now;
                investor.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investor.LastUpdatedDate = DateTime.Now;
                investor.EntityID = Authentication.CurrentEntity.EntityID;
                investor.TaxExempt = false;

                // Attempt to create new investor address.
                InvestorAddress investorAddress = new InvestorAddress();
                investorAddress.CreatedBy = Authentication.CurrentUser.UserID;
                investorAddress.CreatedDate = DateTime.Now;
                investorAddress.EntityID = Authentication.CurrentEntity.EntityID;
                investorAddress.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investorAddress.LastUpdatedDate = DateTime.Now;

                investorAddress.Address = new Address();
                investorAddress.Address.Address1 = model.Address1 ?? "";
                investorAddress.Address.Address2 = model.Address2 ?? "";
                investorAddress.Address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work;
                investorAddress.Address.City = model.City ?? "";
                investorAddress.Address.Country = model.Country;
                investorAddress.Address.CreatedBy = Authentication.CurrentUser.UserID;
                investorAddress.Address.CreatedDate = DateTime.Now;
                investorAddress.Address.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investorAddress.Address.LastUpdatedDate = DateTime.Now;
                investorAddress.Address.EntityID = Authentication.CurrentEntity.EntityID;
                investorAddress.Address.PostalCode = model.Zip;
                investorAddress.Address.State = model.State;

                if (string.IsNullOrEmpty(investorAddress.Address.Address1) == false
                    || string.IsNullOrEmpty(investorAddress.Address.Address2) == false
                    || string.IsNullOrEmpty(investorAddress.Address.City) == false
                    || string.IsNullOrEmpty(investorAddress.Address.PostalCode) == false
                    || string.IsNullOrEmpty(investorAddress.Address.County) == false
                    || string.IsNullOrEmpty(model.Phone) == false
                    || string.IsNullOrEmpty(model.Email) == false
                    || string.IsNullOrEmpty(model.WebAddress) == false
                    || string.IsNullOrEmpty(model.Fax) == false
                    ) {

                    errorTitle = "<b>Address Information:</b>";
                    errors = new StringBuilder();
                    errorInfo = ValidationHelper.Validate(investorAddress.Address);
                    if (errorInfo.Any()) {
                        errors.Append(ValidationHelper.GetErrorInfo(errorInfo));
                    }
                    if (emailValidation.IsValid(model.Email) == false)
                        errors.Append("Invalid Email\n");
                    if (zipAttribute.IsValid(model.Zip) == false)
                        errors.Append("Invalid Zip\n");
                    if (webAttribute.IsValid(model.WebAddress) == false)
                        errors.Append("Invalid Web Address\n");
                    if (string.IsNullOrEmpty(errors.ToString()) == false) {
                        resultModel.Result = string.Format("{0}\n{1}\n", errorTitle, errors.ToString());
                    }

                    if (string.IsNullOrEmpty(resultModel.Result)) {
                        /* Add New Investor Address */
                        investor.InvestorAddresses.Add(investorAddress);
                        /* Investor Communication Values */
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.HomePhone, model.Phone);
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.Email, model.Email);
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.WebAddress, model.WebAddress);
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.Fax, model.Fax);
                    }
                }

                /* Bank Account */
                count = 0;
                InvestorAccount investorAccount;
                for (int index = 0; index < model.AccountLength; index++) {

                    if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "BankIndex"]) <= 0) continue;

                    count++;

                    // Attempt to create new investor account.
                    investorAccount = new InvestorAccount();
                    investorAccount.Comments = string.Empty;
                    investorAccount.CreatedBy = Authentication.CurrentUser.UserID;
                    investorAccount.CreatedDate = DateTime.Now;
                    investorAccount.EntityID = Authentication.CurrentEntity.EntityID;
                    investorAccount.IsPrimary = false;
                    investorAccount.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    investorAccount.LastUpdatedDate = DateTime.Now;
                    investorAccount.Routing = DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ABANumber"]);
                    investorAccount.Reference = Convert.ToString(collection[(index + 1).ToString() + "_" + "Reference"]);
                    investorAccount.AccountOf = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountOf"]);
                    investorAccount.FFC = Convert.ToString(collection[(index + 1).ToString() + "_" + "FFC"]);
                    investorAccount.FFCNumber = Convert.ToString(collection[(index + 1).ToString() + "_" + "FFCNumber"]);
                    investorAccount.IBAN = Convert.ToString(collection[(index + 1).ToString() + "_" + "IBAN"]);
                    investorAccount.ByOrderOf = Convert.ToString(collection[(index + 1).ToString() + "_" + "ByOrderOf"]);
                    investorAccount.SWIFT = Convert.ToString(collection[(index + 1).ToString() + "_" + "Swift"]);
                    investorAccount.Account = Convert.ToString(collection[(index + 1).ToString() + "_" + "Account"]);
                    investorAccount.AccountNumberCash = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountNumber"]);
                    investorAccount.Attention = Convert.ToString(collection[(index + 1).ToString() + "_" + "Attention"]);
                    investorAccount.BankName = Convert.ToString(collection[(index + 1).ToString() + "_" + "BankName"]);
                    investorAccount.Phone = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountPhone"]);
                    investorAccount.Fax = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountFax"]);

                    if (string.IsNullOrEmpty(investorAccount.Comments) == false
                      || string.IsNullOrEmpty(investorAccount.Reference) == false
                      || string.IsNullOrEmpty(investorAccount.AccountOf) == false
                      || string.IsNullOrEmpty(investorAccount.FFC) == false
                      || string.IsNullOrEmpty(investorAccount.FFCNumber) == false
                      || string.IsNullOrEmpty(investorAccount.IBAN) == false
                      || string.IsNullOrEmpty(investorAccount.ByOrderOf) == false
                      || string.IsNullOrEmpty(investorAccount.SWIFT) == false
                      || string.IsNullOrEmpty(investorAccount.Account) == false
                      || string.IsNullOrEmpty(investorAccount.AccountNumberCash) == false
                      || string.IsNullOrEmpty(investorAccount.Attention) == false
                      || string.IsNullOrEmpty(investorAccount.BankName) == false
                      || string.IsNullOrEmpty(investorAccount.Phone) == false
                      || string.IsNullOrEmpty(investorAccount.Fax) == false
                      || investorAccount.Routing > 0) {
                        errorInfo = ValidationHelper.Validate(investorAccount);
                        if (errorInfo.Any()) {
                            resultModel.Result += string.Format("<b>Bank Information {0}:</b>\n{1}\n", count.ToString(), ValidationHelper.GetErrorInfo(errorInfo));
                        }
                        if (string.IsNullOrEmpty(resultModel.Result)) {
                            investor.InvestorAccounts.Add(investorAccount);
                        }
                    }
                }

                count = 0;
                /* Contact Address */
                InvestorContact investorContact;
                ContactAddress contactAddress;
                for (int index = 0; index < model.ContactLength; index++) {

                    if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ContactIndex"]) <= 0) continue;

                    count++;

                    // Attempt to create new investor contact.
                    investorContact = new InvestorContact();
                    investorContact.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContact.CreatedDate = DateTime.Now;
                    investorContact.EntityID = Authentication.CurrentEntity.EntityID;
                    investorContact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    investorContact.LastUpdatedDate = DateTime.Now;
                    investorContact.Contact = new Contact();

                    investorContact.Contact.ContactName = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactPerson"]);
                    investorContact.Contact.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContact.Contact.CreatedDate = DateTime.Now;
                    investorContact.Contact.FirstName = "n/a";
                    investorContact.Contact.LastName = "n/a";
                    investorContact.Contact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    investorContact.Contact.LastUpdatedDate = DateTime.Now;
                    investorContact.Contact.ReceivesDistributionNotices = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "DistributionNotices"]);
                    investorContact.Contact.ReceivesFinancials = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "Financials"]);
                    investorContact.Contact.ReceivesInvestorLetters = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "InvestorLetters"]);
                    investorContact.Contact.ReceivesK1 = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "K1"]);
                    investorContact.Contact.Designation = collection[(index + 1).ToString() + "_" + "Designation"];
                    investorContact.Contact.EntityID = Authentication.CurrentEntity.EntityID;

                    // Attempt to create new investor contact address.
                    contactAddress = new ContactAddress();
                    contactAddress.CreatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.CreatedDate = DateTime.Now;
                    contactAddress.EntityID = Authentication.CurrentEntity.EntityID;
                    contactAddress.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.LastUpdatedDate = DateTime.Now;

                    contactAddress.Address = new Address();
                    contactAddress.Address.Address1 = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactAddress1"]);
                    contactAddress.Address.Address2 = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactAddress2"]);
                    contactAddress.Address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work;
                    contactAddress.Address.City = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactCity"]);
                    contactAddress.Address.Country = Convert.ToInt32(collection[(index + 1).ToString() + "_" + "ContactCountry"]);
                    contactAddress.Address.CreatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.Address.CreatedDate = DateTime.Now;
                    contactAddress.Address.EntityID = Authentication.CurrentEntity.EntityID;
                    contactAddress.Address.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.Address.LastUpdatedDate = DateTime.Now;
                    contactAddress.Address.PostalCode = collection[(index + 1).ToString() + "_" + "ContactZip"];
                    contactAddress.Address.State = Convert.ToInt32(collection[(index + 1).ToString() + "_" + "ContactState"]);

                    /* Add Investor Contact Communication Values */
                    string contactPhoneNo = collection[(index + 1).ToString() + "_" + "ContactPhoneNumber"];
                    string contactFaxNo = collection[(index + 1).ToString() + "_" + "ContactFaxNumber"];
                    string contactEmail = collection[(index + 1).ToString() + "_" + "ContactEmail"];
                    string contactWebAddress = collection[(index + 1).ToString() + "_" + "ContactWebAddress"];

                    if (string.IsNullOrEmpty(contactAddress.Address.Address1) == false
                       || string.IsNullOrEmpty(contactAddress.Address.Address2) == false
                       || string.IsNullOrEmpty(contactAddress.Address.City) == false
                        || string.IsNullOrEmpty(contactAddress.Address.PostalCode) == false
                        || string.IsNullOrEmpty(investorContact.Contact.ContactName) == false
                        || string.IsNullOrEmpty(contactPhoneNo) == false
                        || string.IsNullOrEmpty(contactFaxNo) == false
                        || string.IsNullOrEmpty(contactEmail) == false
                        || string.IsNullOrEmpty(contactWebAddress) == false
                     ) {
                        errorInfo = ValidationHelper.Validate(contactAddress.Address);
                        errorInfo = errorInfo.Union(ValidationHelper.Validate(investorContact.Contact));

                        errorTitle = "<b>Contact Information {0}:</b>\n{1}\n";
                        errors = new StringBuilder();
                        if (errorInfo.Any()) {
                            errors.Append(ValidationHelper.GetErrorInfo(errorInfo));
                        }
                        if (emailValidation.IsValid(contactEmail) == false)
                            errors.Append("Invalid Email\n");
                        if (webAttribute.IsValid(contactWebAddress) == false)
                            errors.Append("Invalid Web Address\n");
                        if (zipAttribute.IsValid(contactAddress.Address.PostalCode) == false)
                            errors.Append("Invalid Zip\n");

                        if (string.IsNullOrEmpty(errors.ToString()) == false) {
                            resultModel.Result += string.Format(errorTitle, count.ToString(), errors.ToString());
                        }

                        if (string.IsNullOrEmpty(resultModel.Result)) {
                            investorContact.Contact.ContactAddresses.Add(contactAddress);
                        }
                        if (string.IsNullOrEmpty(resultModel.Result)) {
                            investor.InvestorContacts.Add(investorContact);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.HomePhone, contactPhoneNo);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Fax, contactFaxNo);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Email, contactEmail);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.WebAddress, contactWebAddress);
                        }
                    }

                }
                if (string.IsNullOrEmpty(resultModel.Result)) {
                    errorInfo = InvestorRepository.SaveInvestor(investor);
                    if (errorInfo != null) {
                        resultModel.Result = ValidationHelper.GetErrorInfo(errorInfo);
                    }
                    else {
                        resultModel.Result += SaveCustomValues(collection, investor.InvestorID);
                    }
                }
                if (string.IsNullOrEmpty(resultModel.Result)) {
                    resultModel.Result = "True||" + investor.InvestorID;
                }
            }
            if (ModelState.IsValid == false) {
                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);
        }
예제 #40
0
 /// <summary>
 /// Utility method to convert address information from the vCard library to a
 /// WinRT ContactAddress instance.
 /// No 1:1 matching is possible between both classes, the method tries to
 /// keep the conversion as accurate as possible.
 /// </summary>
 /// <param name="address">Address information from the vCard library.</param>
 /// <returns>The address information from the vCard library converted to a 
 /// WinRT ContactAddress instance.</returns>
 private ContactAddress ConvertVcardToAddress(vCardDeliveryAddress address)
 {
     var ca = new ContactAddress
     {
         Country = address.Country,
         PostalCode = address.PostalCode,
         Region = address.Region,
         StreetAddress = address.Street,
         Locality = address.City,
         Kind = ConvertVcardToAddressType(address.AddressType)
     };
     return ca;
 }
예제 #41
0
 /// <summary>
 /// Utility method to convert address information from the WinRT ContactAddress 
 /// instance to the representation in the vCard library.
 /// No 1:1 matching is possible between both classes, the method tries to
 /// keep the conversion as accurate as possible.
 /// </summary>
 /// <param name="address">Address information from WinRT.</param>
 /// <returns>The address information from WinRT library converted to a 
 /// vCard library class instance.</returns>
 private vCardDeliveryAddress ConvertAddressToVcard(ContactAddress address)
 {
     var newAddress = new vCardDeliveryAddress
     {
         Country = address.Country,
         PostalCode = address.PostalCode,
         Region = address.Region,
         Street = address.StreetAddress,
         City = address.Locality,
         AddressType = ConvertAddressTypeToVcard(address.Kind)
     };
     return newAddress;
 }
예제 #42
0
파일: Contacts.cs 프로젝트: preekmr/Bytes
        private string getFormattedJSONAddress(ContactAddress address, bool isPrefered)
        {
            string addressFormatString = "\"pref\":{0}," + // bool
                          "\"type\":\"{1}\"," +
                          "\"formatted\":\"{2}\"," +
                          "\"streetAddress\":\"{3}\"," +
                          "\"locality\":\"{4}\"," +
                          "\"region\":\"{5}\"," +
                          "\"postalCode\":\"{6}\"," +
                          "\"country\":\"{7}\"";

            string formattedAddress = EscapeJson(address.PhysicalAddress.AddressLine1 + " "
                                    + address.PhysicalAddress.AddressLine2 + " "
                                    + address.PhysicalAddress.City + " "
                                    + address.PhysicalAddress.StateProvince + " "
                                    + address.PhysicalAddress.CountryRegion + " "
                                    + address.PhysicalAddress.PostalCode);

            string jsonAddress = string.Format(addressFormatString,
                                               isPrefered ? "\"true\"" : "\"false\"",
                                               address.Kind.ToString(),
                                               formattedAddress,
                                               EscapeJson(address.PhysicalAddress.AddressLine1 + " " + address.PhysicalAddress.AddressLine2),
                                               address.PhysicalAddress.City,
                                               address.PhysicalAddress.StateProvince,
                                               address.PhysicalAddress.PostalCode,
                                               address.PhysicalAddress.CountryRegion);

            //Debug.WriteLine("getFormattedJSONAddress returning :: " + jsonAddress);

            return "{" + jsonAddress + "}";
        }
예제 #43
0
        private string getFormattedJSONAddress(ContactAddress address, bool isPrefered)
        {
            string addressFormatString = "pref:{0}," + // bool
                          "type:'{1}'," +
                          "formatted:'{2}'," +
                          "streetAddress:'{3}'," +
                          "locality:'{4}'," +
                          "region:'{5}'," +
                          "postalCode:'{6}'," +
                          "country:'{7}'";

            string jsonAddress = string.Format(addressFormatString,
                                               isPrefered ? "true" : "false",
                                               address.Kind.ToString(),
                                               "formattedAddress",
                                               address.PhysicalAddress.AddressLine1 + " " + address.PhysicalAddress.AddressLine2,
                                               address.PhysicalAddress.City,
                                               address.PhysicalAddress.StateProvince,
                                               address.PhysicalAddress.PostalCode,
                                               address.PhysicalAddress.CountryRegion);

            return "{" + jsonAddress + "}";
        }