Ejemplo n.º 1
0
        public EditNotificationModel(List <ResourceModel> resources)
        {
            //Schedules = new List<ScheduleModel>();
            AttributeDomainItems = new List <AttributeDomainItemsModel>();
            DomainItems          = new List <DomainItemModel>();
            StartDate            = new DateTime();
            EndDate = new DateTime();
            NotificationDependencies = new List <NotificationDependencyModel>();

            foreach (ResourceModel r in resources)
            {
                foreach (ResourceAttributeUsage usage in r.ResourceStructure.ResourceAttributeUsages)
                {
                    ResourceStructureAttribute attr = usage.ResourceStructureAttribute;
                    AttributeDomainItemsModel  item = new AttributeDomainItemsModel(attr);
                    if (item.DomainItems.Count != 0)
                    {
                        if (!AttributeDomainItems.Any(a => a.AttrId == item.AttrId))
                        {
                            AttributeDomainItems.Add(item);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public EditNotificationModel(List <ResourceModel> resources, Notification notification)
        {
            Subject   = notification.Subject;
            StartDate = notification.StartDate;
            EndDate   = notification.EndDate;
            Message   = notification.Message;

            AttributeDomainItems     = new List <AttributeDomainItemsModel>();
            DomainItems              = new List <DomainItemModel>();
            NotificationDependencies = new List <NotificationDependencyModel>();

            //Add Attributes with domain items
            foreach (ResourceModel r in resources)
            {
                foreach (ResourceAttributeUsage usage in r.ResourceStructure.ResourceAttributeUsages)
                {
                    ResourceStructureAttribute attr = usage.ResourceStructureAttribute;
                    AttributeDomainItemsModel  item = new AttributeDomainItemsModel(attr);
                    if (item.DomainItems.Count != 0)
                    {
                        if (!AttributeDomainItems.Any(a => a.AttrId == item.AttrId))
                        {
                            AttributeDomainItems.Add(item);
                        }
                    }
                }
            }

            //Get all dependencies for the notification
            NotificationDependencies = new List <NotificationDependencyModel>();
            using (NotificationManager nManager = new NotificationManager())
            {
                List <NotificationDependency> ndList = nManager.GetNotificationDependenciesByNotification(notification.Id);
                ndList.ToList().ForEach(r => NotificationDependencies.Add(new NotificationDependencyModel(r)));
            }
        }