Example #1
0
        /// <summary>
        /// Creates a new <see cref="Measure"/> that reflects the information in the given <paramref name="element"/>, associates it
        /// with the given <paramref name="target"/>, <paramref name="category"/> and <paramref name="topic"/>, and commits
        /// all changes to the database.
        /// </summary>
        /// <param name="session">NHibernate <see cref="ISession"/></param>
        /// <param name="target">The <see cref="Target"/> that the <see cref="Measure"/> should be associated with</param>
        /// <param name="category">The <see cref="TopicCategory"/> that the <see cref="Measure"/> should be associated with</param>
        /// <param name="topic">The <see cref="Topic"/> that the <see cref="Measure"/> should be associated with</param>
        /// <param name="element">The <see cref="XElement"/> that contains data about this <see cref="Topic"/></param>
        private void AddMeasure(ISession session, Target target, TopicCategory category, Topic topic, XElement element)
        {
            var measureId = string.Format("{0}{1:00}", MeasurePrefix, measurePrefixCount++);
            var measureName = element.Attribute("name").Value;
            var measure = Measure.CreateMeasure(typeof(HospitalMeasure), target, measureId);
            if (measure.MeasureTitle == null) measure.MeasureTitle = new MeasureTitle();

            measure.MeasureTitle.Plain = measureName;
            measure.MeasureTitle.Clinical = measureName;
            measure.MeasureTitle.Policy = measureName;

            measure.NationalBenchmark = null;
            measure.UpperBound = null;
            measure.LowerBound = null;

            if (measure.StatePeerBenchmark != null)
            {
                measure.StatePeerBenchmark.ProvidedBenchmark = null;
            }
            measure.SuppressionDenominator = null;
            measure.SuppressionNumerator = null;

            measure.Description = measureName;
            
            using (var tx = session.BeginTransaction())
            {
                measure.AddTopic(topic);
                topic.Measures.Add(measure);
                session.SaveOrUpdate(measure);
                session.SaveOrUpdate(category);
                session.SaveOrUpdate(topic);
                tx.Commit();
            }
        }
        /// <summary>
        /// 删除文章类别
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public static bool DeleteTopicCategory(TopicCategory topicCategory)
        {
            var cmd = new DataCommand("DeleteTopicCategory");

            cmd.SetParameter("@SysNo", DbType.Int32, topicCategory.SysNo);
            return(cmd.ExecuteNonQuery() > 0);
        }
Example #3
0
        /// <summary>
        /// 创建新闻类别
        /// </summary>
        /// <param name="topicCategory"></param>
        /// <returns></returns>
        public static int InsertTopicCategory(TopicCategory topicCategory, CurrentUser user)
        {
            int sysNo = 0;

            using (ITransaction transaction = TransactionManager.Create())
            {
                bool nameExist = TopicDA.CheckNameIsExist(topicCategory);
                if (nameExist)
                {
                    throw new BusinessException(LangHelper.GetText("类别名称已存在!"));
                }
                string pCategoryID = string.IsNullOrEmpty(topicCategory.ParentCategoryID) ? "" : topicCategory.ParentCategoryID;
                string categoryID  = pCategoryID + "01";

                List <TopicCategory> list = QueryAllTopicCategoryListByParentID(pCategoryID);

                if (list != null && list.Count > 0)
                {
                    TopicCategory tc    = list.OrderByDescending(p => p.SysNo).FirstOrDefault();
                    int           index = int.Parse(tc.CategoryID.Substring(tc.CategoryID.Length - 2, 2)) + 1;
                    categoryID = pCategoryID + (index < 10 ? "0" + index.ToString() : index.ToString());
                }

                topicCategory.ParentCategoryID = pCategoryID;
                topicCategory.CategoryID       = categoryID;
                sysNo = TopicDA.InsertTopicCategory(topicCategory);
                transaction.Complete();
            }
            return(sysNo);
        }
Example #4
0
        /// <summary>
        /// Add a custom topic to the game.
        /// Custom topics can not be asked about by heroines when using the "listen" option, and selecting a custom topic as an answer will always result in failing the prompt. You can only use custom topics when talking to the heroine (speech bubble icon).
        /// If you want your topic to not be obtainable outside of giving it to the player through code, you need to set rarity to <see cref="TopicRarity.Rarity4"/> or higher (unless the category is <see cref="TopicCategory.Love"/>, then it has to be <see cref="TopicRarity.Rarity5"/>. (??? drop tables would make it safe as long as it's not buyable)
        /// </summary>
        /// <param name="topicNo">Unique ID of the topic.
        /// This ID is used in the save file to keep track of owned and used topics, so it has to always be the same between game starts (i.e. use a hardcoded number and never change it).
        /// Topic IDs below 100 are reserved for the base game. For safety it's best to use IDs above 100000. Be careful to not conflict with other plugins!</param>
        /// <param name="topicName">Name of your topic shown on the lists.</param>
        /// <param name="category">Category of your topic. Changes which icon is shown, how it can be obtained and when it is shown.</param>
        /// <param name="rarity">Rarity of your topic. Changes what color background is used and how it can be obtained.</param>
        /// <param name="getAdvScript">Called when player chooses your topic to talk about. It should return a valid ADV event (remember to add Close at the end!) or null if you don't want to display anything. You can use the ADVEditor plugin to create your own scenes. The base game uses different variations of events based on the personality and sometimes relationship of the character you talk to. You can do the same by checking the personality and isNPC parameters.</param>
        /// <param name="getAdvResult">Called after your ADV event from 'getAdvScript' finishes. You can change basic stats with the return value (they will be animated), or do something else (return null if you don't want to change any basic stats).</param>
        /// <returns>Dispose the return value to remove the topic. Warning: This is intended only for development use! This might not remove the topic immediately or fully, and you might need to go back to title menu and load the game again for the changes to take effect. Disposing won't clear the topic from topic inventory or other similar lists.</returns>
        public static IDisposable RegisterTopic(int topicNo, string topicName, TopicCategory category, TopicRarity rarity, GetTopicADVscript getAdvScript, GetTopicADVresult getAdvResult)
        {
            if (StudioAPI.InsideStudio)
            {
                return(Disposable.Empty);
            }

            if (topicNo < 100)
            {
                throw new ArgumentOutOfRangeException(nameof(topicNo), topicNo, "Topic IDs below 100 are reserved for the base game");
            }
            if (topicName == null)
            {
                throw new ArgumentNullException(nameof(topicName));
            }
            if (!Enum.IsDefined(typeof(TopicCategory), category))
            {
                throw new ArgumentOutOfRangeException(nameof(category), category, "Invalid TopicCategory");
            }
            if (!Enum.IsDefined(typeof(TopicRarity), rarity))
            {
                throw new ArgumentOutOfRangeException(nameof(rarity), rarity, "Invalid TopicRarity");
            }

            // As far as I can see RarityName is unused in the game so it doesn't matter what it's set to
            return(RegisterTopic(
                       new Topic.Param
            {
                No = topicNo, Name = topicName, Category = (int)category, Rarity = (int)rarity, RarityName = "Modded"
            },
                       getAdvScript, getAdvResult));
        }
 private bool AddToDB(string parentName, string topicName, string longTitle, string description)
 {
     try
     {
         using (var session = FactoryProvider.SessionFactory.OpenSession())
         {
             MeasureService measureSvc = new MeasureService(session);
             if (topicName == string.Empty)
             {
                 // Row is a topic category.
                 measureSvc.AddTopicCategory(parentName, longTitle, description);
             }
             else
             {
                 // Row is a topic.
                 // Find the topic topic field.
                 TopicCategory category = measureSvc.GetTopicCategory(parentName);
                 // Check to make sure we found one.
                 if (category == null)
                 {
                     // Create a new Topic topic.
                     // longTitle and description are related to the topic, not the parent topic, so just reuse the name.
                     measureSvc.AddTopicCategory(parentName, parentName, parentName);
                 }
                 Topic topic = measureSvc.AddTopic(category, topicName, longTitle, description);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Write(ex);
         return(false);
     }
 }
        public JsonResult MaintainCategory(TopicCategory model)
        {
            model.InUserSysNo   = CurrUser.UserSysNo;       //auth.UserSysNo;
            model.InUserName    = CurrUser.UserDisplayName; // auth.UserDisplayName;
            model.EditUserSysNo = CurrUser.UserSysNo;;      // auth.UserSysNo;
            model.EditUserName  = CurrUser.UserDisplayName; // auth.UserDisplayName;

            if (!model.Priority.HasValue)
            {
                model.Priority = 0;
            }
            if (model.SysNo.HasValue && model.SysNo.Value > 0)//编辑
            {
                TopicService.UpdateTopicCategory(model, CurrUser);
            }
            else//新增
            {
                model.SysNo = TopicService.InsertTopicCategory(model, CurrUser);
            }

            return(Json(new AjaxResult()
            {
                Success = true, Data = model.SysNo
            }));
        }
Example #7
0
        protected virtual void UpdateLocales(TopicCategory topic, TopicCategoryModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(topic,
                                                           x => x.Name,
                                                           localized.Name,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(topic,
                                                           x => x.MetaKeywords,
                                                           localized.MetaKeywords,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(topic,
                                                           x => x.MetaDescription,
                                                           localized.MetaDescription,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(topic,
                                                           x => x.MetaTitle,
                                                           localized.MetaTitle,
                                                           localized.LanguageId);
            }
        }
        /// <summary>
        /// 更新新闻类别
        /// </summary>
        /// <param name="topicCategory"></param>
        /// <returns></returns>
        public static int UpdateTopicCategory(TopicCategory topicCategory)
        {
            DataCommand cmd = new DataCommand("UpdateTopicCategory");

            cmd.SetParameter <TopicCategory>(topicCategory);
            cmd.ExecuteNonQuery();
            return(topicCategory.SysNo.Value);
        }
        public static void SaveTopicCategoryPriority(TopicCategory info)
        {
            DataCommand cmd = new DataCommand("SaveTopicCategoryPriority");

            cmd.SetParameter("@SysNo", DbType.Int32, info.SysNo);
            cmd.SetParameter("@Priority", DbType.Int32, info.Priority);
            cmd.ExecuteNonQuery();
        }
Example #10
0
        /// <summary>
        /// 创建新闻类别
        /// </summary>
        /// <param name="topicCategory"></param>
        /// <returns></returns>
        public static int InsertTopicCategory(TopicCategory topicCategory)
        {
            DataCommand cmd = new DataCommand("InsertTopicCategory");

            cmd.SetParameter <TopicCategory>(topicCategory);
            int result = cmd.ExecuteScalar <int>();

            return(result);
        }
Example #11
0
        public async Task <IActionResult> ViewCommonRoom(int?page, string category)
        {
            ApplicationUser user = await GetCurrentUserAsync();

            House house = await _context.House.SingleOrDefaultAsync(h => h.HouseId == user.HouseId);

            List <TopicCategory> categories = await _context.TopicCategory.ToListAsync();

            List <Topic> topics = new List <Topic>();

            if (category == "All")
            {
                topics = await _context.Topic
                         .Include(t => t.Comments)
                         .ThenInclude(c => c.User)
                         .Include(t => t.User)
                         .ThenInclude(u => u.House)
                         .OrderByDescending(t => t.DateCreated)
                         .Where(t => t.HouseExclusive == true && t.User.HouseId == house.HouseId)
                         .ToListAsync();
            }
            else
            {
                TopicCategory tc = categories
                                   .Where(cat => cat.Label == category)
                                   .SingleOrDefault();

                topics = await _context.Topic
                         .Include(t => t.Comments)
                         .ThenInclude(c => c.User)
                         .Include(t => t.User)
                         .ThenInclude(u => u.House)
                         .OrderByDescending(t => t.DateCreated)
                         .Where(t => t.HouseExclusive == true && t.TopicCategoryId == tc.TopicCategoryId && t.User.HouseId == house.HouseId)
                         .ToListAsync();
            }

            Pager pager = new Pager(topics.Count(), page);

            CommonRoomViewModel viewmodel = new CommonRoomViewModel
            {
                House       = house,
                HouseTopics = topics
                              .Skip((pager.CurrentPage - 1) * pager.PageSize)
                              .Take(pager.PageSize)
                              .ToList(),
                HouseMembers = await _context.ApplicationUser
                               .Where(u => u.HouseId == house.HouseId)
                               .ToListAsync(),
                TopicCategories = categories,
                Pager           = pager,
                Category        = category,
            };


            return(View("CommonRoom", viewmodel));
        }
Example #12
0
        /// <summary>
        /// To the topic.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public static Topic ToTopic(this XElement element, TopicCategory category)
        {
            var result = new Topic(category, element.Attribute("name").Value)
            {
                LongTitle   = element.Attribute("longTitle").Value,
                Description = element.Attribute("description").Value
            };

            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TopicViewModel"/> class.
 /// </summary>
 /// <param name="ts">The ts.</param>
 public TopicViewModel(TopicCategory ts)
     : base(null)
 {
     _oldTopicCategoryName = ts.Name;
     IsSubTopic            = false;
     TopicCategory         = ts;
     LoadChildren(ts.Topics);
     AddSubtopicCommand       = new DelegateCommand <Object>(OnAddSubtopic, CanExecuteAdd);
     CancelSubtopicCommand    = new DelegateCommand <object>(OnCancel);
     EnableAddSubtopicCommand = new DelegateCommand(OnEnableAddSubtopic);
     EnableTopicEditCommand   = new DelegateCommand(OnEnableEdit);
 }
Example #14
0
        public virtual void InsertTopicCategory(TopicCategory topicCategory)
        {
            if (topicCategory == null)
            {
                throw new ArgumentNullException(nameof(topicCategory));
            }

            _topicCategoryRepository.Insert(topicCategory);

            //event notification
            _eventPublisher.EntityInserted(topicCategory);
        }
Example #15
0
		public TopicView(TopicCategory? category, TopicType topic)
		{
			this.category = category;
			this.topic = topic;
			var metadata = topic.Metadata();
			if (metadata.Background != null)
				AddControl(new Background(metadata.Background, metadata.BackgroundPalette));
			AddTopicControls((dynamic)topic.Metadata().Subject);
			AddControl(new Button(5, 5, 30, 14, "OK", metadata.Scheme, Font.Normal, OnOk));
			AddControl(new Button(5, 40, 30, 14, "<<", metadata.Scheme, Font.Normal, OnPrevious));
			AddControl(new Button(5, 75, 30, 14, ">>", metadata.Scheme, Font.Normal, OnNext));
		}
Example #16
0
        public virtual void DeleteTopicCategory(TopicCategory topic)
        {
            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            _topicCategoryRepository.Delete(topic);

            //event notification
            _eventPublisher.EntityDeleted(topic);
        }
Example #17
0
        /// <summary>
        /// Obtains a <see cref="Topic"/> instance that reflects the information in the given <paramref name="element"/>. If no instance exists in the database,
        /// a new instance is created and returned. The new instance is not saved to the database by this method.
        /// </summary>
        /// <param name="session">NHibernate <see cref="ISession"/></param>
        /// <param name="category">The <see cref="TopicCategory"/> that the <see cref="Topic"/> should be associated with</param>
        /// <param name="element">The <see cref="XElement"/> that contains data about this <see cref="Topic"/></param>
        /// <returns>A <see cref="Topic"/> instance</returns>
        private Topic GetTopic(ISession session, TopicCategory category, XElement element)
        {
            var name = element.Attribute("name").Value;
            var result = session.Query<Topic>().FirstOrDefault(t => t.Name == name);
            if (result != null)
                return result;

            result = new Topic(category, name)
            {
                LongTitle = element.Attribute("longTitle").Value,
                Description = element.Attribute("description").Value
            };
            return result;
        }
Example #18
0
        public TopicList(TopicCategory category)
        {
            this.category = category;

            AddControl(new Border(10, 32, 256, 180, ColorScheme.Green, Backgrounds.Title, 0));
            AddControl(new Label(24, Label.Center, "SELECT ITEM", Font.Large, ColorScheme.Yellow));

            var topics = GameState.Current.Data.GetTopics(category);
            var selectionColor = Palette.GetPalette(12).GetColor(230);
            AddControl(new ListView<TopicType>(50, 40, 14, topics, ColorScheme.Aqua, selectionColor, OnSelectTopic)
                .AddColumn(224, Alignment.Center, item => item.Metadata().Name));

            AddControl(new Button(166, 48, 224, 16, "OK", ColorScheme.Green, Font.Normal, OnOk));
        }
 /// <summary>
 /// Saves the or update topic.
 /// </summary>
 /// <param name="category">The category.</param>
 public void SaveOrUpdateTopic(TopicCategory category)
 {
     WaitCursor.Show();
     Save(category, (o, e) =>
     {
         if (e == null)
         {
             ReloadTopicsMeasures(category.Id);
         }
         else
         {
             EventAggregator.GetEvent <ErrorNotificationEvent>().Publish(e);
         }
     });
 }
Example #20
0
        public static bool CheckNameIsExist(TopicCategory topicCategory)
        {
            DataCommand cmd;

            if (topicCategory.SysNo > 0)
            {
                cmd = new DataCommand("CheckTopicCategoryNameIsExistForUpdate");
            }
            else
            {
                cmd = new DataCommand("CheckTopicCategoryNameIsExistForInsert");
            }
            cmd.SetParameter <TopicCategory>(topicCategory);
            return(cmd.ExecuteScalar <int>() > 0);
        }
Example #21
0
        /// <summary>
        /// 删除文章类别
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public static bool DeleteTopicCategory(TopicCategory topicCategory)
        {
            topicCategory = TopicDA.LoadTopicCategory(topicCategory.SysNo.Value);
            //查询当前分类下是否有关联文章
            List <TopicInfo> topicList = TopicDA.LoadTopicInfoListByCategory(topicCategory.SysNo.Value);

            if (topicList != null && topicList.Count > 0)
            {
                throw new BusinessException("当前类别下有关联文章,不能删除此类别!");
            }
            else
            {
                bool result = true;
                result = TopicDA.DeleteTopicCategory(topicCategory);
                return(result);
            }
        }
Example #22
0
        public void CreateNewTopicInNewCategory()
        {
            var ctx = ContextHelper.GetForumContext();

            if (!ctx.Database.Exists())
            {
                ctx.Database.Initialize(true);
            }

            var newCat = new TopicCategory
            {
                Title = "New Cat",
                Desc  = "Test Cat",
            };

            var newTopic = new Topic
            {
                Theme    = "New Theme",
                Category = newCat
            };

            var newPost = new Post
            {
                Author = new User
                {
                    Name = "TestUser"
                },
                Topic = newTopic,
                Text  = "ExamplePost",
                Date  = DateTime.Now
            };

            newTopic.Posts.Add(newPost);
            newCat.Topics.Add(newTopic);

            ctx.TopicCategories.Add(newCat);
            ctx.SaveChanges();

            var cat   = ContextHelper.GetForumContext().TopicCategories.FirstOrDefault(x => x.Title == "New Cat");
            var topic = cat.Topics.FirstOrDefault(x => x.Theme == "New Theme");
            var post  = topic.Posts.First();

            Assert.IsNotNull(cat);
            Assert.IsNotNull(topic);
            Assert.IsNotNull(post);
        }
        public ActionResult TopicCategoryInfo(int sysNo, string MasterName)
        {
            TopicCategory info = new TopicCategory();

            if (sysNo > 0)
            {
                info = TopicService.LoadTopicCategory(sysNo) ?? new Smoke.Entity.TopicCategory();
                if (info.SysNo <= 0)
                {
                    info.MasterName = MasterName;
                }
            }
            else
            {
                info.MasterName = MasterName;
            }
            return(PartialView("~/Views/Topic/_TopicCategoryInfo.cshtml", info));
        }
Example #24
0
        public List <TopicCategory> GetTopicCategories()
        {
            Query   = "SELECT * FROM TopicCategories";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            List <TopicCategory> topicCategories = new List <TopicCategory>();

            while (Reader.Read())
            {
                TopicCategory aTopicCategory = new TopicCategory();
                aTopicCategory.TopicCategoryId   = Convert.ToInt32(Reader["TopicCategoryId"]);
                aTopicCategory.TopicCategoryName = Reader["TopicCategoryName"].ToString();
                aTopicCategory.CountCategory     = Convert.ToInt32(Reader["CountCategory"]);
                topicCategories.Add(aTopicCategory);
            }
            Reader.Close();
            Connection.Close();
            return(topicCategories);
        }
        /// <summary>
        /// Deletes the topic category.
        /// </summary>
        /// <param name="category">The category.</param>
        public void DeleteTopicCategory(TopicCategory category)
        {
            WaitCursor.Show();

            foreach (var topic in category.Topics.ToArray())
            {
                DeleteTopic(topic, false);
            }

            Delete(category, (r, ex) =>
            {
                if (ex == null)
                {
                    ReloadTopicsMeasures(0);
                }
                else
                {
                    EventAggregator.GetEvent <ErrorNotificationEvent>().Publish(ex);
                }
            });
        }
        /// <summary>
        /// 删除类别
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DeleteCategory(string id)
        {
            int sysno = 0;

            if (!string.IsNullOrEmpty(id) && int.TryParse(id, out sysno))
            {
                TopicCategory tc = new TopicCategory();
                tc.SysNo = sysno;
                TopicService.DeleteTopicCategory(tc);
                return(Json(new AjaxResult()
                {
                    Success = true
                }));
            }
            else
            {
                return(Json(new AjaxResult()
                {
                    Success = false, Message = "传入参数错误."
                }));
            }
        }
Example #27
0
        //The return value is the first topic ID.  All other topics are assuming to be sequencial after that number.
        private long AddTopics()
        {
            var topicCategory = new TopicCategory {
                Name = SpiritualGiftsDiscoveryQuizData.TopicCategory
            };

            _databaseContext.TopicCategories.Add(topicCategory);
            _databaseContext.SaveChanges();

            long firstTopicId = -1;

            foreach (var topicData in SpiritualGiftsDiscoveryQuizData.Topics)
            {
                var topic = new Topic {
                    Name = topicData.Item1, Description = topicData.Item2, TopicCategoryId = topicCategory.Id
                };
                _databaseContext.Topics.Add(topic);
                _databaseContext.SaveChanges();

                if (firstTopicId < 0)
                {
                    firstTopicId = topic.Id;
                }

                foreach (var supportingScriptureText in topicData.Item3)
                {
                    var supportingScripture = new SupportingScripture {
                        ScriptureReference = supportingScriptureText, TopicId = topic.Id
                    };
                    _databaseContext.SupportingScriptures.Add(supportingScripture);
                }
                _databaseContext.SaveChanges();
            }

            return(firstTopicId);
        }
Example #28
0
 /// <summary>
 /// 更新新闻类别
 /// </summary>
 /// <param name="topicCategory"></param>
 /// <returns></returns>
 public static int UpdateTopicCategory(TopicCategory topicCategory, CurrentUser user)
 {
     return(TopicDA.UpdateTopicCategory(topicCategory));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TopicViewModel"/> class.
 /// </summary>
 /// <param name="topicName">Name of the topic.</param>
 public TopicViewModel(string topicName)
     : base(null)
 {
     TopicCategory = new TopicCategory(topicName);
 }
Example #30
0
        public virtual TopicCategoryModel PrepareTopicCategoryModel(TopicCategoryModel model, TopicCategory topic, bool excludeProperties = false)
        {
            Action <TopicCategoryLocalizedModel, int> localizedModelConfiguration = null;

            if (topic != null)
            {
                //fill in model values from the entity
                model = model ?? topic.ToModel <TopicCategoryModel>();

                //define localized model configuration action
                localizedModelConfiguration = (locale, languageId) =>
                {
                    locale.Name            = _localizationService.GetLocalized(topic, entity => entity.Name, languageId, false, false);
                    locale.MetaKeywords    = _localizationService.GetLocalized(topic, entity => entity.MetaKeywords, languageId, false, false);
                    locale.MetaDescription = _localizationService.GetLocalized(topic, entity => entity.MetaDescription, languageId, false, false);
                    locale.MetaTitle       = _localizationService.GetLocalized(topic, entity => entity.MetaTitle, languageId, false, false);
                };
            }

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration);
            }

            model.TopicCategories.Add(new TopicCategory()
            {
                Id = 0, Name = "ROOT"
            });
            _topicService
            .GetAllTopicCategories()
            .Where(x => x.Id != topic?.Id)
            .ToList()
            .ForEach(x => model.TopicCategories.Add(x));

            return(model);
        }
Example #31
0
 public List<TopicType> GetTopics(TopicCategory category)
 {
     return AvailableTopics.Where(topic => topic.Metadata().Category == category).ToList();
 }
Example #32
0
        public async Task <IActionResult> ViewGreatHall(int?page, string category, string search)
        {
            ApplicationUser user = await GetCurrentUserAsync();

            List <House> houses = await _context.House.ToListAsync();

            List <TopicCategory> categories = await _context.TopicCategory.ToListAsync();

            List <Topic> topics = new List <Topic>();

            if (search != null)
            {
                topics = await _context.Topic
                         .Include(t => t.Comments)
                         .ThenInclude(c => c.User)
                         .Include(t => t.User)
                         .ThenInclude(u => u.House)
                         .OrderByDescending(t => t.DateCreated)
                         .Where(t => t.HouseExclusive == false && t.Title.Contains(search) || t.Content.Contains(search))
                         .ToListAsync();
            }
            else if (category == "All")
            {
                topics = await _context.Topic
                         .Include(t => t.Comments)
                         .ThenInclude(c => c.User)
                         .Include(t => t.User)
                         .ThenInclude(u => u.House)
                         .OrderByDescending(t => t.DateCreated)
                         .Where(t => t.HouseExclusive == false)
                         .ToListAsync();
            }
            else
            {
                TopicCategory tc = categories.Where(cat => cat.Label == category).SingleOrDefault();
                topics = await _context.Topic
                         .Include(t => t.Comments)
                         .ThenInclude(c => c.User)
                         .Include(t => t.User)
                         .ThenInclude(u => u.House)
                         .OrderByDescending(t => t.DateCreated)
                         .Where(t => t.HouseExclusive == false && t.TopicCategoryId == tc.TopicCategoryId)
                         .ToListAsync();
            }



            Pager pager = new Pager(topics.Count(), page);

            GreatHallViewModel viewmodel = new GreatHallViewModel
            {
                User = user,
                NonExclusiveTopics = topics
                                     .Skip((pager.CurrentPage - 1) * pager.PageSize)
                                     .Take(pager.PageSize)
                                     .ToList(),
                Houses          = houses,
                TopicCategories = categories,
                Pager           = pager,
                Category        = category
            };


            return(View("GreatHall", viewmodel));
        }