Esempio n. 1
0
        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));
        }
Esempio n. 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));
        }