public ActionResult Delete(CategoryDto item) { using(_conversation.SetAsCurrent()) { Category itemMapped = _mapper.Map<CategoryDto, Category>(item); _repository.Delete(itemMapped); _conversation.Flush(); return Json(new{ success = true }); } }
public ActionResult Create(CategoryDto item) { using(_conversation.SetAsCurrent()) { Category itemMapped = _mapper.Map<CategoryDto, Category>(item); ValidationHelpers.AddErrorsToModelState(ModelState, _validator.Validate(itemMapped), "item"); if(ModelState.IsValid) { _repository.Create(itemMapped); _conversation.Flush(); } return Json(new{ success = true }); } }
public IHttpActionResult PutCategory(int id, CategoryDto category) { if (!ModelState.IsValid) { return BadRequest(ModelState); } string oldName = _db.Categories .FirstOrDefault(c => c.Id == id) .Name; _db.Categories .FirstOrDefault(c => c.Id == id) .Name = category.Name; _db.SaveChanges(); return this.Ok(string.Format("Category: \"{0}\" was renamed to \"{1}\"", oldName, category.Name)); }
public IHttpActionResult PostCategory(CategoryDto category) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (_db.Categories.Any(c => c.Name == category.Name)) { return BadRequest("Duplicated category"); } _db.Categories.AddOrUpdate(new Category() { Name = category.Name }); _db.SaveChanges(); return this.Ok(string.Format("Category: {0} was succefully added", category.Name)); }
private static CategoryDto InitCategoryDtoFromHttpPost(NameValueCollection form, CategoryDto category) { //form.BindToEntity(category); category.Keywords = form["Keywords"]; category.PageTitle = form["PageTitle"]; category.Tag = form["Tag"]; category.Name = form["Name"]; category.SortNumber = int.Parse(form["SortNumber"]); category.Description = form["Description"]; category.Location = form["Location"]; category.Icon = form["Icon"]; if (!String.IsNullOrEmpty(category.Keywords)) { category.Keywords = Regex.Replace(category.Keywords, ",|\\s|\\|", ","); } //设置模板 string categoryTplPath = form["CategoryTemplate"], archiveTplPath = form["CategoryArchiveTemplate"]; //如果设置了栏目视图路径,则保存 category.CategoryTemplate = categoryTplPath; //如果设置了文档视图路径,则保存 category.CategoryArchiveTemplate = archiveTplPath; return(category); }
/// <summary> /// 创建文档 /// </summary> public void Create_GET() { object data; string tpls, nodesHtml, //栏目JSON extendFieldsHtml = "", //属性Html extendItemsHtml = ""; Module module; int categoryId = int.Parse(base.Request["category.id"] ?? "1"); //分类ID CategoryDto category = ServiceCall.Instance.SiteService.GetCategory(base.SiteId, categoryId); //获取模板视图下拉项 StringBuilder sb2 = new StringBuilder(); //模板目录 DirectoryInfo dir = new DirectoryInfo( String.Format("{0}templates/{1}", AppDomain.CurrentDomain.BaseDirectory, Settings.TPL_MultMode ? "" : base.CurrentSite.Tpl + "/" )); EachClass.EachTemplatePage( dir, sb2, TemplatePageType.Custom, TemplatePageType.Archive ); tpls = sb2.ToString(); sb2.Remove(0, sb2.Length); //获取该模块栏目JSON数据 //categoryJSON = CmsLogic.Category.GetJson(m.ID); ServiceCall.Instance.SiteService.HandleCategoryTree(this.SiteId, 1, (_category, level) => { sb2.Append("<option value=\"").Append(_category.ID.ToString()).Append("\""); if (_category.ID == category.ID) { sb2.Append(" selected=\"selected\""); } sb2.Append(">"); for (int i = 0; i < level; i++) { sb2.Append(CmsCharMap.Dot); } sb2.Append(_category.Name).Append("</option>"); }); nodesHtml = sb2.ToString(); //============= 拼接模块的属性值 ==============// /* * //========= 统计tab =============// * sb.Append("<ul class=\"dataExtend_tabs\">"); * foreach (DataExtend e in extends) * { * sb.Append("<li><span>").Append(e.Name).Append("</span></li>"); * } * sb.Append("</ul>"); * * extendItemsHtml = sb.ToString(); * * sb.Capacity = 1000; * sb.Remove(0, sb.Length); */ //======== 生成值 =============// StringBuilder sb = new StringBuilder(500); sb.Append("<div class=\"dataextend_item\">"); foreach (IExtendField p in category.ExtendFields) { sb.Append("<dl><dt>").Append(p.Name).Append(":</dt><dd>"); if (p.Type == ((int)PropertyUI.Text).ToString()) { sb.Append("<input type=\"text\" class=\"tb_normal\" field=\"extend_").Append(p.ID.ToString()) .Append("\" value=\"").Append(p.DefaultValue).Append("\"/>"); } else if (p.Type == ((int)PropertyUI.Upload).ToString()) { sb.Append("<input type=\"text\" disabled=\"disabled\" class=\"tb_normal\" id=\"extend_").Append(p.ID.ToString()) .Append("\" field=\"extend_").Append(p.ID.ToString()) .Append("\" value=\"").Append(p.DefaultValue).Append("\"/><span id=\"upload_") .Append(p.ID.ToString()).Append("\">选择文件</span>") .Append("<script type=\"text/javascript\">cms.propertyUpload(") .Append("'upload_").Append(p.ID.ToString()).Append("','extend_").Append(p.ID.ToString()).Append("');</script>"); } sb.Append("</dd></dl>"); /*<p><span class="txt">标签:</span> * <span class="input"><input type="text" name="tags" size="30"/></span> * <span class="msg"></span></p> */ } sb.Append("</div>"); extendFieldsHtml = sb.ToString(); // extendFieldsHtml = "<div style=\"color:red;padding:20px;\">所选栏目模块不包含任何自定义属性,如需添加请到模块管理-》属性设置</div>"; object json = new { Thumbnail = CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto }; data = new { extendFieldsHtml = extendFieldsHtml, extendItemsHtml = extendItemsHtml, thumbPrefix = CmsVariables.Archive_ThumbPrefix, nodes = nodesHtml, url = Request.Url.PathAndQuery, tpls = tpls, json = JsonSerializer.Serialize(json) }; base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_Create), data); }
public IActionResult UpdateCategory([FromForm] CategoryDto categoryDto) { var result = _categoryService.UpdateCategory(categoryDto); return(Ok(result)); }
static async Task Main(string[] args) { var client = new HttpClient(); //credential string email = "*****@*****.**"; string password = "******"; //fech auth token var token = await client.PostFromJsonAsync(_fetchTokenUrl, new { email = email, password = Base64Encode(password) }); $"Fetch auth token :{token}".Print(); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); //Country var allCountries = await client.GetFromJsonAsync <ODataWrapper <List <CountryDto> > >(_coutryUrl); $"Fetch {allCountries.Value.Count }countiers ".Print(); //--------category-------- var allCategories = await client.GetFromJsonAsync <ODataWrapper <List <CategoryDto> > >(_categoryUrl); //add category var newCategory = new CategoryDto() { Name = "SampleCategory" }; var addedCategory = await client.PostFromJsonAsync <CategoryDto>(_categoryUrl, newCategory); $"Add new category '{addedCategory.Name}' with Id {addedCategory.Id}".Print(); addedCategory.Name = "new sample name"; //update var updatedCategory = await client.PutFromJsonAsync <CategoryDto>(_categoryUrl, addedCategory); $"Update category '{updatedCategory.Name}' with id {updatedCategory.Id}".Print(); //category by id var category = await client.GetFromJsonAsync <CategoryDto>($"{_categoryUrl}/{addedCategory.Id}"); //delete category await client.DeleteFromJsonAsync($"{_categoryUrl}?key={addedCategory.Id}"); $"Delete category with id {addedCategory.Id}".Print(); //--------Products------ var products = await client.GetFromJsonAsync <ODataWrapper <List <ProductDto> > >(_productUrl); $"Fetch {products.Value.Count} products".Print(); var product = addedProduct.Value.FirstOrDefault(); var cat = allCategories.Value.FirstOrDefault(); var productCategory = new ProductCategoryDto() { CategoryId = cat.Id }; //Add new category to product var updatedProduct = await client.PostFromJsonAsync <ProductDto>($"{_createCategoryProduct}/({product.Id})", productCategory); $"Add category to product id {product.Id}".Print(); }
public static Category ToEntity(this CategoryDto categoryDto) { return(categoryDto.MapTo <CategoryDto, Category>()); }
public void TestCategory() { Rendu.Clear(); addToOc(ActionsEnum.Travail.ToString(), ServiceEnum.Category.ToString()); var item = new CategoryDto(); item.Balance = 7.0; item.Color = "AA"; item.Name = "MyCategory"; var Categories = CategoryService.GetAllCategories(false, false); addToOc(ActionsEnum.GetList.ToString(),string.Format(TEMPLATEMessage,ObjectType.itemCount.ToString(), Categories.Value.Count)); if (Categories.Value.Count > 0) { foreach (var dto in Categories.Value) { CategoryService.DeleteCategorieById(dto.Id); addToOc(ActionsEnum.Delete.ToString(),string.Format(TEMPLATEMessage,ObjectType.itemId.ToString(), dto.Id)); } Categories = CategoryService.GetAllCategories(false, false); addToOc(ActionsEnum.GetList.ToString(),string.Format(TEMPLATEMessage, ObjectType.itemCount.ToString(), Categories.Value.Count)); } var addedCategory = CategoryService.CreateCategory(item); addToOc(ActionsEnum.Insert.ToString(),string.Format(TEMPLATEMessage, ObjectType.itemId.ToString(), addedCategory.Value.Id)); var category = CategoryService.GetCategoryById(addedCategory.Value.Id, false, false).Value; addToOc(ActionsEnum.Get.ToString(),string.Format(TEMPLATEMessage, ObjectType.itemId.ToString(), category.Id)); category.Name = "LALALALALA"; var updatedCategory = CategoryService.UpdateCategory(category); addToOc(ActionsEnum.Update.ToString(), string.Format(TEMPLATEMessageOnUpdate, ServiceEnum.Category.ToString(), ObjectType.itemName.ToString(), updatedCategory.Value.Name, addedCategory.Value.Name)); }
public IActionResult Update(CategoryDto categoryDto) { var category = _categoryService.Update(_mapper.Map <Category>(categoryDto)); return(NoContent()); }
public Boolean insertCategory(CategoryDto dto) { Category obj = Category.createCategory(dto.CategoryId, dto.CategoryName, dto.CategoryDescription); CategoryManager mgr = new CategoryManager(); return mgr.insertCategory(obj); }
public CategoryDto selectCategoryById(CategoryDto dto) { CategoryManager mgr = new CategoryManager(); Category obj = new Category(); obj.CategoryId = dto.CategoryId; obj = mgr.selectCategoryById(obj); if (obj != null) { return CategoryDto.createCategoryDTO(obj); } else { return null; } }
public void TestTransaction() { Rendu.Clear(); addToOc(ActionsEnum.Travail.ToString(), ServiceEnum.Transaction.ToString()); #region Nouvelle Categorie, Nouveau Account var newCategory = new CategoryDto(); newCategory.Balance = 7.0; newCategory.Color = "AA"; newCategory.Name = "MyCategory"; var newAccount = new AccountDto(); newAccount.Balance = 7.0; newAccount.BankName = "AA"; newAccount.Name = "MyAccount"; #endregion #region Nettoyage Base var Categories = CategoryService.GetAllCategories(false, false); addToOc(ActionsEnum.GetList.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Category.ToString(), ObjectType.itemCount.ToString(), Categories.Value.Count)); var Accounts = AccountService.GetAllAccounts(false, false); addToOc(ActionsEnum.GetList.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Account.ToString(), ObjectType.itemCount.ToString(), Accounts.Value.Count)); if (Categories.Value.Count > 0) { foreach (var dto in Categories.Value) { CategoryService.DeleteCategorieById(dto.Id); addToOc(ActionsEnum.Delete.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Category.ToString(), ObjectType.itemId.ToString(), dto.Id)); } Categories = CategoryService.GetAllCategories(false, false); addToOc(ActionsEnum.GetList.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Category.ToString(), ObjectType.itemCount.ToString(), Categories.Value.Count)); } if (Accounts.Value.Count > 0) { foreach (var dto in Accounts.Value) { AccountService.DeleteAccountById(dto.Id); addToOc(ActionsEnum.Delete.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Account.ToString(), ObjectType.itemId.ToString(), dto.Id)); } Accounts = AccountService.GetAllAccounts(false, false); addToOc(ActionsEnum.GetList.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Account.ToString(), ObjectType.itemCount.ToString(), Accounts.Value.Count)); } #endregion #region Ajout Category, Account var addedCategory = CategoryService.CreateCategory(newCategory); addToOc(ActionsEnum.Insert.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Category.ToString(), ObjectType.itemId.ToString(), addedCategory.Value.Id)); var addedAccount = AccountService.CreateAccount(newAccount); addToOc(ActionsEnum.Insert.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Account.ToString(), ObjectType.itemId.ToString(), addedAccount.Value.Id)); #endregion #region Ajout 2 transactions, same account, 1 with the category var newTransaction = new TransactionDto(); newTransaction.Name = "First Transaction !"; newTransaction.Balance = 40.0; newTransaction.Account = addedAccount.Value; newTransaction.Category = addedCategory.Value; var newTransaction2 = new TransactionDto(); newTransaction2.Name = "Second Transaction !"; newTransaction2.Balance = 40.0; newTransaction2.Account = addedAccount.Value; var addedtransaction = TransactionService.CreateTransaction(newTransaction); addToOc(ActionsEnum.Insert.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Transaction.ToString(), ObjectType.itemName.ToString(), addedtransaction.Value.Name)); var addedtransaction2 = TransactionService.CreateTransaction(newTransaction); addToOc(ActionsEnum.Insert.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Transaction.ToString(), ObjectType.itemName.ToString(), addedtransaction2.Value.Name)); #endregion #region get des listes par account et par category var listebyAccount = TransactionService.GetTransactionsByAccountId(addedAccount.Value.Id, false, false); addToOc(ActionsEnum.GetList.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Transaction.ToString(), ObjectType.itemCount.ToString(), listebyAccount.Value.Count)); var listebyCategory = TransactionService.GetTransactionsByCategoryId(addedCategory.Value.Id, false, false); addToOc(ActionsEnum.GetList.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Transaction.ToString(), ObjectType.itemCount.ToString(), listebyCategory.Value.Count)); #endregion var gettedTrans = TransactionService.GetTransactionById(addedtransaction.Value.Id, false, false).Value; addToOc(ActionsEnum.Get.ToString(), string.Format(TEMPLATEMessagedifferService, ServiceEnum.Transaction.ToString(), ObjectType.itemName.ToString(), gettedTrans.Name)); gettedTrans.Name = "MODIFIED"; var updatedCategory = TransactionService.UpdateTransaction(gettedTrans); addToOc(ActionsEnum.Update.ToString(), string.Format(TEMPLATEMessageOnUpdate, ServiceEnum.Transaction.ToString(), ObjectType.itemName.ToString(), updatedCategory.Value.Name, addedtransaction.Value.Name)); }
public async Task <IActionResult> Create(CategoryDto categoryDto) { var response = await _categoryService.CreateAsync(categoryDto); return(CreateActionResultInstance(response)); }
public IActionResult Update(CategoryDto categoryDto) { _categoryService.Update(_mapper.Map <Category>(categoryDto)); return(RedirectToAction("Index")); }
public static void MappingCategory(this CategoryDto CategoryDto, Category category) { category.Id = CategoryDto.Id; category.Name = CategoryDto.Name; }
/// <summary> /// 根据名称获取分类tag /// </summary> /// <param name="name"></param> /// <returns></returns> protected string GetCategory(string name) { CategoryDto c = ServiceCall.Instance.SiteService.GetCategoryByName(this.SiteId, name); return(c.ID <= 0 ? "" : c.Tag); }
public async Task CreateAsync(CategoryDto dto) { var entity = _mapper.Map <Category>(dto); await _categoryRepository.CreateAsync(entity); }
public static Category ToEntity(this CategoryDto model, Category destination) { return(model.MapTo(destination)); }
public async Task <IActionResult> Get([FromRoute] CategoryQueries query) { CategoryDto category = await _dispatcher.QueryAsync <CategoryDto>(query); return(Ok(category)); }
public void Store(CategoryDto categoryDto) { var category = new Category(categoryDto.name); CategoryRepository.Add(category); }
public virtual string GetCategory(CategoryDto category, int pageIndex, params object[] args) { string tplId = this.GetCategoryTemplateId(category); // //todo: /news/news/news/时候仍然能访问 // //用于当前的模板共享数据 //Cms.Context.Items["category.tag"] = category.Tag; Cms.Context.Items["category.path"] = category.Path; Cms.Context.Items["module.id"] = category.ModuleId; Cms.Context.Items["page.index"] = pageIndex; bool isFirstPage = pageIndex == 1; string title; if (pageIndex == 1) { if (!String.IsNullOrEmpty(category.PageTitle)) { title = category.PageTitle; } else { title = String.Format("{0}_{1}", category.Name, _site.Title); } } else { switch (_site.Language) { case Languages.Zh_CN: title = String.Format("- 第" + pageIndex.ToString() + "页"); break; default: case Languages.En: title = String.Format("- page " + pageIndex.ToString()); break; } title = String.Format("{0}{1}_{2}", category.Name, title, _site.Title); } //解析模板 return(PageUtility.Require(tplId, page => { page.AddVariable("site", _site); page.AddVariable("page", new PageVariable { Title = title, SubTitle = _site.Title, Keywords = category.Keywords, Description = category.Description, PageIndex = pageIndex }); page.AddVariable("category", category); page.AddVariable("module", new Module { ID = category.ModuleId }); })); }
public async Task <IActionResult> AddArticle([FromForm] CategoryDto categoryDto) { var result = await _categoryService.AddCategory(categoryDto); return(Ok(result)); }
public virtual string GetArchive(ArchiveDto archive, params object[] args) { #region 属性 /* * //验证密码 * PropertyBLL pbll = new PropertyBLL(); * var a = pbll.GetProperty(category.ModuleID, "pwd"); * if (a != null) * { * var json = archive.GetPropertiesJson(); * string key = json.GetValue("pwd"); * if (!String.IsNullOrEmpty(key)) * { * string requireKey = HttpContext.Current.Request.QueryString["pwd"]; * if (requireKey != key) * { * HttpContext.Current.Response.Write("<div style='margin:0 auto;padding:30px 0'>请输入密码:<input type='text'/><input type='button' value='提交' onclick=\"location.replace(location.href+'?pwd='+this.previousSibling.value)\"/></div>"); * HttpContext.Current.Response.End(); * } * * } * }*/ #endregion //获取模板ID string tplId = this.GetArchiveTemplateId(archive); CategoryDto category = archive.Category; //用于当前的模板共享数据 Cms.Context.Items["archive.id"] = archive.Id; Cms.Context.Items["category.path"] = category.Path; Cms.Context.Items["module.id"] = category.ModuleId; //解析模板 string html = PageUtility.Require(tplId, page => { page.AddVariable("site", this._site); PageArchive pageArchive = new PageArchive(archive); page.AddVariable("archive", pageArchive); page.AddVariable("category", category); page.AddVariable("module", new Module { ID = category.ModuleId }); page.AddVariable("page", new PageVariable { Title = String.Format("{0}_{1}_{2}", archive.Title, category.Name, _site.Title), SubTitle = _site.Title, Keywords = archive.Tags, Description = pageArchive.Outline.Replace("\"", String.Empty) }); }); return(html); }
/// <summary> /// 文档评论 /// </summary> public void Comment_GET() { string commentListHtml; int id = int.Parse(base.Request["archive.id"]); ArchiveDto archive = ServiceCall.Instance.ArchiveService.GetArchiveById(this.SiteId, id); bool desc = base.Request["desc"] == "true"; CategoryDto category = archive.Category; StringBuilder sb = new StringBuilder(); DataTable table = CmsLogic.Comment.GetArchiveComments(archive.StrId, desc); int i = 1; bool isGuest = false; string nickName, content, avatar; Match match; foreach (DataRow dr in table.Rows) { //筛选出游客的昵称和内容 if (dr["memberid"].ToString() != "0") { nickName = dr["nickname"].ToString(); content = dr["content"].ToString(); avatar = dr["avatar"].ToString(); isGuest = false; } else { content = dr["content"].ToString(); match = Regex.Match(content, "\\(u:'(?<user>.+?)'\\)"); if (match != null) { nickName = match.Groups["user"].Value; content = Regex.Replace(content, "\\(u:'(.+?)'\\)", String.Empty); } else { nickName = "游客"; } avatar = "?module=file&action=guestavatar"; isGuest = true; } sb.Append("<p class=\"comment\"><img src=\"").Append(avatar).Append("\" /><span class=\"time\">") .Append(String.Format("{0:yyyy-MM-dd HH:mm:ss}", dr["createdate"])).Append("</span><span class=\"details\"><a href=\"#\">") .Append(nickName).Append("</a><br />").Append(content).Append("</span><span class=\"floor\">") .Append(i.ToString()).Append("楼</span><span class=\"control\"><a href=\"javascript:;\" onclick=\"remove(this,'").Append(dr["id"].ToString()).Append("')\">删除</a></span></p>"); ++i; } commentListHtml = sb.Length == 0 ? "暂无评论!" : sb.ToString(); object data = new { archiveID = archive.StrId, archiveTitle = archive.Title, author = archive.Author, publishDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", archive.CreateDate), commentListHtml = commentListHtml }; base.RenderTemplate(ResourceMap.CommentList, data); }
public void AddNewCategory(CategoryDto category) { _categoryService.Insert(category); }
// Rename the category private void RenameCategory(object sender, RoutedEventArgs e) { CategoryDto source = ((Button)sender).DataContext as CategoryDto; ViewModel.RenameCategoryAction(source); }
} //esempio di dato pubblico senza metodo di set public static async Task <IValidator <CategoryDto, Category> > CreateCategoryAsync(CategoryDto categoryDto, IEnumerable <IRuleSpecification <CategoryDto> > rules) { var validator = new Validator <CategoryDto, Category>(rules); await validator.ExecuteCheckAsync(categoryDto, new Category()); //Qui potrebbero essere inserite delle rules a livello di codice da richiamare sempre //(oppure prima del controllo delle rules dinamiche) if (!validator.IsValid) { return(validator); } validator.ValidatedObject.SetName(categoryDto.Name); validator.ValidatedObject.SetDescription(categoryDto.Description); validator.ValidatedObject.Note = categoryDto.Note; return(validator); }
/// <summary> /// 创建栏目 /// </summary> public void Update_GET() { string categoryOptions, //栏目下拉列表 categoryTypeOptions, //栏目类型下拉列表 archiveTpl, archiveTplOpts, categoryTplOpts; StringBuilder sb = new StringBuilder(); //获取栏目 int categoryId = int.Parse(base.Request["category_id"]); CategoryDto category = ServiceCall.Instance.SiteService.GetCategory(this.SiteId, categoryId); //检验站点 if (!(category.Id > 0)) { return; } //获取父栏目pleft int pId = 0; CategoryDto pc = ServiceCall.Instance.SiteService.GetParentCategory(this.SiteId, category.Lft); if (pc.Id > 0) { pId = pc.Id; } /* * //加载模块 * foreach (var m in CmsLogic.Module.GetSiteAvailableModules(this.SiteId)) * { * if (!m.IsDelete) * { * sb.Append("<option value=\"").Append(m.ID.ToString()).Append("\">").Append(m.Name).Append("</option>"); * } * } * categoryTypeOptions = sb.ToString(); * sb.Remove(0, sb.Length); * */ //加载栏目(排除当前栏目) ServiceCall.Instance.SiteService.HandleCategoryTree(this.SiteId, 1, (c, level, isLast) => { if (c.Lft != categoryId) { sb.Append("<option value=\"").Append(c.Id.ToString()).Append("\">"); for (var i = 0; i < level; i++) { sb.Append(CmsCharMap.Dot); } sb.Append(c.Name).Append("</option>"); } }); categoryOptions = sb.ToString(); //获取模板视图下拉项 sb.Remove(0, sb.Length); //模板目录 DirectoryInfo dir = new DirectoryInfo(String.Format("{0}templates/{1}/", Cms.PyhicPath, base.CurrentSite.Tpl)); IDictionary <String, String> names = Cms.TemplateManager.Get(base.CurrentSite.Tpl).GetNameDictionary(); EachClass.EachTemplatePage(dir, dir, sb, names, TemplatePageType.Archive); archiveTplOpts = sb.ToString(); sb.Remove(0, sb.Length); EachClass.EachTemplatePage(dir, dir, sb, names, TemplatePageType.Category); categoryTplOpts = sb.ToString(); //获取栏目及文档模板绑定 var categoryTpl = String.IsNullOrEmpty(category.CategoryTemplate) ? "" : category.CategoryTemplate; archiveTpl = String.IsNullOrEmpty(category.CategoryArchiveTemplate) ? "" : category.CategoryArchiveTemplate; object data = new { entity = JsonSerializer.Serialize(category), url = base.Request.RawUrl, categories = categoryOptions, //categoryTypes = categoryTypeOptions, parentId = pId, categoryTplPath = categoryTpl, archiveTplPath = archiveTpl, category_tpls = categoryTplOpts, archive_tpls = archiveTplOpts }; base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Category_EditCategory), data); }
public IResponseDTO Update([FromBody] CategoryDto model) { var result = ServicesCategory.Update(model); return(result); }
public async Task <IActionResult> Create(CategoryDto categoryDto) { await _categoryService.AddAsync(_mapper.Map <Category>(categoryDto)); return(RedirectToAction("Index")); }
public IResponseDTO SaveNew([FromBody] CategoryDto model) { var result = ServicesCategory.Insert(model); return(result); }
public async Task <IActionResult> Save(CategoryDto dto) { var newCategory = await _categoryService.AddAsync(_mapper.Map <Category>(dto)); return(Created(string.Empty, _mapper.Map <CategoryDto>(newCategory))); }
private static CategoryDto CreateCategoryFromInput() { CategoryDto category = new CategoryDto(); Clear(); WriteLine("Press Esc to when done editing.".PadRight(Program.WindowWidth, '#')); WriteLine("".PadRight(Program.WindowWidth, '#')); OptionsPrinter(" "); Coordinates categoryPropertiesCoordinates = new Coordinates(ContentCursorPosLeft, ContentCursorPosTop); category.PrintProperties(categoryPropertiesCoordinates); void EraseOldText(int length) { int cursorLeft = CursorLeft; int cursorTop = CursorTop; Write(" ".PadRight(length)); SetCursorPosition(cursorLeft, cursorTop); } List <string> propertyNames = categoryPropertiesCoordinates.SavedCoordinates.Keys.ToList(); int moveCursor = 0; bool shouldNotExit = true; int propertysValuesSpacing = 10; ConsoleKeyInfo consoleKeyInfo; bool correktKey; while (shouldNotExit) { SetCursorPosition(categoryPropertiesCoordinates.SavedCoordinates[propertyNames[moveCursor]].X + propertysValuesSpacing, categoryPropertiesCoordinates.SavedCoordinates[propertyNames[moveCursor]].Y); do { consoleKeyInfo = ReadKey(true); correktKey = !(consoleKeyInfo.Key == ConsoleKey.UpArrow || consoleKeyInfo.Key == ConsoleKey.DownArrow || consoleKeyInfo.Key == ConsoleKey.Escape || consoleKeyInfo.Key == ConsoleKey.Enter); } while (correktKey); switch (consoleKeyInfo.Key) { case ConsoleKey.UpArrow: if (moveCursor > 0) { moveCursor--; } break; case ConsoleKey.DownArrow: if (moveCursor < propertyNames.Count - 1) { moveCursor++; } break; case ConsoleKey.Enter: string currentProperty = propertyNames[moveCursor]; if (!currentProperty.ToUpper().Contains("ID")) { EraseOldText(100); string input = ReadLine(); foreach (var property in category.GetType().GetProperties()) { if (property.Name == currentProperty) { property.SetValue(category, input); } } } break; case ConsoleKey.Escape: shouldNotExit = false; break; } SetCursorPosition(categoryPropertiesCoordinates.SavedCoordinates[propertyNames[moveCursor]].X + propertysValuesSpacing, categoryPropertiesCoordinates.SavedCoordinates[propertyNames[moveCursor]].Y); } if (category.ImageUrl == null && category.Name == null) { return(null); } bool b; OptionsPrinter("Save category? (Y)es (N)o"); do { consoleKeyInfo = ReadKey(true); b = !(consoleKeyInfo.Key == ConsoleKey.Y || consoleKeyInfo.Key == ConsoleKey.N); } while (b); switch (consoleKeyInfo.Key) { case ConsoleKey.Y: Clear(); return(category); case ConsoleKey.N: Clear(); SetCursorPosition(MenuCursorPosLeft, MenuCursorPosTop); WriteLine("No changes applied"); Thread.Sleep(1500); return(null); default: return(null); } }
public ActionResult Edit(int id) { CategoryDto category = _categoryService.Get(id); return(View(category)); }
public static Category ToEntity(this CategoryDto model) { return(model.MapTo <CategoryDto, Category>()); }
public async Task <IActionResult> Update(CategoryDto categoryDto) { await _categoryApiService.Update(categoryDto); return(RedirectToAction("Index")); }
protected override void Because_of() { var category = new Category { Name = "Grandparent", Children = new List<Category>() { new Category { Name = "Parent 1", Children = new List<Category>() { new Category { Name = "Child 1"}, new Category { Name = "Child 2"}, new Category { Name = "Child 3"}, }}, new Category { Name = "Parent 2", Children = new List<Category>() { new Category { Name = "Child 4"}, new Category { Name = "Child 5"}, new Category { Name = "Child 6"}, new Category { Name = "Child 7"}, }}, } }; _result = Mapper.Map<Category, CategoryDto>(category); }