public void Delete(int id) { using (angulardbEntities entities = new angulardbEntities()) { entities.Employees.Remove(entities.Employees.FirstOrDefault(e => e.Id == id)); entities.SaveChanges(); } }
public void Put(int id, [FromBody] Employee employee) { using (angulardbEntities entities = new angulardbEntities()) { var entity = entities.Employees.FirstOrDefault(e => e.Id == id); entity.FirstName = employee.FirstName; entity.LastName = employee.LastName; entities.SaveChanges(); } }
public void Post([FromBody] Employee employee) { try { using (angulardbEntities entities = new angulardbEntities()) { entities.Employees.Add(employee); entities.SaveChanges(); //var message = Request.CreateResponse(HttpStatusCode.Created, employee); //message.Headers.Location = new Uri(Request.RequestUri + employee.Id.ToString()); //return message; } } catch (Exception ex) { Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex); } }