public void Edit(StudGroup group) { var old = Get(group.GroupId); old.Name = group.Name; old.FacultId = group.FacultId; }
static void Main(string[] args) { StudGroup group = new StudGroup { new List <Student> { new Student("ABC", DateTime.Now, "8-800-555-35-35"), new Student("BCA", DateTime.Now.AddDays(-2), "9-800-555-35-35"), new Student("CBA", DateTime.Now.AddDays(-15), "10-800-555-35-35"), new Student("BAC", DateTime.Now.AddDays(-152), "11-800-555-35-35"), new Student("CAB", DateTime.Now.AddDays(-900), "12-800-555-35-35"), } }; string phone = "11-800-555-35-35"; Console.WriteLine("До сортировки\n"); Console.WriteLine(group); group.Sort(); Console.WriteLine("---------------------------"); Console.WriteLine("После сортировки\n"); Console.WriteLine(group); Console.WriteLine("---------------------------"); Console.WriteLine($"Ищем ученика с телефоном: {phone}\n"); var tmp = group.Search(phone, "Phone"); Console.WriteLine(tmp); Console.WriteLine("---------------------------"); Console.WriteLine("Удалили его\n"); group.Remove(tmp); Console.WriteLine(group); Console.WriteLine("---------------------------"); Console.WriteLine("Проверяем еще разок его наличие\n"); tmp = group.Search("11-800-555-35-35", "Phone"); Console.WriteLine(tmp is null ? "не найдено" : "найден"); }
// // TODO AJAX => упростит всЁ // public bool ListAdd(ScheduleTableCreate table, StudGroup studgroup) { // Валидация// Перенос //var group = _ctx.StudGroups.Find(table.GroupId); //if (group == null || (!Roles.IsUserInRole(group.FacultId.ToString(CultureInfo.InvariantCulture)) && !Roles.IsUserInRole("Admin"))) // return false; if (studgroup == null) { return(false); } // Старая таблица - для сравнения по изменению var oldids = table.ScheduleTableRows.Select(x => x.ScheduleTableId); var oldTable = (from x in _ctx.ScheduleTables where studgroup.GroupId == x.GroupId && table.IsWeekOdd == x.IsWeekOdd && oldids.All(i => i != x.ScheduleTableId) select x).ToList(); foreach (var tRow in table.ScheduleTableRows) { //// Убираем //var updatedItem = oldTable.SingleOrDefault(x => x.ScheduleTableId == tRow.ScheduleTableId); //oldTable.Remove(updatedItem); // Если ID == 0, то у нас новый экземпляр - Добавляем if (tRow.ScheduleTableId == 0) { _ctx.ScheduleTables.Add(tRow); } else // Иначе изменяем по ID { var old = _ctx.ScheduleTables.Find(tRow.ScheduleTableId); old.LectorName = tRow.LectorName; old.SubjectName = tRow.SubjectName; old.Auditory = tRow.Auditory; old.LessonType = tRow.LessonType; } } // Очистить удалённые foreach (var t in oldTable) { _ctx.ScheduleTables.Remove(t); } // Обновление данных для экспорта var facult = _ctx.Facults.Find(studgroup.FacultId); facult.IsReady = false; // Все этапы пройдены успешно return(true); }
public ActionResult Edit(StudGroup studgroup) { if (ModelState.IsValid) { _db.Groups.Edit(studgroup); _db.SaveChanges(); return(RedirectToAction("Index", new { controller = "Facult" })); } ViewBag.FacultId = new SelectList(_db.Facults.ListNames(), "FacultId", "Name", studgroup.FacultId); return(View(studgroup)); }
public ActionResult Edit(int id) { StudGroup studgroup = _db.Groups.Get(id); if (studgroup == null || (!Roles.IsUserInRole(studgroup.FacultId.ToString(CultureInfo.InvariantCulture)) && !Roles.IsUserInRole(StaticData.AdminRole))) { return(RedirectToRoute(new { controller = "Default", action = "Error", id = 404 })); } ViewBag.FacultId = new SelectList(_db.Facults.ListNames(), "FacultId", "Name", studgroup.FacultId); return(View(studgroup)); }
public ActionResult Create(StudGroup studgroup) { if (ModelState.IsValid) { if (!Roles.IsUserInRole(studgroup.FacultId.ToString(CultureInfo.InvariantCulture)) && !Roles.IsUserInRole(StaticData.AdminRole)) { return(RedirectToRoute(new { controller = "Default", action = "Error", id = 404 })); } studgroup.LastCheck = DateTime.Now; _db.Groups.Add(studgroup); _db.SaveChanges(); return(RedirectToAction("Index", new { controller = "Facult" })); } ViewBag.FacultId = new SelectList(_db.Facults.ListNames(), "FacultId", "Name", studgroup.FacultId); return(View(studgroup)); }
public ScheduleTableCreate ListForCreate(StudGroup group, bool week) { //var group = _ctx.StudGroups.Find(groupId); //if (group == null || (!Roles.IsUserInRole(group.FacultId.ToString(CultureInfo.InvariantCulture)) && !Roles.IsUserInRole("Admin"))) // return null; if (group == null) { return(null); } var result = new ScheduleTableCreate { GroupId = group.GroupId, GroupName = group.Name, IsWeekOdd = week, Lessons = _ctx.Lessons.OrderBy(x => x.Time.Hour).ToList(), Weekdays = _ctx.Weekdays.OrderBy(x => x.WeekdayId).ToList(), ScheduleTableRows = List(group.GroupId, week) }; return(result); }
public static void Main() { string[] name = { "Ивнов", "Петров", "Сидоров", "Субботина", "Алексеев" }; Group gr = new Group(name); StudGroup StudGrup = new StudGroup("09-901", "ИВМИиТ", gr.group); Console.WriteLine("##### ДО СОРТИРОВКИ #####"); StudGrup.Display(); Console.WriteLine("##### ПОСЛЕ СОРТИРОВКИ #####"); StudGrup.Sort(); StudGrup.Display(); string n = "Сидоров"; Console.WriteLine("##### После удаления ={0}= #####", n); gr = gr - n; //удаляем из масиива grup класса group StudGrup = new StudGroup("09-901", "ИВМИиТ", gr.group); // записываем заново удалив StudGrup.Display(); StudGrup.InFile("..\\..\\Text.txt"); }
public void Add(StudGroup group) { _ctx.StudGroups.Add(group); }
// // GET: /Groups/Delete/5 public ActionResult Delete(int id) { StudGroup studgroup = _db.Groups.Get(id); return(View(studgroup)); }