Esempio n. 1
0
        private static void HandlePropertyChangeNotificationMessage(PropertyChangeNotificationMessage propertyChangeNotificationMessage)
        {
            IRealEstateContext context = new RealEstateContext(ConfigurationManager.ConnectionStrings["RealEstateConnection"].ToString());
            IRealEstatePropertyInterestRepository realEstatePropertyInterestRepository = new RealEstatePropertyInterestRepository(context);
            IRealEstateNotificationRepository     realEstateNotificationRepository     = new RealEstateNotificationRepository(context);
            var propertyInterests = realEstatePropertyInterestRepository.GetRealEstatePropertyInterests(propertyChangeNotificationMessage.PropertyId);

            foreach (var propertyInterest in propertyInterests)
            {
                //Create Notification
                var notification = new RealEstateNotification
                {
                    Message    = "Property Modification. Please check",
                    PropertyId = propertyChangeNotificationMessage.PropertyId,
                    UserId     = propertyInterest.UserId
                };
                realEstateNotificationRepository.CreateRealEstateNotification(notification);

                //Send Email Notification
                MailHelper mailHelper = new MailHelper();
                mailHelper.Recipient = propertyInterest.User.UserName;
                mailHelper.Subject   = "Property Change Notification";
                mailHelper.Sender    = ConfigurationManager.AppSettings["EmailFromAddress"];
                mailHelper.Body      = $"Property - {propertyInterest.Property.PropertyName} is modified. Please check the app for details";
                mailHelper.Send();
            }
        }
Esempio n. 2
0
        private void AddToAzureStorageQueue(long propertyId, string userId, string userName)
        {
            var message       = new PropertyChangeNotificationMessage(propertyId, userId, userName);
            var messageString = JsonConvert.SerializeObject(message);

            AzureQueueHelper.AddAzureQueueMessage(messageString);
        }