public Models.HighScore Add(Models.HighScore highScore) { var entity = mapper.Map <HighScore>(highScore); entity = dbContext.HighScores.Add(entity).Entity; dbContext.SaveChanges(); return(mapper.Map <Models.HighScore>(entity)); }
public void Create([FromBody] Users user) { try { _context.Users.Add(user); _context.SaveChanges(); } catch (Exception e) { throw e; } }
public TestContext() { var options = new DbContextOptionsBuilder <WebApplicationDbContext>().UseInMemoryDatabase(databaseName: "TestDb").Options; DbContext = new WebApplicationDbContext(options); DbContext.Users.RemoveRange(DbContext.Users); DbContext.HighScores.RemoveRange(DbContext.HighScores); DbContext.SaveChanges(); Config = A.Fake <IConfiguration>(); }
public IActionResult Edit([FromBody] Users user) { if (user == null) { return(BadRequest()); } var item = _context.Users.Find(user.UserId); if (user == null) { return(NotFound()); } item.FirstName = user.FirstName; item.MiddleName = user.MiddleName; item.LastName = user.LastName; //item.IsMale = user.IsMale; _context.Users.Update(item); _context.SaveChanges(); return(NoContent()); }
public Restaurant Add(Restaurant restaurant) { dbContext.Restaurants.Add(restaurant); dbContext.SaveChanges(); return(restaurant); }