本文整理汇总了C#中TopicModel类的典型用法代码示例。如果您正苦于以下问题:C# TopicModel类的具体用法?C# TopicModel怎么用?C# TopicModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TopicModel类属于命名空间,在下文中一共展示了TopicModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(TopicModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
if (ModelState.IsValid)
{
if (!model.IsPasswordProtected)
{
model.Password = null;
}
var topic = new Topic()
{
Body = model.Body,
IncludeInSitemap = model.IncludeInSitemap,
IsPasswordProtected = model.IsPasswordProtected,
MetaDescription = model.MetaDescription,
MetaKeywords = model.MetaKeywords,
MetaTitle = model.MetaTitle,
Password = model.Password,
SystemName = model.SystemName,
Title = model.Title
};
_topicService.InsertTopic(topic);
//locales
UpdateLocales(topic, model);
SuccessNotification("Chủ đề đã được tạo.");
return continueEditing ? RedirectToAction("Edit", new { id = topic.Id }) : RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
return View(model);
}
示例2: Create
public ActionResult Create(TopicModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
if (ModelState.IsValid)
{
if (!model.IsPasswordProtected)
{
model.Password = null;
}
var topic = model.ToEntity();
_topicService.InsertTopic(topic);
//locales
UpdateLocales(topic, model);
NotifySuccess(_localizationService.GetResource("Admin.ContentManagement.Topics.Added"));
return continueEditing ? RedirectToAction("Edit", new { id = topic.Id }) : RedirectToAction("List");
}
// If we got this far, something failed, redisplay form
PrepareStoresMappingModel(model, null, true);
return View(model);
}
示例3: Create
public ActionResult Create(TopicModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
if (ModelState.IsValid)
{
if (!model.IsPasswordProtected)
{
model.Password = null;
}
var topic = model.ToEntity();
_topicService.InsertTopic(topic);
//search engine name
model.SeName = topic.ValidateSeName(model.SeName, topic.Title ?? topic.SystemName, true);
_urlRecordService.SaveSlug(topic, model.SeName, 0);
//Stores
SaveStoreMappings(topic, model);
//locales
UpdateLocales(topic, model);
SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Topics.Added"));
return continueEditing ? RedirectToAction("Edit", new { id = topic.Id }) : RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
//templates
PrepareTemplatesModel(model);
//Stores
PrepareStoresMappingModel(model, null, true);
return View(model);
}
示例4: Create
public ActionResult Create(TopicModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
//decode description
model.Body = HttpUtility.HtmlDecode(model.Body);
foreach (var localized in model.Locales)
localized.Body = HttpUtility.HtmlDecode(localized.Body);
if (ModelState.IsValid)
{
if (!model.IsPasswordProtected)
{
model.Password = null;
}
var topic = model.ToEntity();
_topicService.InsertTopic(topic);
//locales
UpdateLocales(topic, model);
SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Topics.Added"));
return continueEditing ? RedirectToAction("Edit", new { id = topic.Id }) : RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
return View(model);
}
示例5: UpdateLocales
protected void UpdateLocales(Topic topic, TopicModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Title,
localized.Title,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Body,
localized.Body,
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);
//search engine name
var seName = topic.ValidateSeName(localized.SeName, localized.Title, false);
_urlRecordService.SaveSlug(topic, seName, localized.LanguageId);
}
}
示例6: UpdateLocales
public void UpdateLocales(Topic topic, TopicModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Title,
localized.Title,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Body,
localized.Body,
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);
}
}
示例7: Create
public ActionResult Create()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
var model = new TopicModel();
//locales
AddLocales(_languageService, model.Locales);
return View(model);
}
示例8: PrepareTemplatesModel
protected virtual void PrepareTemplatesModel(TopicModel model)
{
if (model == null)
throw new ArgumentNullException("model");
var templates = _topicTemplateService.GetAllTopicTemplates();
foreach (var template in templates)
{
model.AvailableTopicTemplates.Add(new SelectListItem
{
Text = template.Name,
Value = template.Id.ToString()
});
}
}
示例9: Create
public ActionResult Create()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
var model = new TopicModel();
//Stores
PrepareStoresMappingModel(model, null, false);
//locales
AddLocales(_languageService, model.Locales);
model.TitleTag = "h1";
return View(model);
}
示例10: AddTopic
public ActionResult AddTopic(string content)
{
// TODO: validate received data from form
if (content.Length > 3)
{
TopicModel topic = new TopicModel()
{
Content = content,
IsActive = true,
};
db.Topics.Add(topic);
db.SaveChanges();
}
return PartialView("_TopicsList", db.Topics.ToList());
}
开发者ID:TuononenP,项目名称:collaborative-shared-desktop-online-conference-software,代码行数:18,代码来源:TopicsController.cs
示例11: PrepareStoresMappingModel
private void PrepareStoresMappingModel(TopicModel model, Topic topic, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (topic != null)
{
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(topic);
}
else
{
model.SelectedStoreIds = new int[0];
}
}
}
示例12: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(TopicModel model, Topic topic, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (topic != null)
{
model.SelectedStoreIds = topic.Stores.ToArray();
}
}
}
示例13: Edit
public ActionResult Edit(int id)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
var topic = _topicService.GetTopicById(id);
if (topic == null)
//No topic found with the specified id
return RedirectToAction("List");
var model = new TopicModel()
{
Body = topic.Body,
Id = topic.Id,
IncludeInSitemap = topic.IncludeInSitemap,
IsPasswordProtected = topic.IsPasswordProtected,
MetaDescription = topic.MetaDescription,
MetaKeywords = topic.MetaKeywords,
MetaTitle = topic.MetaTitle,
Password = topic.Password,
SystemName = topic.SystemName,
Title = topic.Title
};
model.Url = Url.RouteUrl("Topic", new { SystemName = topic.SystemName }, "http");
//locales
AddLocales(_languageService, model.Locales, (locale, languageId) =>
{
locale.Title = topic.GetLocalized(x => x.Title, languageId, false, false);
locale.Body = topic.GetLocalized(x => x.Body, languageId, false, false);
locale.MetaKeywords = topic.GetLocalized(x => x.MetaKeywords, languageId, false, false);
locale.MetaDescription = topic.GetLocalized(x => x.MetaDescription, languageId, false, false);
locale.MetaTitle = topic.GetLocalized(x => x.MetaTitle, languageId, false, false);
});
return View(model);
}
示例14: Edit
public ActionResult Edit(TopicModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
return AccessDeniedView();
var topic = _topicService.GetTopicById(model.Id);
if (topic == null)
//No topic found with the specified id
return RedirectToAction("List");
if (!model.IsPasswordProtected)
{
model.Password = null;
}
if (ModelState.IsValid)
{
topic = model.ToEntity(topic);
_topicService.UpdateTopic(topic);
//search engine name
model.SeName = topic.ValidateSeName(model.SeName, topic.Title ?? topic.SystemName, true);
_urlRecordService.SaveSlug(topic, model.SeName, 0);
//Stores
SaveStoreMappings(topic, model);
//locales
UpdateLocales(topic, model);
SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Topics.Updated"));
if (continueEditing)
{
//selected tab
SaveSelectedTabIndex();
return RedirectToAction("Edit", new {id = topic.Id});
}
return RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
model.Url = Url.RouteUrl("Topic", new { SeName = topic.GetSeName() }, "http");
//templates
PrepareTemplatesModel(model);
//Store
PrepareStoresMappingModel(model, topic, true);
return View(model);
}
示例15: SaveStoreMappings
protected virtual void SaveStoreMappings(Topic topic, TopicModel model)
{
var existingStoreMappings = _storeMappingService.GetStoreMappings(topic);
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.Id))
{
//new store
if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0)
_storeMappingService.InsertStoreMapping(topic, store.Id);
}
else
{
//remove store
var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id);
if (storeMappingToDelete != null)
_storeMappingService.DeleteStoreMapping(storeMappingToDelete);
}
}
}