public async Task <IActionResult> Create([Bind("Id,Name,Description")] CategoryModel categoryModel)
        {
            if (ModelState.IsValid)
            {
                categoryModel.Id = Guid.NewGuid();
                _context.Add(categoryModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoryModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Slug,ShortDescription,MainContent,CreatedDate,UpdatedDate")] PostModel postModel)
        {
            if (ModelState.IsValid)
            {
                postModel.Id = Guid.NewGuid();
                _context.Add(postModel);
                await _context.SaveChangesAsync();

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