Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Title,ArticleTypeId,CoverImg,LinkUrl,Content,MContent,Author,Keywords,Description,Status,Sort,Id,AddTime,UpdateTime")] Article article)
        {
            if (ModelState.IsValid)
            {
                _context.Add(article);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArticleTypeId"] = new SelectList(_context.ArticleType, "Id", "TypeName", article.ArticleTypeId);
            return(View(article));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ApiAdd(Column model)
        {
            if (ModelState.IsValid)
            {
                model.AddTime    = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                db.Column.Add(model);
                await db.SaveChangesAsync();

                return(MyJsonResultSuccess("添加成功!"));
            }

            return(MyJsonResultParamInvalid());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> ApiDelete(int id = 0)
        {
            var model = await db.ColumnType.FirstOrDefaultAsync(p => p.Id == id);

            if (model != null)
            {
                db.ColumnType.Remove(model);
                await db.SaveChangesAsync();
            }
            return(MyJsonResultSuccess("success"));
        }