예제 #1
0
        public async Task <IActionResult> Create([Bind("CategoryId, Name, Description, Color")] Category categoryModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categoryModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoryModel));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Header,Summery,Content,HomeImageUrl,CategoryId,Location,IsShowMap")] Article articleModel)
        {
            if (ModelState.IsValid)
            {
                articleModel.DateCreated = DateTime.Now;
                _context.Add(articleModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(articleModel));
        }