public IEnumerable <object> Get() { using (var AppContext = new TestEmployeeContext()) { return(AppContext.Employee.ToList()); } }
public bool Save([FromBody] Employee value) { using (var AppContext = new TestEmployeeContext()) { AppContext.Employee.Add(value); AppContext.SaveChanges(); return(true); } }
//[HttpPost("{id}")] public bool Delete([FromBody] Employee data) { using (var AppContext = new TestEmployeeContext()) { Employee save = AppContext.Employee.FirstOrDefault(obj => obj.Id == data.Id); AppContext.Employee.Remove(save); AppContext.SaveChanges(); return(true); } }
public bool Put([FromBody] Employee value) { using (var AppContext = new TestEmployeeContext()) { Employee save = AppContext.Employee.FirstOrDefault(obj => obj.Id == value.Id); save.FirstName = value.FirstName; save.LastName = value.LastName; save.Email = value.Email; AppContext.Employee.Update(save); AppContext.SaveChanges(); return(true); } }