public async Task <ActionResult <Category> > Create(Category category) { try { _context.Categories.Add(category); await _context.SaveChangesAsync(); return(category); } catch (Exception e) { Console.WriteLine(e); } return(null); }
public async Task <ActionResult <Theme> > Create([FromBody] Theme theme) { var obj = await _context.Themes .Where(b => b.Id == theme.Id) .FirstOrDefaultAsync(); if (obj != null) { return(BadRequest()); } if (ModelState.IsValid) { var themee = await _context.Themes.AddAsync(theme); await _context.SaveChangesAsync(); } return(CreatedAtAction(nameof(Create), new { id = theme.Id }, theme)); }
public async Task SaveAsync(Logging logging) { await _context.Loggings.AddAsync(logging); await _context.SaveChangesAsync(); }