public ActionResult GetPeople() { AccelaDbContext dbContext = new AccelaDbContext(); var result = dbContext.People.ToList(); return(Ok(result)); }
public ActionResult AddPerson([FromBody] Person req) { AccelaDbContext dbContext = new AccelaDbContext(); dbContext.People.Add(req); dbContext.SaveChanges(); return(Ok()); }
public ActionResult DeleteReport(int personId) { AccelaDbContext dbContext = new AccelaDbContext(); Person personToRemove = dbContext.People.Where(x => x.PersonId == personId).FirstOrDefault(); if (personToRemove != null) { dbContext.People.Remove(personToRemove); dbContext.SaveChanges(); } return(Ok()); }
public ActionResult EditPerson([FromBody] Person req) { int personId = req.PersonId; AccelaDbContext dbContext = new AccelaDbContext(); Person personToUpdate = dbContext.People.Where(x => x.PersonId == personId).FirstOrDefault(); if (personToUpdate != null) { personToUpdate.Title = req.Title; personToUpdate.FirstName = req.FirstName; personToUpdate.LastName = req.LastName; personToUpdate.Email = req.Email; personToUpdate.Telephone = req.Telephone; personToUpdate.DateOfBirth = req.DateOfBirth; dbContext.SaveChanges(); } return(Ok()); }
public UnitTests() { dbContext = new AccelaDbContext(); }
public void Dispose() { dbContext = null; }