public async Task UpdateCategoryAsync(ContentCategory category) { _db.Update(category); await _db.SaveChangesAsync(); _eventService.TriggerContentChanged(this); }
public void RegisterOpenFile(DockContent content, ContentCategory category) { if (!IsHidden && !ChildForms.ContainsKey(content)) { content.FormClosed += new FormClosedEventHandler(ChildForms_FormClosed); ListViewItem item = new ListViewItem(content.Text); item.ToolTipText = content.ToolTipText; item.Tag = content; ColumnHeader hdr = null; switch (category) { case ContentCategory.Archives: hdr = archiveListHeader; break; case ContentCategory.Meshes: hdr = meshListHeader; break; case ContentCategory.Animations: hdr = animationListHeader; break; case ContentCategory.Others: hdr = otherListHeader; break; } hdr.ListView.Items.Add(item); hdr.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); tabControlQuickAccess.SelectTabWithoutLosingFocus((TabPage)hdr.ListView.Parent); ChildForms.Add(content, item); } }
private ContentCategory CreateContentCategory() { ContentCategory cc = new ContentCategory(); cc.Name = "Organizing"; return(cc); }
public IList <Content> Search(string text, ContentCategory cc, ContentType ct, int userId) { ICriteria crit = GetSearchCriteria(text, cc, userId); crit.Add(Expression.Eq("Type", ct)); return(crit.List <Content>()); }
public ViewResult Create(ContentCategory item) { _Repo.Add(item); _Repo.SaveChange(); ViewData["Title"] = "Create a new portal"; return(View(_Repo.Create())); }
public async Task <ContentCategory> AddCategoryAsync(string value, string type) { // Ensure it is in title case. value = value.Trim().ToTitleCase(); string slug = value.ToSeoUrl(); int counter = 1; while (await _db.ContentCategories.CountAsync(cc => cc.Slug == slug && cc.ContentType == type) > 0) { slug = value.ToSeoUrl() + "-" + counter; counter++; } ContentCategory category = _db.ContentCategories.SingleOrDefault(t => t.DisplayName == value && t.ContentType == type); if (category == null) { category = new ContentCategory() { DisplayName = value, ContentType = type, Slug = slug }; _db.ContentCategories.Add(category); await _db.SaveChangesAsync(); _eventService.TriggerContentChanged(this); } return(category); }
public static string[] GetContentTypes(this ContentCategory contentCategory) { return(contentCategory switch { ContentCategory.Image => new[] { "image/gif", "image/x-icon", "image/jpeg", "image/png", "image/apng", "image/bmp", "image/tiff", "image/svg+xml", "image/webp" }, ContentCategory.Text => new[] { "text/plain", "application/json", "text/xml", "text/html" }, ContentCategory.Video => new[] { "video/mp4" }, _ => Array.Empty <string>(), });
public virtual async Task <IActionResult> EditCategory(int id, string type) { ContentCategory model = await _content.GetCategoryByIdAsync(id); model.Categories = _contentCategoryCache.TopLevel(type); return(View("_Blade_Category", model)); }
public void PreSavingModifiedDataProcessing() { _entry.CreateDate = _testDate; var contentCategory = new ContentCategory(); var subContentCategory = new ContentSubcategory(); var existingEntry = new Entry { Title = Resources.ModifiedEntryTitle, Description = Resources.ModifiedEntryDescription, Content = Resources.ModifiedEntryContent, ImageUrl = Resources.ModifiedEntryImgUrl }; Thread.Sleep(1000); _entryManageService.PreSavingModifiedDataProcessing(_account, _entry, contentCategory, subContentCategory, existingEntry); Assert.AreEqual(_entry.LastModifiedBy, _account); Assert.Greater(_entry.LastModification, _testDate); Assert.IsNotEmpty(_entry.Paragraphs); StringAssert.Contains(Resources.ModificationSuffix, _entry.Title); StringAssert.Contains(Resources.ModificationSuffix, _entry.Description); StringAssert.Contains(Resources.ModificationSuffix, _entry.Content); StringAssert.Contains(Resources.ModificationSuffix, _entry.ImageUrl); }
private static void AddContentCategoryAll() { using var context = new InsuranceContext(); var categories = new ContentCategory[] { new ContentCategory { Id = 1, CategoryName = "Electronics" }, new ContentCategory { Id = 2, CategoryName = "Clothing" }, new ContentCategory { Id = 3, CategoryName = "Kitchen" }, }; foreach (var category in categories) { var entity = context.ContentCategory.Add(category); entity.State = EntityState.Added; } context.SaveChanges(); }
public override void OnShow() { Gamestate_Gameplay gs = (Gamestate_Gameplay)GameObject.FindGameObjectWithTag("Gamestate").gameObject.GetComponent <Gamestate_Gameplay> (); if (gs) { for (int i = 0; i < gs.categories.Length; i++) { Transform trCategory = panelContainer.transform.Find("cc." + i); if (trCategory) { ContentCategory cat = (ContentCategory)gs.categories[i]; Transform trIconContainer = trCategory.Find("Sprite"); for (int j = 0; j < cat.contents.Length; j++) { Transform trItem = trIconContainer.transform.Find("Item" + (j + 1)); if (trItem) { int iAmount = 0; if (PlayerPrefs.HasKey("cc." + i + "." + j)) { iAmount = PlayerPrefs.GetInt("cc." + i + "." + j); } GameManager.SetNGUILabel(trItem.transform.Find("Label Amount"), iAmount.ToString()); } } GameManager.SetNGUILabel(trCategory.Find("Label Reward"), cat.bonus + " Energy " + cat.bonusEXP + " exp"); ActivateColliders(trCategory.gameObject, true); } } } }
private NewsSource convertApiSource2Source(NewsApiSource source, int index) { ContentCategory category = ds.GetContentCategoryByName(source.Category); Language language = ds.GetLanguageByCode(source.Language); Country country = ds.GetCountryByCode(source.Country); NewsSource result = new NewsSource(); result.Id = index; result.NewsProviderId = ProviderDef.Id; result.NewsProvider = ProviderDef.Name; result.NewsSourceId = source.Id; result.NewsSourceDescription = source.Description; result.NewsSourceUrl = source.Url; result.NewsSourceSmallLogoUrl = source.UrlsToLogos.Small; result.NewsSourceMediumLogoUrl = source.UrlsToLogos.Medium; result.NewsSourceLargeLogoUrl = source.UrlsToLogos.Large; result.ContentCategoryId = category.Id; result.ContentCategory = category.Name; result.CountryId = country != null ? country.Id : null; result.CountryCode = source.Country; result.CountryName = country != null ? country.Name : null; result.LanguageId = language != null ? language.Id : null; result.LanguageCode = source.Language; result.LanguageName = language != null ? language.Name : null; return(result); }
private void FilterContentPublishedCriteria(ICriteria crit, ContentCategory cc, ContentType ct) { crit.Add(Expression.Eq("Category", cc)); crit.Add(Expression.Eq("Type", ct)); crit.Add(Expression.Eq("Status", ContentPublishedStatus.Enabled)); Conjunction c1 = new Conjunction(); c1.Add(Expression.Ge("ScheduleFrom", DateTime.Today)); c1.Add(Expression.IsNull("ScheduleTo")); Conjunction c2 = new Conjunction(); c2.Add(Expression.IsNull("ScheduleFrom")); c2.Add(Expression.IsNull("ScheduleTo")); Conjunction c3 = new Conjunction(); c3.Add(Expression.Ge("ScheduleFrom", DateTime.Today)); c3.Add(Expression.Le("ScheduleTo", DateTime.Today)); Disjunction d = new Disjunction(); d.Add(c1); d.Add(c2); d.Add(c3); crit.Add(d); crit.AddOrder(new Order("CreatedOn", false)); crit.AddOrder(new Order("ScheduleFrom", false)); }
public ActionResult Create(ContentCategory contentCategory) { if (ModelState.IsValid) { //Xử lý MetaTitle if (!string.IsNullOrEmpty(contentCategory.Name)) { contentCategory.MetaTitle = StringHelper.ToUnsignString(contentCategory.Name); } var dao = new ContentCategoryDao(); long id = dao.Insert(contentCategory); if (id > 0) { SetAlert("Create a new content category successfully.", "success"); return(RedirectToAction("Index", "ContentCategory")); } else { ModelState.AddModelError("", "Create a new Content category failed."); return(RedirectToAction("Create", "ContentCategory")); } } SetParentIDViewBag(); return(View(contentCategory)); }
/// <summary> /// Sets the extraData to be sent to the ContentCategory using a Bundle. /// </summary> /// <param name="category">The ContentCategory that some information is to be set, in the AttachPanel.</param> /// <param name="extraData">The AttachPanel sends some information using a Bundle.</param> /// <feature>http://tizen.org/feature/attach_panel</feature> /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category.</exception> /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception> /// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate the memory fails.</exception> /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception> /// <since_tizen> 4 </since_tizen> public void SetExtraData(ContentCategory category, Bundle extraData) { if (extraData == null) { CheckException(Interop.AttachPanel.ErrorCode.InvalidParameter); } if (IsAttachPanelSupported() == false) { CheckException(Interop.AttachPanel.ErrorCode.NotSupported); } if (IsInitialized() == false) { CheckException(Interop.AttachPanel.ErrorCode.NotInitialized); } var bundle = IntPtr.Zero; if (extraData != null) { bundle = extraData.SafeBundleHandle.DangerousGetHandle(); } var err = Interop.AttachPanel.SetExtraData(s_attachPanel, (int)category, bundle); CheckException(err); }
public virtual async Task <Response> EditCategory(ContentCategory model) { try { if (model.ParentCategoryId.HasValue) { if (model.ParentCategoryId == model.Id) { throw new Exception("You cannot set the parent to be the same category!"); } IEnumerable <ContentCategory> thisAndChildren = _contentCategoryCache.GetThisAndChildren(model.Id); if (thisAndChildren.Select(c => c.Id).ToList().Contains(model.ParentCategoryId.Value)) { throw new Exception("You cannot set the parent to be a child of this category!"); } } await _content.UpdateCategoryAsync(model); return(new Response(true, $"The category has been saved.")); } catch (Exception ex) { return(await ErrorResponseAsync <BaseContentController>($"Error updating a content category.", ex)); } }
public void RegisterOpenFile(DockContent content, ContentCategory category) { if (!IsHidden && !ChildForms.ContainsKey(content)) { content.FormClosed += new FormClosedEventHandler(ChildForms_FormClosed); ListViewItem item = new ListViewItem(content.Text); item.ToolTipText = content.ToolTipText; item.Tag = content; ColumnHeader hdr = null; switch (category) { case ContentCategory.Archives: hdr = archiveListHeader; break; case ContentCategory.Meshes: hdr = meshListHeader; break; case ContentCategory.Animations: hdr = animationListHeader; break; case ContentCategory.Others: hdr = otherListHeader; break; } hdr.ListView.Items.Add(item); hdr.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); tabControlQuickAccess.SelectTabWithoutLoosingFocus((TabPage)hdr.ListView.Parent); ChildForms.Add(content, item); } }
public JsonResult Create(string data) { JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); ContentCategory model = javaScriptSerializer.Deserialize <ContentCategory>(data); bool status = false; string mess = String.Empty; if (model.ID == 0) { var dao = db.Create(model); if (dao == 1) { status = true; mess = "Thêm mới thành công"; } else { status = false; mess = "Tên đã tồn tại"; } } else { status = db.Update(model); mess = "Cập nhập thất bại"; } return(Json(new { status = status, mess = mess })); }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create ContentCategoryRemoteService instance. ContentCategoryRemoteService service = (ContentCategoryRemoteService)user.GetService( DfaService.v1_20.ContentCategoryRemoteService); string contentCategoryName = _T("INSERT_CONTENT_CATEGORY_NAME_HERE"); // Create content category structure. ContentCategory contentCategory = new ContentCategory(); contentCategory.id = 0; contentCategory.name = contentCategoryName; try { // Create content category. ContentCategorySaveResult contentCategorySaveResult = service.saveContentCategory(contentCategory); // Display content category id. Console.WriteLine("Content category with id \"{0}\" was created.", contentCategorySaveResult.id); } catch (Exception e) { Console.WriteLine("Failed to add content category. Exception says \"{0}\"", e.Message); } }
private ICriteria GetCriteria(ContentCategory cc, ContentType ct) { ICriteria crit = Session.CreateCriteria(typeof(ContentPublished)); FilterContentPublishedCriteria(crit, cc, ct); return(crit); }
//[HasCredential(RoleID = "ADD_USER")] public ActionResult Create(ContentCategory contentCategory) { if (ModelState.IsValid) { var dao = new ContentCategoryDao(); var a = new ContentCategory(); a.Name = contentCategory.Name; a.CreateDate = Convert.ToDateTime(DateTime.UtcNow.ToLocalTime()); a.MetaTitle = StringHelper.ToUnsignString(a.Name); a.Status = Convert.ToBoolean(true); var id = dao.Insert(a); if (id > 0) { SetAlert("Thêm thành công", "success"); ViewBag.Success = "Thêm thành công"; contentCategory = new ContentCategory(); return(RedirectToAction("Index", "ContentCategory")); } else { ModelState.AddModelError("", "Thêm user ko thành công"); } } return(View(contentCategory)); }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create ContentCategoryRemoteService instance. ContentCategoryRemoteService service = (ContentCategoryRemoteService) user.GetService( DfaService.v1_19.ContentCategoryRemoteService); string contentCategoryName = _T("INSERT_CONTENT_CATEGORY_NAME_HERE"); // Create content category structure. ContentCategory contentCategory = new ContentCategory(); contentCategory.id = 0; contentCategory.name = contentCategoryName; try { // Create content category. ContentCategorySaveResult contentCategorySaveResult = service.saveContentCategory(contentCategory); // Display content category id. Console.WriteLine("Content category with id \"{0}\" was created.", contentCategorySaveResult.id); } catch (Exception e) { Console.WriteLine("Failed to add content category. Exception says \"{0}\"", e.Message); } }
public ContentPublished Get(ContentCategory cc, ContentType ct) { ICriteria crit = GetCriteria(cc, ct); crit.SetMaxResults(1); return(crit.UniqueResult <ContentPublished>()); }
protected void btnDelete_Click(object sender, EventArgs e) { ContentCategory item = ContentCategory.Get(guidItemID); item.Delete(); Response.Redirect(SiteFilename.CategoryIndexURL); }
public IList <ContentPublishedSection> ListSections(ContentCategory cc, ContentType ct) { ICriteria crit = Session.CreateCriteria(typeof(ContentPublishedSection)); ICriteria critContent = crit.CreateCriteria("ContentPublished"); FilterContentPublishedCriteria(critContent, cc, ct); return(crit.List <ContentPublishedSection>()); }
/// <summary> /// Insert one ContentCategory to database /// </summary> /// <param name="entity"></param> /// <returns></returns> public long Insert(ContentCategory entity) { entity.CreatedDate = entity.ModifiedDate = DateTime.Now; entity.Status = true; db.ContentCategories.Add(entity); db.SaveChanges(); return(entity.ID); }
private ICriteria GetCriteria(ContentCategory cc, ContentType ct) { ICriteria crit = Session.CreateCriteria(typeof(ContentPublished)); FilterContentPublishedCriteria(crit, cc, ct); crit.SetCacheable(true); crit.SetCacheRegion("Content"); return(crit); }
public async Task DeleteCategoryAsync(int categoryId) { ContentCategory category = await _db.ContentCategories.FirstOrDefaultAsync(c => c.Id == categoryId); _db.Entry(category).State = EntityState.Deleted; await _db.SaveChangesAsync(); _eventService.TriggerContentChanged(this); }
public virtual IActionResult CreateCategory(string type) { ContentCategory model = new ContentCategory() { ContentType = type, Categories = _contentCategoryCache.TopLevel(type) }; return(View("_Blade_Category", model)); }
public static void DeleteData() { ContentCategory contentCategory = new ContentCategory(); BasePageActionModel <ContentCategory> baseAction = new BasePageActionModel <ContentCategory>(_dataPath, _logPath); ReturnOutput returnOutput = new ReturnOutput(); var result = baseAction.DeleteData("", ""); Console.WriteLine(result); }
public bool Edit(ContentCategory contentCategory) { if (contentCategory == null) { return(false); } var editProductCategory = _contentCategoryAdminRepository.EditContentCategory(contentCategory); return(editProductCategory); }
public void ShowDockContent(DockContent content, DockContent defaultDock, ContentCategory category) { try { content.FormClosed += content_FormClosed; List <DockContent> typeList; Type type = content.GetType(); if (!DockContents.TryGetValue(type, out typeList)) { typeList = new List <DockContent>(); DockContents.Add(type, typeList); } typeList.Add(content); var handler = DockContentAdded; if (handler != null) { handler(this, new DockContentEventArgs(content)); } if (defaultDock == null) { content.Show(this.dockPanel, DockState.Float); } else { content.Show(defaultDock.Pane, null); if (((defaultDock == DockFiles) || (defaultDock == DockEditors)) && !defaultDock.IsHidden) { defaultDock.Hide(); } } SetDocking(content, dockingToolStripMenuItem.Checked); if (category != ContentCategory.None) { ((FormQuickAccess)DockQuickAccess).RegisterOpenFile(content, category); } foreach (Control c in content.Controls) { if (c is MenuStrip) { MenuStrip ms = (MenuStrip)c; InstallStatusLineHandler(ms.Items); } } } catch (Exception ex) { Utility.ReportException(ex); } }
public async Task<IHttpActionResult> PostContentCategory(ContentCategory contentCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } await repository.AddAsync(contentCategory); return CreatedAtRoute("DefaultApi", new { id = contentCategory.ContentCategoryID }, contentCategory); }
public Episode() { News = new ContentCategory(); Tools = new ContentCategory(); Novices = new ContentCategory(); Videos = new ContentCategory(); Blogs = new ContentCategory(); Events = new ContentCategory(); People = new PeopleCategory(); Humor = new ContentCategory(); }
public ContentCategory AddCategory(string name, int? parentCategoryId) { ContentCategory category = new ContentCategory { CategoryName = name.Trim(), Key = name.Trim().ToUrlKey(), ParentCategoryId = parentCategoryId, CreatedDate =DateTime.Now, UpdatedDate = DateTime.Now, Status = EntityStatuses.Actived.ToString() }; this.Categories.InsertOnSubmit(category); Commit(); return category; }
// PUT api/ContentCategories/5 public async Task<IHttpActionResult> PutContentCategory(int id, ContentCategory contentCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != contentCategory.ContentCategoryID) { return BadRequest(); } await repository.UpdateAsync(contentCategory, contentCategory.ContentCategoryID); return StatusCode(HttpStatusCode.NoContent); }
/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); String contentCategoryName = _T("INSERT_CONTENT_CATEGORY_NAME_HERE"); // Create the content category. ContentCategory contentCategory = new ContentCategory(); contentCategory.Name = contentCategoryName; // Insert the content category. ContentCategory result = service.ContentCategories.Insert(contentCategory, profileId).Execute(); // Display the new content category ID. Console.WriteLine("Content category with ID {0} was created.", result.Id); }
public Navigation Create(Navigation nv) { nv.CreatedDate = DateTime.Now; nv.UpdatedDate = DateTime.Now; nv.DisplayOrder = 1; if(nv.ParentId.HasValue && nv.ParentId.Value ==0) nv.ParentId = new Nullable<int>(); nv.Status = EntityStatuses.Actived.ToString(); if (nv.Component == SiteModules.Article.ToString()) { if (!nv.CategoryId.HasValue || nv.CategoryId.Value == 0) { ContentCategory cat = new ContentCategory() { CategoryName = nv.Name, CreatedDate = DateTime.Now, IsFeatured = false, Key = nv.Name.ToUrlKey(), ParentCategoryId = new Nullable<int>(), Status = EntityStatuses.Actived.ToString(), UpdatedDate = DateTime.Now }; Navigation parent = GetItem(nv.ParentId.HasValue? nv.ParentId.Value: 0); if (parent != null && parent.Component == SiteModules.Article.ToString()) { cat.ParentCategoryId = parent.CategoryId; } nv.Controller = DBNL.App.Models.Statics.Controllers.Article.ToString(); nv.Action = DBNL.App.Models.Statics.Actions.Category.ToString(); nv.Area = ""; Categories.InsertOnSubmit(cat); Commit(); nv.CategoryId = cat.ID; } } Navigations.InsertOnSubmit(nv); Commit(); Reorder(nv.Id, ReorderMethods.Down.ToString()); return nv; }
private void Delete(ContentCategory cat) { if (cat.Status == EntityStatuses.Deleted.ToString()) return; foreach (var item in cat.ContentCategories) { Delete(item); } //foreach(var content in cat.Contents.Where(p=>p.Status != EntityStatuses.Deleted.ToString()) { // content.Status = //} var query = Navigations.Where(p => p.CategoryId == cat.ID && p.Component == SiteModules.Article.ToString() ).AsEnumerable(); foreach (var nav in query) { nav.Status = EntityStatuses.Deleted.ToString(); Commit(); } cat.Status = EntityStatuses.Deleted.ToString(); Commit(); }
public void Create(ContentCategory category) { string key = category.CategoryName.ToUrlKey(); var item = GetByKey(key); if (item != null) { key += category.GetHashCode().ToString(); } category.CreatedDate = DateTime.Now; category.UpdatedDate = DateTime.Now; category.Key = key; category.Status = EntityStatuses.Actived.ToString(); Categories.InsertOnSubmit(category); Commit(); UpdateFeaturedCategory(); }
public ContentAttribute(string resourceName, ContentCategory contentCategory, LoadingPriority loadingPriority = LoadingPriority.Immediate) { this.ContentCategory = contentCategory; this.LoadingPriority = loadingPriority; this.ResourceName = resourceName; }
public void ShowDockContent(DockContent content, DockContent defaultDock, ContentCategory category) { try { content.FormClosed += content_FormClosed; List<DockContent> typeList; Type type = content.GetType(); if (!DockContents.TryGetValue(type, out typeList)) { typeList = new List<DockContent>(); DockContents.Add(type, typeList); } typeList.Add(content); var handler = DockContentAdded; if (handler != null) { handler(this, new DockContentEventArgs(content)); } if (defaultDock == null) { content.Show(this.dockPanel, DockState.Float); } else { content.Show(defaultDock.Pane, null); if (((defaultDock == DockFiles) || (defaultDock == DockEditors)) && !defaultDock.IsHidden) { defaultDock.Hide(); } } if (category != ContentCategory.None) { ((FormQuickAccess)DockQuickAccess).RegisterOpenFile(content, category); } } catch (Exception ex) { Utility.ReportException(ex); } }
public void Update(int id, ContentCategory category) { var original = GetById(id); original.CategoryName = category.CategoryName; original.Key = category.CategoryName.ToUrlKey(); original.IsFeatured = category.IsFeatured; original.ShowOnHP = category.ShowOnHP; original.Status =category.Status; original.UpdatedDate = DateTime.Now; if(category.ParentCategoryId.HasValue) original.ContentCategory1 = GetById(category.ParentCategoryId.Value); Commit(); UpdateFeaturedCategory(); }
public ContentCategorySaveResult saveContentCategory(ContentCategory contentCategory) { object[] results = this.Invoke("saveContentCategory", new object[] {contentCategory}); return ((ContentCategorySaveResult) (results[0])); }