public string AddUser(HOBAppUser user)
        {
            Logger.Info(user.FirstName + " " + user.LastName + " " + user.Email);

            string existingUserId = string.Empty;
            var    existingUser   = FindUser(user.Email);

            // update
            if (existingUser != null)
            {
                existingUserId = existingUser.UserId;
                UpdateUser(existingUser, user);
            }

            // add if not present
            if (existingUser == null)
            {
                existingUserId = AddNewUser(user);
            }

            // Add new IP Address if not found
            var existingIPAddress = FindIPAddress(existingUserId, user.ClientIPAddress);

            if (existingIPAddress == null)
            {
                AddNewIPAddress(existingUserId, user.ClientIPAddress);
            }

            return(existingUserId);
        }
        public string AddRentValuationRecord(HOBAppUser user, Address address, RentValuationData rentValuationData)
        {
            // check if the user is already there
            AppUsers existingUser = FindUser(user.Email);

            // if this user not found, then add.
            string existingUserId = string.Empty;

            if (existingUser == null)
            {
                existingUserId = AddNewUser(user);
            }
            else
            {
                // also update the user
                UpdateUser(existingUser, user);
                existingUserId = existingUser.UserId;

                var IPAddress = FindIPAddress(existingUserId, user.ClientIPAddress);

                if (IPAddress == null)
                {
                    AddNewIPAddress(existingUserId, user.ClientIPAddress);
                }
            }

            // check if this address is already there. Or else add.
            var    existingAddress   = FindAddress(existingUserId, address);
            string existingAddressId = string.Empty;

            if (existingAddress == null)
            {
                existingAddressId = AddNewAddress(existingUserId, address);
            }
            else
            {
                existingAddressId = existingAddress.AddressId;
            }

            // we always add the rent valuation record everytime as it will keep changing as per market fluctuation
            var newRentValuationRecordGuid = Guid.NewGuid().ToString();

            homeOwnerBestieDBContext.RentValuationReports.Add(new RentValuationReports()
            {
                AverageMonthlyRent      = rentValuationData.AverageMonthlyRent,
                IsRentEstimateAvailable = rentValuationData.IsRentEstimateAvailable,
                RentValuationRecordId   = newRentValuationRecordGuid,
                ValuationRentHigh       = rentValuationData.ValuationRentHigh,
                ValuationRentLow        = rentValuationData.ValuationRentLow,
                ValueChangedIn30Days    = rentValuationData.ValueChangedIn30Days,
                DateCreated             = DateTime.Now,
                UserId    = existingUserId,
                AddressId = existingAddressId
            });
            homeOwnerBestieDBContext.SaveChanges();

            return(newRentValuationRecordGuid);
        }
        string UpdateUser(AppUsers existingUser, HOBAppUser hobUser)
        {
            existingUser.DateModified = DateTime.Now;
            existingUser.FirstName    = hobUser.FirstName;
            existingUser.LastName     = hobUser.LastName;
            existingUser.Phone        = hobUser.Phone;

            homeOwnerBestieDBContext.SaveChanges();
            return(existingUser.UserId);
        }
 public string AddRentValuationRecord(HOBAppUser user, Address address, RentValuationData rentValuationData)
 {
     try
     {
         return(leadDataProvider.AddRentValuationRecord(user, address, rentValuationData));
     }
     catch (Exception ex)
     {
         //TBD
         return(null);
     }
 }
 public string AddUser(HOBAppUser user)
 {
     try
     {
         return(leadDataProvider.AddUser(user));
     }
     catch (Exception ex)
     {
         //TBD
         return(null);
     }
 }
Ejemplo n.º 6
0
        public bool EmailRentValuationReport(HOBAppUser user, decimal homeOwnerSpecifiedRent)
        {
            string            userId = this.leadDataManager.GetUserIdFromEmail(user.Email);
            string            updatedRentValuationRecord = this.leadDataManager.UpdateHomeOwnerSpecifiedRent(userId, homeOwnerSpecifiedRent);
            RentValuationData rentValuationData          = this.leadDataManager.FindRentValuationRecord(updatedRentValuationRecord);
            Address           address = this.leadDataManager.GetAddressFromRentValuationRecordId(updatedRentValuationRecord);

            //var jsonUser = JsonConvert.SerializeObject(user);
            //var jsonRentValuationData = JsonConvert.SerializeObject(rentValuationData);
            //var jsonAddress = JsonConvert.SerializeObject(address);

            EmailEnvelop emailEnvelope = new EmailEnvelop()
            {
                Body = "<h1>Congratulations on your signup!</h1>"
                       + "<hr/>"
                       + "<h2>Here is the data we have collected from you.</h2>"
                       + "<h3>User Info</h3>"
                       + "<p> Name: " + user.FirstName + " " + user.LastName + "</p>"
                       + "<p> IP Address: " + user.ClientIPAddress + "</p>"
                       + "<p> Phone: " + user.Phone + "</p>"
                       + "<h3>Rent Valuation Data</h3>"
                       + "<p> Home Owner Specified Rent: " + (rentValuationData.HomeOwnerSpecifiedRent == 0 ? "None" : rentValuationData.HomeOwnerSpecifiedRent.ToString()) + "</p>"
                       + "<p> Average Monthly Rent: " + rentValuationData.AverageMonthlyRent + "</p>"
                       + "<p> Valuation Range High : " + rentValuationData.ValuationRentHigh + "</p>"
                       + "<p> Valuation Range Low : " + rentValuationData.ValuationRentLow + "</p>"
                       + "<p> Value Changed In 30 Days: " + rentValuationData.ValueChangedIn30Days + "</p>"
                       + "<p> Is Rent Estimate Available: " + (rentValuationData.IsRentEstimateAvailable?"Yes":"No") + "</p>"
                       + "<h3>Home Address</h3>"
                       + "<p> Street: " + address.Street + "</p>"
                       + "<p> City: " + address.City + "</p>"
                       + "<p> County: " + (!string.IsNullOrEmpty(address.County)?address.County:"--") + "</p>"
                       + "<p> State: " + address.State + "</p>"
                       + "<p> Zip: " + address.Zip + "</p>"
                       + "<h4>Thank you. Visit us again!</h4>"
                       + "<h5>Best wishes from Home Owner Bestie Team :-)</h5>",
                From    = "*****@*****.**",
                To      = user.Email,
                Subject = $"Hello {user.FirstName}! Your Home Rent Valuation Info is now ready.",
            };

            EmailConfig emailConfig = new EmailConfig()
            {
                Password = "******",
                Port     = 587,
                Smtp     = "smtp.gmail.com",
                UserName = "******"
            };

            return(Utils.SendEmail(emailEnvelope, emailConfig));
        }
        string AddNewUser(HOBAppUser user)
        {
            var newUserGuid = Guid.NewGuid().ToString();

            homeOwnerBestieDBContext.AppUsers.Add(new AppUsers()
            {
                DateCreated = DateTime.Now,
                FirstName   = user.FirstName,
                LastName    = user.LastName,
                Email       = user.Email,
                Phone       = user.Phone,
                UserId      = newUserGuid
            });

            homeOwnerBestieDBContext.SaveChanges();
            return(newUserGuid);
        }
Ejemplo n.º 8
0
        public RentValuationData RunRentEvaluation(HOBAppUser user, Address address)
        {
            RentValuationData rentValuationData = realEstateDataProvider.RunRentEvaluation(address);

            if (rentValuationData == null)
            {
                return(rentValuationData);
            }

            string rentValuationRecordId = leadDataManager.AddRentValuationRecord(user, address, rentValuationData);

            if (string.IsNullOrWhiteSpace(rentValuationRecordId))
            {
                return(null);
            }

            return(rentValuationData);
        }
Ejemplo n.º 9
0
 public string Post([FromBody] HOBAppUser user)
 {
     return(leadDataManager.AddUser(user));
 }