Exemplo n.º 1
0
        public void ChangeSubplatformSettings(Subplatform subplatform, List <SubplatformSetting> settings)
        {
            InitNonExistingRepo();
            if (subplatform == null)
            {
                throw new Exception("No subplatform has been provided");
            }

            settings.ForEach(ss =>
            {
                if (ss.Subplatform.SubplatformId != subplatform.SubplatformId)
                {
                    throw new Exception(
                        "Setting doesn't have same subplatform anymore. Settings cannot be removed from subplatforms, only disabled.");
                }
                if (!subplatform.Settings.Contains(ss))
                {
                    if (subplatform.Settings.FirstOrDefault(sstc => sstc.SettingName.Equals(ss.SettingName)) is null)
                    {
                        subplatform.Settings.Add(ss);
                    }
                    else
                    {
                        subplatform.Settings[
                            subplatform.Settings.FindIndex(sstc => sstc.SettingName.Equals(ss.SettingName))] = ss;
                    }
                }
            });

            SubplatformRepo.UpdateSubplatform(subplatform);
            uowManager.Save();
        }
Exemplo n.º 2
0
        public ActionResult _ThemaPartialTable(string subplatform)
        {
            Subplatform         Subplatform = SubplatformMgr.GetSubplatform(subplatform);
            IEnumerable <Theme> themes      = itemMgr.GetThemes().Where(t => t.SubPlatforms.Contains(Subplatform));

            return(PartialView(themes));
        }
Exemplo n.º 3
0
        public ActionResult _PersonPartialTable(string subplatform)
        {
            Subplatform          Subplatform = SubplatformMgr.GetSubplatform(subplatform);
            IEnumerable <Person> persons     = itemMgr.GetPersons().Where(p => p.SubPlatforms.Contains(Subplatform));

            return(PartialView(persons));
        }
Exemplo n.º 4
0
        public ActionResult UploadBanner(string subplatform, FileViewModel fileViewModel)
        {
            if (ModelState.IsValid)
            {
                Subplatform subplatformToChange = SubplatformMgr.GetSubplatform(subplatform);
                var         iconUrl             = "";
                string      _FileName           = "";
                if (fileViewModel.file != null)
                {
                    if (fileViewModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(fileViewModel.file.FileName);
                        //var name = "Default_Item_Logo";
                        //var newName = name + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Index/"), newName);
                        //fileViewModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Index/" + newName;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(fileViewModel.file.InputStream);
                        SubplatformMgr.ChangeSubplatformSetting(subplatformToChange, new SubplatformSetting
                        {
                            SettingName = Setting.Platform.BANNER,
                            Value       = null,
                            Image       = (byte[])imgCon.ConvertTo(img, typeof(byte[])),
                            IsEnabled   = true,
                            Subplatform = subplatformToChange
                        });
                    }
                }

                return(RedirectToAction("PlatformSettings", "Subplatform"));
            }

            return(RedirectToAction("PlatformSettings", "Subplatform"));
        }
        public ActionResult _Search(string subplatform)
        {
            Subplatform        sp    = SubplatformMgr.GetSubplatform(subplatform);
            IEnumerable <Item> items = itemMgr.GetItems().Where(i => i.SubPlatforms.Contains(sp)).OrderBy(i => i.Name);

            return(PartialView(items));
        }
Exemplo n.º 6
0
        internal static async void RefreshSubplatform(IActivatedEventArgs args = null)
        {
            await subplatformRefreshLock.WaitAsync();

            Crystal3.Core.Subplatform lastSubplatform = currentSubplatform;

            //First check for mixed reality.
            if (IsMixedRealitySupported())
            {
                //mixed reality and holographic supported.
                if (args != null)
                {
                    //https://docs.microsoft.com/en-us/uwp/api/windows.applicationmodel.preview.holographic.holographicapplicationpreview.isholographicactivation
                    //HoloLens will always return true for this.
                    //On other platforms, determines if the app was activated in holographic/mixed reality.
                    bool holographicActivation = Windows.ApplicationModel.Preview.Holographic.HolographicApplicationPreview.IsHolographicActivation(args);

                    if (holographicActivation)
                    {
                        currentSubplatform = Subplatform.MixedReality;
                        RaiseSubplatformChangeEvent(lastSubplatform, currentSubplatform);
                        subplatformRefreshLock.Release();
                        return;
                    }
                }

                if (IsCurrentViewInMixedReality())
                {
                    currentSubplatform = Subplatform.MixedReality;
                    RaiseSubplatformChangeEvent(lastSubplatform, currentSubplatform);
                    subplatformRefreshLock.Release();
                    return;
                }
            }

            //Check for tablet mode.
            if (IsCurrentViewInTabletMode())
            {
                //Tablet mode is specific to desktop sku at this point.
                currentSubplatform = Subplatform.TabletMode;
                RaiseSubplatformChangeEvent(lastSubplatform, currentSubplatform);
                subplatformRefreshLock.Release();
                return;
            }

            //Check for continuum for mobile/phone mode.
            if (IsCurrentViewInPhoneContinuumMode())
            {
                //Continuum For Phone mode is specific to mobile sku at this point.
                currentSubplatform = Subplatform.ContinuumForPhoneMode;
                RaiseSubplatformChangeEvent(lastSubplatform, currentSubplatform);
                subplatformRefreshLock.Release();
                return;
            }

            //Resets the subplatform back to none if it gets here.
            currentSubplatform = Subplatform.None;
            RaiseSubplatformChangeEvent(lastSubplatform, currentSubplatform);
            subplatformRefreshLock.Release();
        }
Exemplo n.º 7
0
        public List <ProfileAlert> GetWebAPIProfileAlerts(Subplatform subplatform, string userId)
        {
            InitNonExistingRepo();
            Profile profile      = ProfileRepo.ReadProfile(userId);
            bool?   settingValue = profile?.Settings
                                   .Find(us => us.SettingName.Equals(Setting.Account.WANTS_ANDROID_NOTIFICATIONS))?.boolValue;

            if (settingValue.HasValue && settingValue.Value)
            {
                List <ProfileAlert> profileAlerts = GetProfileAlerts(subplatform, userId).ToList();

                profileAlerts.Sort(delegate(ProfileAlert x, ProfileAlert y)
                {
                    if (x.TimeStamp == null && y.TimeStamp == null)
                    {
                        return(0);
                    }
                    if (x.TimeStamp == null)
                    {
                        return(-1);
                    }
                    if (y.TimeStamp == null)
                    {
                        return(1);
                    }
                    return(y.TimeStamp.CompareTo(x.TimeStamp));
                });

                return(profileAlerts);
            }

            return(new List <ProfileAlert>());
        }
Exemplo n.º 8
0
        public ActionResult _OrganisationPartialTable(string subplatform)
        {
            Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
            IEnumerable <Organisation> organisations = itemMgr.GetOrganisations().Where(o => o.SubPlatforms.Contains(Subplatform));

            return(PartialView(organisations));
        }
        public async Task <int> CleanupOldRecordsAsync(Subplatform subplatform)
        {
            InitNonExistingRepo();

            // Validation
            if (subplatform.Settings.FirstOrDefault(ss => ss.SettingName == Setting.Platform.DAYS_TO_KEEP_RECORDS) is
                null)
            {
                throw new Exception("Subplatform has no set period to keep records!");
            }

            // Days to keep records
            int days = int.Parse(subplatform.Settings
                                 .FirstOrDefault(ss => ss.SettingName == Setting.Platform.DAYS_TO_KEEP_RECORDS).Value);

            // All persons
            List <Person> persons = ItemRepo.ReadPersons().Where(i => i.SubPlatforms.Contains(subplatform)).ToList();

            // All records to clear
            List <Record> oldRecords = persons
                                       .SelectMany(p => p.Records)
                                       .Distinct()
                                       .Where(r => r.Date.Date < DateTime.Today.AddDays(-days))
                                       .ToList();

            // Persist deleted records
            if (oldRecords.Count > 0)
            {
                RecordRepo.DeleteRecords(oldRecords);
            }

            // Save pending changes
            return(await UowManager.SaveAsync());
        }
Exemplo n.º 10
0
        public ActionResult _KeywordPartialTable(string subplatform)
        {
            Subplatform           Subplatform = SubplatformMgr.GetSubplatform(subplatform);
            IEnumerable <Keyword> keywords    = itemMgr.GetKeywords();

            return(PartialView(keywords));
        }
        public ActionResult LoadDefaults(string subplatform)
        {
            Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);

            ViewBag.Logo     = VirtualPathUtility.ToAbsolute(SubplatformMgr.GetSubplatformSetting(Subplatform.SubplatformId, Setting.Platform.SITE_ICON_URL).Value);
            ViewBag.SiteName = Content(ViewBag.SiteName = SubplatformMgr.GetSubplatformSetting(Subplatform.SubplatformId, Setting.Platform.SITE_NAME).Value);
            return(Content(""));
        }
 public ActionResult GetThemeColors(string subplatform)
 {
     if (User.Identity.IsAuthenticated)
     {
         Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
         return(Content(accountMgr.GetUserSetting(User.Identity.GetUserId(), Setting.Account.THEME).Value.ToLower()));
     }
     return(Content(""));
 }
Exemplo n.º 13
0
 public ActionResult KeywordPartialCreate(string subplatform, Keyword keyword)
 {
     if (ModelState.IsValid)
     {
         Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
         itemMgr.AddKeyword(keyword.Name, keyword.Items);
         return(RedirectToAction("ItemBeheer", "Item"));
     }
     return(RedirectToAction("ItemBeheer", "Item"));
 }
Exemplo n.º 14
0
        public void DeleteSubplatform(int subplatformId)
        {
            Subplatform subplatform = ReadSubplatform(subplatformId);

            if (subplatform != null)
            {
                ctx.Subplatforms.Remove(subplatform);
                ctx.SaveChanges();
            }
        }
Exemplo n.º 15
0
        public ActionResult EditSubplatform(Subplatform newsubplatform)
        {
            Subplatform subplatform = SubplatformMgr.GetSubplatform(newsubplatform.SubplatformId);

            subplatform.Name = newsubplatform.Name;
            subplatform.URL  = newsubplatform.URL;
            SubplatformMgr.ChangeSubplatform(subplatform);

            return(PartialView(subplatform));
        }
Exemplo n.º 16
0
 private static void Seed()
 {
     if (!ItemManager.IsSyncing)
     {
         //Makes PB subplatform
         Subplatform pbSubplatform = SubplatformMgr.GetSubplatforms()
                                     .FirstOrDefault(s => s.Name.ToLower().Equals("Politieke Barometer".ToLower()));
         ItemMgr.SyncDatabase(pbSubplatform);
     }
 }
Exemplo n.º 17
0
        public IHttpActionResult AddQuestion([FromBody] FAQViewModel model)
        {
            Subplatform subplatform = SubplatformMgr.GetSubplatform(model.Subplatform);

            Page page  = subplatform.Pages.Where(p => p.PageName.ToLower().Equals("FAQ".ToLower())).FirstOrDefault();
            int  count = page.Tags.Count() + 1;

            SubplatformMgr.AddTag(page.PageId, "Question" + count, model.Question, model.Answer);

            return(Ok());
        }
        public void SyncDatabase(Subplatform subplatform)
        {
            if (!IsSyncing)
            {
                // Set IsSyncing flag
                IsSyncing = true;
                SyncDatabaseAsync(subplatform).Wait();

                // Reset IsSyncing flag
                IsSyncing = false;
            }
        }
Exemplo n.º 19
0
        public void SendWeeklyReviews(Subplatform subplatform)
        {
            if (!IsSendingWeeklyReviews)
            {
                // Set IsSendingWeeklyReviews flag
                IsSendingWeeklyReviews = true;
                SendWeeklyReviewsAsync(subplatform).Wait();

                // Reset IsSendingWeeklyReviews flag
                IsSendingWeeklyReviews = false;
            }
        }
        public void CleanupOldRecords(Subplatform subplatform)
        {
            if (!IsCleaning)
            {
                // Set IsCleaning flag
                IsCleaning = true;
                CleanupOldRecordsAsync(subplatform).Wait();

                // Reset IsCleaning flag
                IsCleaning = false;
            }
        }
        public ActionResult GetName(string subplatform)
        {
            Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);

            if (Subplatform is null)
            {
                return(HttpNotFound());
            }

            string name = SubplatformMgr.GetSubplatformSetting(Subplatform.SubplatformId, Setting.Platform.SITE_NAME).Value;

            return(Content(name));
        }
Exemplo n.º 22
0
        public IHttpActionResult ChangeTagMenu([FromBody] MenuViewModel model)
        {
            Subplatform subplatform = SubplatformMgr.GetSubplatform(model.Subplatform);

            Page page = SubplatformMgr.GetPages().Where(p => p.PageName.Equals("Menu")).Where(p => p.SubplatformId == subplatform.SubplatformId).FirstOrDefault();
            Tag  tag  = page.Tags.Find(t => t.Name.ToLower().Equals(model.MenuItem.ToLower()));

            tag.Text = model.MenuText;
            SubplatformMgr.ChangeTag(tag);


            return(Ok());
        }
Exemplo n.º 23
0
        public IHttpActionResult ChangeTagFAQ([FromBody] FAQViewModel model)
        {
            Subplatform subplatform = SubplatformMgr.GetSubplatform(model.Subplatform);

            Page page = SubplatformMgr.GetPages().Where(p => p.PageName.ToLower().Equals("FAQ".ToLower())).Where(p => p.SubplatformId == subplatform.SubplatformId).FirstOrDefault();
            Tag  tag  = page.Tags.Find(t => t.Name.ToLower().Equals(model.FAQitem.ToLower()));

            tag.Text  = model.Question;
            tag.Text2 = model.Answer;
            SubplatformMgr.ChangeTag(tag);

            return(Ok());
        }
Exemplo n.º 24
0
        public ActionResult EditPerson(string subplatform, int id, PersonEditModel personEditModel)
        {
            byte[] image = null;
            if (ModelState.IsValid)
            {
                Person       person       = itemMgr.GetPerson(personEditModel.ItemId);
                Organisation organisation = null;
                if (personEditModel.OrganisationId != null && personEditModel.OrganisationId >= 1)
                {
                    organisation = itemMgr.GetOrganisation((int)personEditModel.OrganisationId);
                    if (organisation == null)
                    {
                        return(RedirectToAction("ItemBeheer", "Item"));
                    }
                }
                Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
                var         iconUrl     = "";
                string      _FileName   = "";
                if (personEditModel.file != null)
                {
                    if (personEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(personEditModel.file.FileName);
                        //var username = personEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Persons/"), newName);
                        //personEditModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Persons/" + newName;
                        //person.IconURL = iconUrl;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(personEditModel.file.InputStream);
                        image        = (byte[])imgCon.ConvertTo(img, typeof(byte[]));
                        person.Image = image;
                    }
                }
                else
                {
                    iconUrl = person.IconURL;
                }

                person.Gemeente        = personEditModel.Gemeente;
                person.IsTrending      = personEditModel.IsTrending;
                person.Organisation    = organisation;
                person.SocialMediaLink = personEditModel.SocialMediaLink;
                person.Name            = personEditModel.Name;
                person.District        = personEditModel.District;
                itemMgr.ChangePerson(person);
                return(RedirectToAction("ItemBeheer", "Item"));
            }
            return(RedirectToAction("ItemBeheer", "Item"));
        }
        public void RemoveItem(int itemId, Subplatform subplatform)
        {
            InitNonExistingRepo();
            Item item = ItemRepo.ReadItem(itemId);

            if (item.SubPlatforms.Contains(subplatform))
            {
                item.SubPlatforms.Remove(subplatform);
                subplatform.Items.Remove(item);

                ItemRepo.UpdateItem(item);
                UowManager.Save();
            }
        }
        public ActionResult IsSubplatformAdmin(string subplatform)
        {
            if (User.Identity.IsAuthenticated)
            {
                Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
                Profile     profile     = accountMgr.GetProfile(User.Identity.GetUserId());
                if (profile.AdminPlatforms.Contains(Subplatform))
                {
                    return(Content("True"));
                }
            }

            return(Content("False"));
        }
Exemplo n.º 27
0
        public ActionResult DeleteItem(string subplatform, int id)
        {
            try
            {
                Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
                itemMgr.RemoveItem(id, Subplatform);

                return(RedirectToAction("ItemBeheer", "Item"));
            }
            catch
            {
                return(RedirectToAction("ItemBeheer", "Item"));
            }
        }
        public ActionResult FAQ(string subplatform)
        {
            ViewBag.Title   = SubplatformMgr.GetSubplatform(subplatform).Name;
            ViewBag.Tag     = "#collapse";
            ViewBag.Control = "collapse";

            Subplatform       Subplatform = SubplatformMgr.GetSubplatform(subplatform);
            IEnumerable <Tag> tags        = Subplatform.Pages.SingleOrDefault(p => p.PageName.Equals("FAQ"))?.Tags;

            if (tags is null || tags.Count() == 0)
            {
                return(HttpNotFound());
            }
            return(View(tags));
        }
Exemplo n.º 29
0
        public ActionResult _ChangeHomePage(string subplatform)
        {
            Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
            List <Tag>  tags        = Subplatform.Pages.SingleOrDefault(p => p.PageName.Equals("Home"))?.Tags;

            HomePageViewModel homePageViewModel = new HomePageViewModel
            {
                BannerTitle    = tags.SingleOrDefault(t => t.Name.Equals("BannerTitle")).Text,
                BannerTextSub1 = tags.SingleOrDefault(t => t.Name.Equals("BannerTextSub1")).Text,
                BannerTextSub2 = tags.SingleOrDefault(t => t.Name.Equals("BannerTextSub2")).Text,
                Call_to_action = tags.SingleOrDefault(t => t.Name.Equals("call-to-action-text")).Text
            };

            return(PartialView(homePageViewModel));
        }
Exemplo n.º 30
0
        public void AddAdmin(int subplatformId, Profile admin)
        {
            InitNonExistingRepo();
            Subplatform subplatform = SubplatformRepo.ReadSubplatform(subplatformId);

            if (subplatform == null)
            {
                throw new Exception("Subplatform with id (" + subplatformId +
                                    ") doesnt exist"); //Subplatform bestaat niet
            }
            subplatform.Admins.Add(admin);
            admin.AdminPlatforms.Add(subplatform);

            SubplatformRepo.UpdateSubplatform(subplatform);
            uowManager.Save();
        }