Exemplo n.º 1
0
        /// <summary>
        /// Changes the contact properties of a specific platform
        /// Updates the changes in database
        /// </summary>
        public Customization ChangeAddress(int platformId, string streetAndHousenumber, string zipcode, string city, string country, string email)
        {
            InitRepo();

            //Get Customization of platform
            SubPlatform platform = platformRepo.ReadSubplatformWithCustomization(platformId);

            if (platform == null || platform.Customization == null)
            {
                return(null);
            }

            //Change Customization
            Customization custom = platform.Customization;

            custom.StreetAndHousenumber = streetAndHousenumber;
            custom.Zipcode = zipcode;
            custom.City    = city;
            custom.Country = country;
            custom.Email   = email;

            //Update platform
            platformRepo.UpdateSubplatform(platform);

            return(custom);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Changes the page text of a specific platform
        /// Updates the changes in database
        /// </summary>
        public Customization ChangePageText(int platformId, string personAlias, string personsAlias, string organisationAlias, string organisationsAlias, string themeAlias, string themesAlias)
        {
            InitRepo();

            //Get Customization of platform
            SubPlatform platform = platformRepo.ReadSubplatformWithCustomization(platformId);

            if (platform == null || platform.Customization == null)
            {
                return(null);
            }

            //Change Customization
            Customization custom = platform.Customization;

            custom.PersonAlias        = personAlias;
            custom.PersonsAlias       = personsAlias;
            custom.OrganisationAlias  = organisationAlias;
            custom.OrganisationsAlias = organisationsAlias;
            custom.ThemeAlias         = themeAlias;
            custom.ThemesAlias        = themesAlias;

            //Update platform
            platformRepo.UpdateSubplatform(platform);

            return(custom);
        }
        public ActionResult CreatePerson(CreateItemModels.CreatePersonModel model)
        {
            int subPlatformID = (int)RouteData.Values["SubPlatformID"];

            itemManager     = new ItemManager();
            platformManager = new SubplatformManager();
            dataManager     = new DataManager();
            SubPlatform subplatform = platformManager.GetSubPlatform(subPlatformID);

            if (model.Name == null || model.Website == null || model.OrganisationId == 0)
            {
                return(RedirectToAction("ItemManagement", "Admin"));
            }
            else
            {
                string themeName     = Regex.Replace(model.Name, @"\s+", "");
                string themeWordlist = Regex.Replace(model.Website, @"\s+", "");

                if (themeName.Count() == 0 || themeWordlist.Count() == 0)
                {
                    return(RedirectToAction("ItemManagement", "Admin"));
                }
            }

            Person person = (Person)itemManager.AddItem(ItemType.Person, model.Name, site: model.Website, dateOfBirth: new System.DateTime(1900, 1, 1));

            itemManager.ChangeItemPlatform(person.ItemId, subplatform.SubPlatformId);
            itemManager.ChangePersonOrganisation(person.ItemId, model.OrganisationId);

            itemManager.ChangePersonSocialMedia(person.ItemId, model.Twitter, model.Facebook);

            itemManager.GenerateDefaultItemWidgets(person.Name, person.ItemId);

            return(RedirectToAction("Details", "Person", new { id = person.ItemId }));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Changes the page colors of a specific platform
        /// Updates the changes in database
        /// </summary>
        public Customization ChangePageColors(int platformId, string primaryColor, string primaryDarkerColor, string primaryDarkestColor, string secondairyColor,
                                              string secondaryLighterColor, string secondaryDarkerColor, string secondaryDarkestColor, string tertiaryColor, string backgroundColor, string textColor)
        {
            InitRepo();

            //Get Customization of platform
            SubPlatform platform = platformRepo.ReadSubplatformWithCustomization(platformId);

            if (platform == null || platform.Customization == null)
            {
                return(null);
            }

            //Change Customization
            Customization custom = platform.Customization;

            custom.PrimaryColor          = primaryColor;
            custom.PrimaryDarkerColor    = primaryDarkerColor;
            custom.PrimaryDarkestColor   = primaryDarkestColor;
            custom.SecondaryColor        = secondairyColor;
            custom.SecondaryLighterColor = secondaryLighterColor;
            custom.SecondaryDarkerColor  = secondaryDarkerColor;
            custom.SecondaryDarkestColor = secondaryDarkestColor;
            custom.TertiaryColor         = tertiaryColor;
            custom.BackgroundColor       = backgroundColor;
            custom.TextColor             = textColor;

            //Update platform
            platformRepo.UpdateSubplatform(platform);

            return(custom);
        }
        public ActionResult CreateOrganisation(CreateItemModels.CreateOrganisationModel model)
        {
            int subPlatformID = (int)RouteData.Values["SubPlatformID"];

            if (model.Name == null || model.Website == null)
            {
                return(RedirectToAction("ItemManagement", "Admin"));
            }
            else
            {
                string themeName     = Regex.Replace(model.Name, @"\s+", "");
                string themeWordlist = Regex.Replace(model.Website, @"\s+", "");

                if (themeName.Count() == 0 || themeWordlist.Count() == 0)
                {
                    return(RedirectToAction("ItemManagement", "Admin"));
                }
            }

            itemManager     = new ItemManager();
            platformManager = new SubplatformManager();
            SubPlatform subplatform = platformManager.GetSubPlatform(subPlatformID);

            Organisation org = (Organisation)itemManager.AddItem(ItemType.Organisation, model.Name, site: "www.kdg.be");

            itemManager.ChangeItemPlatform(org.ItemId, subplatform.SubPlatformId);

            itemManager.GenerateDefaultItemWidgets(org.Name, org.ItemId);
            return(RedirectToAction("Details", "Organisation", new { id = org.ItemId }));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a question in the database
        ///
        /// WARNING
        /// THIS METHOD USES UNIT OF WORK
        ///
        /// NOTE
        /// Unit of work is not realy needed because we work with one context
        /// Its added just for safety.
        /// </summary>
        public Question AddQuestion(int platformId, QuestionType type, string title, string anwser)
        {
            uowManager = new UnitOfWorkManager();
            InitRepo();

            //Get Subplatform
            SubPlatform platform = GetSubPlatform(platformId);

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

            //Create question
            Question question = new Question()
            {
                QuestionType = type,
                Title        = title,
                Answer       = anwser,
                SubPlatform  = platform
            };

            //Create question in database
            platformRepo.CreateQuestion(question);
            uowManager.Save();
            uowManager = null;

            return(question);
        }
        /// <summary>
        /// Gives back the customisation for a specific subplatform
        /// </summary>
        public Customization ReadCustomisation(int platformId)
        {
            SubPlatform subplatFrom = ctx.SubPlatforms.Include(platform => platform.Customization)
                                      .Where(platform => platform.SubPlatformId == platformId)
                                      .SingleOrDefault();

            return(subplatFrom.Customization);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Deletes a platform from the database
        /// </summary>
        public void RemoveSubplatform(int platformId)
        {
            InitRepo();

            //Get platform
            SubPlatform platform = GetSubPlatform(platformId);

            if (platform == null)
            {
                return;
            }

            //Delete platform
            platformRepo.DeleteSubplatform(platform);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Forces an update for the activity widgets
        /// </summary>
        public IEnumerable <Widget> ChangeWidgetActities(IEnumerable <Widget> widgets, int platformId)
        {
            //** Create new widgetDatas **//
            DataManager dataManager = new DataManager();

            //1st widget
            WidgetData loginData   = dataManager.GetUserActivitiesData(ActivityType.LoginActivity, DateTime.Now.AddDays(-30));
            Widget     loginWidget = widgets.Where(widget => widget.PropertyTags.All(tag => tag.Name.ToLower().Contains("login"))).SingleOrDefault();

            loginWidget.WidgetDatas = new List <WidgetData>
            {
                loginData
            };
            loginData.Widget = loginWidget;
            widgetRepo.CreateWidgetData(loginData);

            //2nd widget
            WidgetData registerData   = dataManager.GetUserActivitiesData(ActivityType.RegisterActivity, DateTime.Now.AddDays(-30));
            Widget     registerWidget = widgets.Where(widget => widget.PropertyTags.All(tag => tag.Name.ToLower().Contains("register"))).SingleOrDefault();

            loginWidget.WidgetDatas = new List <WidgetData>
            {
                loginData
            };
            registerData.Widget = registerWidget;
            widgetRepo.CreateWidgetData(registerData);

            //3rd widget
            WidgetData visitData   = dataManager.GetUserActivitiesData(ActivityType.VisitActitiy, DateTime.Now.AddDays(-30));
            Widget     visitWidget = widgets.Where(widget => widget.PropertyTags.All(tag => tag.Name.ToLower().Contains("visit"))).SingleOrDefault();

            loginWidget.WidgetDatas = new List <WidgetData>
            {
                loginData
            };
            visitData.Widget = visitWidget;
            widgetRepo.CreateWidgetData(visitData);

            //Get last updated
            SubplatformManager platformManager = new SubplatformManager();
            SubPlatform        platform        = platformManager.GetSubPlatform(platformId);

            platform.LastUpdatedActivities = DateTime.Now;
            platformManager.ChangeSubplatform(platform);

            return(widgets);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Generate alerts for the weekly review
        /// </summary>
        public bool GenerateAlertsForWeeklyReview(int platformId)
        {
            InitRepo();

            //Get timepstamp for weekly review
            SubplatformManager platformManager = new SubplatformManager();
            SubPlatform        platform        = platformManager.GetSubPlatform(platformId);

            if (platform.LastUpdatedWeeklyReview != null && platform.LastUpdatedWeeklyReview > DateTime.Now.AddDays(-7))
            {
                return(false);
            }

            platform.LastUpdatedWeeklyReview = DateTime.Now;
            platformManager.ChangeSubplatform(platform);

            //Get all users
            IEnumerable <User> users = userRepo.ReadAllUsersWithAlerts();

            if (users == null || users.Count() == 0)
            {
                return(false);
            }

            //Generate weekly review alerts
            foreach (User user in users)
            {
                UserAlert alert = new UserAlert()
                {
                    User      = user,
                    Subject   = "Nieuwe Weekly Review",
                    IsRead    = false,
                    TimeStamp = DateTime.Now,
                    AlertType = AlertType.Weekly_Review
                };
                user.Alerts.Add(alert);
            }

            //Update database & send emails
            SendWeeklyReviewEmails(platformId, users.Where(user => user.AlertsViaEmail));
            userRepo.UpdateUsers(users);
            return(true);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Makes an subplatform and persist that to the database
        /// </summary>
        public SubPlatform AddSubplatform(string name)
        {
            InitRepo();

            //Make subplatform
            SubPlatform platform = new SubPlatform()
            {
                Name          = name,
                CreationDate  = DateTime.Now,
                NumberOfUsers = 0,
                Questions     = new List <Question>(),
                Customization = AddDefaultCustomization()
            };

            //Create subplatform
            platformRepo.CreateSubplatform(platform);

            return(platform);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Changes the FAQ title of a specific platform
        /// Updates the changes in database
        /// </summary>
        public Customization ChangeFAQTitle(int platformId, string title)
        {
            InitRepo();

            //Get Customization of platform
            SubPlatform platform = platformRepo.ReadSubplatformWithCustomization(platformId);

            if (platform == null || platform.Customization == null)
            {
                return(null);
            }

            //Change Customization
            Customization custom = platform.Customization;

            custom.FAQTitle = title;

            //Update platform
            platformRepo.UpdateSubplatform(platform);

            return(custom);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Changes the contact properties of a specific platform
        /// Updates the changes in database
        /// </summary>
        public Customization ChangePrivacyText(int platformId, string content, string title = "Privacy policy")
        {
            InitRepo();

            //Get Customization
            SubPlatform platform = platformRepo.ReadSubplatformWithCustomization(platformId);

            if (platform == null || platform.Customization == null)
            {
                return(null);
            }

            //Change Customization
            Customization custom = platform.Customization;

            custom.PrivacyText  = content;
            custom.PrivacyTitle = title;

            //Update platform
            platformRepo.UpdateSubplatform(platform);

            return(custom);
        }
        /// <summary>
        /// Generates some subplatforms.
        /// </summary>
        private void GenerateSubPlatforms(BarometerDbContext ctx)
        {
            SubPlatform subPlatform2 = new SubPlatform
            {
                Name          = "politiek",
                CreationDate  = DateTime.Now,
                Customization = AddDefaultCustomization(),
                Questions     = new List <Question>(),
            };

            ctx.SubPlatforms.Add(subPlatform2);

            SubPlatform subPlatform1 = new SubPlatform
            {
                Name          = "k3",
                CreationDate  = DateTime.Now,
                Customization = AddDefaultCustomization(),
                Questions     = new List <Question>(),
            };

            ctx.SubPlatforms.Add(subPlatform1);

            ctx.SaveChanges();
        }
 /// <summary>
 /// Updates a single subplatform.
 /// </summary>
 public int UpdateSubplatform(SubPlatform subPlatform)
 {
     ctx.Entry(subPlatform).State = EntityState.Modified;
     return(ctx.SaveChanges());
 }
 /// <summary>
 /// Creates a new instance of a given subplatform in the database
 /// </summary>
 public int CreateSubplatform(SubPlatform subPlatform)
 {
     ctx.SubPlatforms.Add(subPlatform);
     return(ctx.SaveChanges());
 }
Exemplo n.º 17
0
 /// <summary>
 /// Changes the subplatform in the database
 /// </summary>
 public SubPlatform ChangeSubplatform(SubPlatform platform)
 {
     InitRepo();
     platformRepo.UpdateSubplatform(platform);
     return(platform);
 }
 /// <summary>
 /// Deletes a subplatform.
 ///
 /// NOTE
 /// When you delete a subplatform, all other information of
 /// that subplatform will also be deleted.
 /// </summary>
 public int DeleteSubplatform(SubPlatform subPlatform)
 {
     ctx.SubPlatforms.Remove(subPlatform);
     return(ctx.SaveChanges());
 }