static void Main(string[] args) { string[] token = Console.ReadLine().Split(", "); Arcticle arcticle = new Arcticle(token[0], token[1], token[2]); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string[] cmdArg = Console.ReadLine().Split(": "); string command = cmdArg[0]; string argument = cmdArg[1]; switch (command) { case "Edit": arcticle.Edit(argument); break; case "ChangeAuthor": arcticle.ChangeAuthor(argument); break; case "Rename": arcticle.Reneme(argument); break; } } Console.WriteLine(arcticle.ToString()); }
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List <Arcticle> arcticles = new List <Arcticle>(); for (int i = 0; i < n; i++) { string[] token = Console.ReadLine().Split(", "); string title = token[0]; string content = token[1]; string author = token[2]; Arcticle arcticle = new Arcticle(title, content, author); arcticles.Add(arcticle); } string criteria = Console.ReadLine(); if (criteria == "title") { arcticles = arcticles.OrderBy(x => x.Title).ToList(); } else if (criteria == "content") { arcticles.Sort((c1, c2) => c1.Content.CompareTo(c2.Content)); } else if (criteria == "author") { arcticles = arcticles.OrderBy(x => x.Author).ToList(); } Console.WriteLine(string.Join(Environment.NewLine, arcticles)); }
static void Main(string[] args) { var input = Console.ReadLine() .Split(", ", StringSplitOptions.RemoveEmptyEntries) .ToArray(); Arcticle article = new Arcticle(input[0], input[1], input[2]); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { var command = Console.ReadLine() .Split(", ", StringSplitOptions.RemoveEmptyEntries) .ToArray(); switch (command[0]) { case "Edit": article.Edit(command[1]); break; case "ChangeAuthor": article.ChangeAuthor(command[1]); break; case "Rename": article.Rename(command[1]); break; default: break; } } Console.WriteLine(article.ToString()); }
public ActionResult CreateNew(int?catParentId, int?catId) { var artCatSrv = IoC.Resolve <IArticleCategoryService>(); var model = new ArticleInputModel(); var articleModel = new Arcticle(); model.ArticleModel = articleModel; model.ParentCatId = catParentId; model.ParentCats = artCatSrv.GetParents(); model.CatId = catId; model.ChildCats = artCatSrv.GetChilds(catParentId); return(View(model)); }
public ActionResult CreateNew(Arcticle artModel, int?catParentId, int CatId, string[] tags) { var artSrv = IoC.Resolve <IArticleService>(); var artCatSrv = IoC.Resolve <IArticleCategoryService>(); var tagSrv = IoC.Resolve <ITagService>(); var lstExisted = new List <Tag>(); var lstNotExisted = new List <Tag>(); artCatSrv.BeginTran(); try { if (tags.Length > 0) { var map = tags.Distinct().ToDictionary(x => StringUtil.UnsignToString(x)); foreach (var item in map) { var flag = tagSrv.CheckTitleContain(item.Key); if (!flag) { var tagEntity = new Tag(); tagEntity.TagTitle = item.Key; tagEntity.TagName = item.Value; tagEntity.CreateBy = CurrentInstance.Instance.CurrentUser.UserName; tagEntity.CreateDate = DateTime.Now; tagEntity.Status = true; tagSrv.CreateNew(tagEntity); tagSrv.CommitChange(); lstNotExisted.Add(tagEntity); } else { lstExisted.Add(tagSrv.GetByKey(item.Key)); } } var lstTag = lstExisted.Union(lstNotExisted); artModel.Tags = string.Join(",", lstTag.Select(n => n.TagName)); } artModel.CreateBy = CurrentInstance.Instance.CurrentUser.UserName; artModel.CreateDate = DateTime.Now; artModel.URL = "/" + UnsignToString(artModel.Name); artSrv.CreateNew(artModel); artSrv.CommitChange(); artSrv.CommitTran(); AlertSuccess(InfoString.CREATE_SUCCESSFULL); return(RedirectToAction("Index")); } catch (Exception ex) { artSrv.RollbackTran(); LogError(ex); var model = new ArticleInputModel(); var articleModel = artModel; model.ArticleModel = articleModel; var map = tags.Distinct().ToDictionary(x => StringUtil.UnsignToString(x)); var lstTag = new List <Tag>(); foreach (var item in map) { var flag = tagSrv.CheckTitleContain(item.Key); if (!flag) { var tag = new Tag(); tag.TagTitle = item.Key; tag.TagName = item.Value; lstTag.Add(tag); } else { lstTag.Add(tagSrv.GetByKey(item.Key)); } } model.Tags = lstTag; model.ParentCatId = catParentId; model.ParentCats = artCatSrv.GetParents(); model.CatId = CatId; model.ChildCats = artCatSrv.GetChilds(catParentId); return(View(model)); } }
public void Update(Arcticle article) { _artRp.Update(article); }
public void CreateNew(Arcticle article) { _artRp.CreateNew(article); }