public async Task <IActionResult> Create([Bind("Id,Name,Surname,Pesel,Age")] DrugaKlasaModel drugaKlasaModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(drugaKlasaModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(drugaKlasaModel));
        }
        public async Task <IActionResult> Create([Bind("Id,PhoneNumber,Nickname,Description,Address")] DowolnaKlasaModel dowolnaKlasaModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dowolnaKlasaModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dowolnaKlasaModel));
        }
Exemple #3
0
 public IActionResult CreateNew(LoaiModel model)
 {
     try
     {
         var loai = new Loai
         {
             TenLoai = model.TenLoai
         };
         _context.Add(loai);
         _context.SaveChanges();
         return(Ok(loai));
     }catch
     {
         return(BadRequest());
     }
 }