/// <summary>
        /// Initializes the model.
        /// </summary>
        /// <param name="notiItem">The noti item.</param>
        /// <param name="notificationPosition">The notification position.</param>
        /// <returns>INotificationPosition.</returns>
        protected virtual INotificationPosition InitModel(INotificationPositionType notiItem, NotificationPosition notificationPosition)
        {
            var model = GetModelInstance <INotificationPosition>();

            model.Name       = notiItem.Position.ToString();
            model.Type       = notiItem.Position;
            model.IsSelected = notiItem.Position == notificationPosition;
            return(model);
        }
示例#2
0
 /// <summary>
 /// Registers the notification position.
 /// </summary>
 /// <param name="notificationPosition">The notification position.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 /// <exception cref="InvalidOperationException">Notification position is null or already registered.</exception>
 public bool RegisterNotificationPosition(INotificationPositionType notificationPosition)
 {
     lock (dbLock)
     {
         if (notificationPosition == null || Database.NotificationPosition.Any(p => p.Position == notificationPosition.Position) || (notificationPosition.IsDefault && Database.NotificationPosition.Any(p => p.IsDefault)))
         {
             throw new InvalidOperationException("Notification position is null or already registered.");
         }
         var model = DIResolver.Get <INotificationPositionType>();
         model.IsDefault = notificationPosition.IsDefault;
         model.Position  = notificationPosition.Position;
         Database.NotificationPosition.Add(model);
         return(true);
     }
 }