Esempio n. 1
0
        public PushNotificationStatus PushNotification(string username, int compnayid, string message, string eventName)
        {
            try
            {
                using (UserPersonalSettingRepository cmp = new UserPersonalSettingRepository(_context))
                {
                    BO.UserPersonalSetting userSettings = (BO.UserPersonalSetting)cmp.GetByUserNameAndCompanyId(username, compnayid);

                    if (userSettings != null)
                    {
                        if (userSettings.IsPushNotificationEnabled)
                        {
                            var subscription = GetSubscriptionByEventName(username, eventName);
                            if (subscription != null)
                            {
                                var result = PushNotification(username, message, subscription.EventID);
                                if (result)
                                {
                                    return(PushNotificationStatus.Delivered);
                                }
                                else
                                {
                                    return(PushNotificationStatus.Failed);
                                }
                            }
                            else
                            {
                                return(PushNotificationStatus.EventNotSubscribed);
                            }
                        }
                        {
                            return(PushNotificationStatus.NotificationNotEnabled);
                        }
                    }
                    else
                    {
                        return(PushNotificationStatus.NotificationNotEnabled);
                    }
                }
            }
            catch (Exception e)
            {
                return(PushNotificationStatus.NotificationNotEnabled);
            }
        }
Esempio n. 2
0
        public PreferedModeOfComunication GetModeOfComunication(string userName, int companyid)
        {
            using (UserPersonalSettingRepository cmp = new UserPersonalSettingRepository(_context))

            {
                BO.UserPersonalSetting userSettings = (BO.UserPersonalSetting)cmp.GetByUserNameAndCompanyId(userName, companyid);


                if (userSettings != null)
                {
                    return((PreferedModeOfComunication)userSettings.PreferredModeOfCommunication);
                }
                else
                {
                    return(PreferedModeOfComunication.Both);
                }
            }
        }