Beispiel #1
0
        public void CreateContact()
        {
            var contact = new PermitLandlordContact()
            {
                ROWID          = _landlordID,
                CONTACT_ACTIVE = true,
            };

            _db.PermitLandlordContacts.Add(contact);
            _db.SaveChanges();
            NewlyInsertedContactID = contact.CONTACT_ID;
        }
Beispiel #2
0
        private string GetFullName(PermitLandlordContact contact)
        {
            string s1 = "";
            string s2 = "";
            string s3 = "";

            if (MyString.IsStringLengthLongerThan(1, contact.CONTACT_HONORIFIC))
            {
                s1 = contact.CONTACT_HONORIFIC + " ";
            }

            if (MyString.IsStringLengthLongerThan(1, contact.CONTACT_FIRST_NAME))
            {
                s2 = contact.CONTACT_FIRST_NAME + " ";
            }

            if (MyString.IsStringLengthLongerThan(1, contact.CONTACT_LAST_NAME))
            {
                s3 = contact.CONTACT_LAST_NAME;
            }

            return(s1 + s2 + s3);
        }
        private void HandleLandlord(string sfLandlordID, string addr, string city, string state, string zipCode, string landlordContactName, string phone, string landlordName)
        {
            try
            {
                int landlordID = CommonMethods.GetMISID(TableName.PermitLandlord, sfLandlordID, salesForceProjectID);
                if (landlordID == 0)
                {
                    // insert to PermitLandlord
                    PermitLandlord pl = new PermitLandlord();
                    pl.NAME    = landlordName;
                    pl.ADDR_1  = addr;
                    pl.CITY    = city;
                    pl.STATE   = state;
                    pl.ZIPCODE = zipCode;
                    pl.Active  = true;

                    _db.PermitLandlords.Add(pl);
                    _db.SaveChanges();

                    int id = SqlCommon.GetNewlyInsertedRecordID(TableName.PermitLandlord);
                    landlordID = id;
                    if (id > 0)
                    {
                        CommonMethods.InsertToMISSalesForceMapping(TableName.PermitLandlord, sfLandlordID, id.ToString(), salesForceProjectID);
                    }
                }
                else
                {
                    var item = _db.PermitLandlords.Where(x => x.ROWID == landlordID).FirstOrDefault();
                    if (item != null)
                    {
                        item.NAME    = landlordName;
                        item.ADDR_1  = addr;
                        item.CITY    = city;
                        item.STATE   = state;
                        item.ZIPCODE = zipCode;

                        _db.Entry(item).State = EntityState.Modified;
                        _db.SaveChanges();
                    }
                }

                /* landlord contact */
                int landlordContactID = CommonMethods.GetMISID(TableName.PermitLandlordContact, sfLandlordID, salesForceProjectID);
                if (landlordContactID == 0)
                {
                    /* add landloard contact */
                    PermitLandlordContact plc = new PermitLandlordContact();
                    plc.ROWID = landlordID;
                    plc.CONTACT_FIRST_NAME = landlordContactName;
                    plc.CONTACT_PHONE      = phone;

                    _db.PermitLandlordContacts.Add(plc);
                    _db.SaveChanges();

                    int id = SqlCommon.GetNewlyInsertedRecordID(TableName.PermitLandlordContact);
                    if (id > 0)
                    {
                        CommonMethods.InsertToMISSalesForceMapping(TableName.PermitLandlordContact, sfLandlordID, id.ToString(), salesForceProjectID);
                    }
                }
                else
                {
                    var item = _db.PermitLandlordContacts.Where(x => x.CONTACT_ID == landlordContactID).FirstOrDefault();
                    if (item != null)
                    {
                        item.CONTACT_FIRST_NAME = landlordContactName;
                        item.CONTACT_PHONE      = phone;

                        _db.Entry(item).State = EntityState.Modified;
                        _db.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                LogMethods.Log.Error("HandleLandLord:Error:" + e.Message);
            }
        }