public override void FuncPreInitCreateView() { //get article types var articleTypes = new ArticleTypeModel <ArticleType>().GetData(isBlock: false); ViewBag.ArticleTypes = articleTypes.Select(x => new CustomSelectListItem() { Text = x.ArticleTypeName, Value = x.ArticleTypeID.ToString() }); //get scopes var scopes = new ScopeModel <Scope>().GetData(isBlock: false); ViewBag.Scopes = scopes.Select(x => new CustomSelectListItem() { Text = x.ScopeName, Value = x.ScopeID.ToString() }); //get authors var authors = new AuthorModel <Author>().GetData(isBlock: false); ViewBag.Authors = authors.Select(x => new CustomSelectListItem() { Text = x.AuthorName, Value = x.AuthorID.ToString() }); base.FuncPreInitCreateView(); }
public ActionResult Add(ArticleTypeModel model) { model.CreateOn = DateTime.Now; var result = articleTypeService.CreateModel(model) ? SuccessTip() : ErrorTip(); return(Json(result)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ArticleTypeModel = await _context.ArticleTypes.FirstOrDefaultAsync(m => m.Id == id); if (ArticleTypeModel == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ArticleTypeModel = await _context.ArticleTypes.FindAsync(id); if (ArticleTypeModel != null) { _context.ArticleTypes.Remove(ArticleTypeModel); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private List <ArticleTypeModel> PrepareArticleTypes(List <ArticleType> articleTypes) { List <ArticleTypeModel> model = new List <ArticleTypeModel>(); foreach (ArticleType at in articleTypes) { ArticleTypeModel m = new ArticleTypeModel(); m.Description = at.Description; m.Title = at.Name; m.Code = at.Code.ToLower(); m.IsMain = at.IsMain; model.Add(m); } return(model); }
public override void FuncPreInitEditView(object id, ref PublishedArticle EditItem, ref PublishedArticleEditModel model) { if (EditItem == null) { //get the item by id EditItem = new PublishedArticleModel <PublishedArticle>().Get(id); } if (EditItem != null) { model = new PublishedArticleEditModel(); model.EditItem = EditItem; var selectedItem = EditItem; var articleTypes = new ArticleTypeModel <ArticleType>().GetData(); ViewBag.ArticleTypeID = articleTypes.Select(x => new CustomSelectListItem() { Text = x.ArticleTypeName, Value = x.ArticleTypeID.ToString(), Selected = (x.ArticleTypeID == selectedItem.PublishedArticleID) }).OrderBy(x => x.Text).ToList(); } }
public ActionResult Edit(ArticleTypeModel model) { var result = articleTypeService.UpdateModel(model) ? SuccessTip() : ErrorTip(); return(Json(result)); }
public JsonResult List(ArticleTypeModel filter, PageInfo pageInfo) { var result = articleTypeService.GetListByFilter(filter, pageInfo); return(Json(result, JsonRequestBehavior.AllowGet)); }