public IHttpActionResult PutStudentSubject(int id, StudentSubject studentSubject) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != studentSubject.Id) { return(BadRequest()); } db.Entry(studentSubject).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentSubjectExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutGroup(int id, Group group) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != group.Id) { return(BadRequest()); } db.Entry(group).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GroupExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Insert(T entity) { if (entity == null) { throw new ArgumentNullException("entity"); } entities.Add(entity); context.SaveChanges(); }