public IHttpActionResult PostAddPerson(Person newPerson) { using (PeopleDBEntities context = new PeopleDBEntities()) { if (!ModelState.IsValid) { return(BadRequest()); } var personObj = context.People.FirstOrDefault(p => p.id == newPerson.id); if (personObj != null) { personObj.fname = newPerson.fname; personObj.lname = newPerson.lname; personObj.age = newPerson.age; personObj.addr = newPerson.addr; personObj.interests = newPerson.interests; personObj.picture = newPerson.picture; } else { context.People.Add(newPerson); } context.SaveChanges(); return(Ok()); } }
public IHttpActionResult GetPeople() { using (PeopleDBEntities context = new PeopleDBEntities()) { var personList = context.People.ToList(); return(Ok(personList)); } }
public BaseRepository(IDbFactory dbFactory) { _dbFactory = dbFactory; _dbContext = _dbFactory.Init(); _dbSet = _dbContext.Set <T>(); }
public HomeController() { _db = new PeopleDBEntities(); }