public ActionResult Create(Groups groups) { db.Groups.Add(groups); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Teachers teachers) { db.Teachers.Add(teachers); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Create(TypeOfClasses typeOfClasses) { db.TypeOfClasses.Add(typeOfClasses); db.SaveChanges(); return(RedirectToAction("Index")); }
private void kafedraAddbutton1_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in kafedrasGridView1.Rows) { foreach (int changedIndex in indexesOfChangedRows) { if (row.Index == changedIndex) { context.Kafedras.Add(new Kafedra { FullName = row.Cells[0].Value.ToString(), ShortName = row.Cells[1].Value.ToString() }); } } context.SaveChanges(); ClearIndexes(); } }
public ActionResult Create(Subjects_groups subjects_groups) { db.Subjects_groups.Add(subjects_groups); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Copy(Cycles cycles) { var id_cycle = cycles.Id; var id_subject_group = Int32.Parse(Request.Form["Subjects_groups"]); var items = new List <Subjects>(db.Subjects.Where(l => l.Subjects_groupsId == id_subject_group).OrderBy(s => s.Name)); foreach (var item in items) { db.Cycles_item.Add(new Cycles_item { Name = item.Name, Hours = 0, CyclesId = id_cycle, SubjectsGroupsId = id_subject_group }); } db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Copy(Subjects_groups subjects_groups) { var Id = subjects_groups.Id; var s = db.Subjects_groups.FirstOrDefault(l => l.Id == Id); var items = new List <Subjects>(db.Subjects.Where(l => l.Subjects_groupsId == Id)); var Speciality = new Speciality() { Name = s.Name }; foreach (var item in items) { db.Speciality_item.Add(new Speciality_item { Name = item.Name, Hours = 0, SpecialityId = Speciality.Id }); } db.Speciality.Add(Speciality); db.SaveChanges(); return(RedirectToAction("Index")); }
//---------Сохранение данных календаря в БД public ActionResult Save(Events changedEvent, FormCollection actionValues) { String action_type = actionValues["!nativeeditor_status"]; Int64 source_id = Int64.Parse(actionValues["id"]); Int64 target_id = source_id; try { switch (action_type) { case "inserted": db.Events.Add(changedEvent); //---запись break; case "deleted": changedEvent = db.Events.SingleOrDefault(ev => ev.id == source_id); db.Events.Remove(changedEvent); //---удаление break; default: // "updated" changedEvent = db.Events.SingleOrDefault(ev => ev.id == source_id); UpdateModel(changedEvent); //---по умолчанию обновить отображение break; } db.SaveChanges(); target_id = changedEvent.id; } catch { action_type = "error"; } return(View(new CalendarActionResponseModel(action_type, source_id, target_id))); }
public ActionResult Create(Cities city) { if (ModelState.IsValid) { db.Cities.Add(city); db.SaveChanges(); } //ViewBag.Cities = db.Cities; // return View("Cities");//поправить вывод после добавления нового элемента return(RedirectToAction("Cities")); }