public static void Insert(StudentsGroupsModel model) { try { using (AppContext db = new AppContext()) { db.StudentsGroupsSet.Add(model); db.SaveChanges(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public ContentResult AddStudent(StudentsGroupsModel model) { if (ModelState.IsValid) { InsertStudent.Insert(model); return(new ContentResult { StatusCode = (int)HttpStatusCode.OK }); } else { return(new ContentResult { StatusCode = (int)HttpStatusCode.InternalServerError }); } }