public void TestMissingInteger() { int[] A = new int[] { 1, 3, 6, 4, 1, 2 }; int expected = 5; int actual = Lessons.MissingInteger(A); Assert.AreEqual(expected, actual); A = new int[] { 1, 2, 3 }; expected = 4; actual = Lessons.MissingInteger(A); Assert.AreEqual(expected, actual); A = new int[] { -1, -3 }; expected = 1; actual = Lessons.MissingInteger(A); Assert.AreEqual(expected, actual); A = new int[] { 2 }; expected = 1; actual = Lessons.MissingInteger(A); Assert.AreEqual(expected, actual); }
public ActionResult Edit(int id, IFormCollection collection) { try { Lessons lessons = db.Lessons.Find(id); lessons.Sid = collection["Sid"]; lessons.Name = collection["Name"]; lessons.Text = collection["Text"]; lessons.Types = collection["Types"]; db.Entry(lessons).State = EntityState.Modified; //修改后设置内容已更新 //var setting = db.Settings.Where(o => o.Name == "lastupdate").FirstOrDefault(); Settings setting = db.Settings.Where(o => o.Name == "lastupdate").FirstOrDefault(); setting.Update = DateTime.Now; db.Entry(setting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
void webView3_ScriptNotify(object sender, NotifyEventArgs e) { string str = e.Value; Lessons obj = new Lessons("Example from lesson", "This is an example from the lesson you were viewing. Feel free to tinker around.", str); this.Frame.Navigate(typeof(CodeEditor), new CodeEditorContext(obj, "LessonExample")); }
private void ShowLesson() { ShowModifyLessonSubView = true; using (var db = Database.Instance.GetConnection()) { var lessonsInDatabase = db.Table <Lesson>().Where(l => l.UserId == CurrentUser.Id && l.Name == CurrentLesson.Name); if (lessonsInDatabase.Count() != 1) { CurrentLessonWords.Clear(); Lessons.Remove(CurrentLesson); CurrentLesson = null; return; } CurrentLesson = lessonsInDatabase.First(); CurrentLessonWords = new ObservableCollection <Word>(); CurrentLessonWords.CollectionChanged += CurrentLessonWords_CollectionChanged; foreach (var word in db.Table <Word>().Where(w => w.LessonId == CurrentLesson.Id)) { CurrentLessonWords.Add(word); } CurrentEditingWord = new Word(); OnPropertyChanged("CurrentEditingWord"); OnPropertyChanged("CurrentLessonWords"); OnPropertyChanged("CurrentLesson"); } }
private void Button_Click(object sender, RoutedEventArgs e) { DocumentReader.Visibility = Visibility.Hidden; var window = new Lessons(); transitioningControl.Content = window; }
public async Task <IHttpActionResult> PutLessons(int id, Lessons lessons) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != lessons.id_lesson) { return(BadRequest()); } db.Entry(lessons).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { if (!LessonsExists(id)) { return(NotFound()); } else { WebApiApplication.logger.Warn(e.ToString()); } } return(StatusCode(HttpStatusCode.NoContent)); }
public string this[Pupil pupil, Lesson lesson] { get { try { return(marks[Lessons.IndexOf(lesson), Pupils.IndexOf(pupil)]); } catch (Exception) { throw new IndexOutOfRangeException("pupil or lesson haven't found"); } } set { try { marks[Lessons.IndexOf(lesson), Pupils.IndexOf(pupil)] = value; } catch (Exception) { throw new IndexOutOfRangeException("pupil or lesson haven't found"); } } }
public IActionResult Video(int v_id) { if (Lessons.cashdata.Count() == 0) { string wwwPath = this.Environment.WebRootPath; Lessons.cashdata = Lessons.GetTestData(wwwPath); } Lessons one_les = Lessons.cashdata[0]; if (v_id > -1) { int couter = Lessons.cashdata.Count; for (int i = 0; i < couter; i++) { if (Lessons.cashdata[i].ID == v_id) { one_les = Lessons.cashdata[i]; Lessons.cashdata[i].Moving += 1; break; } } } ViewBag.Lesson = one_les; return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ClassroomId,Date,Time,StyleId")] Lessons lessons) { if (id != lessons.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(lessons); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LessonsExists(lessons.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["StyleId"] = new SelectList(_context.Classrooms, "Id", "Name", lessons.StyleId); ViewData["StyleId"] = new SelectList(_context.Styles, "Id", "Name", lessons.StyleId); return(View(lessons)); }
public async Task <IActionResult> PutLessons(int id, Lessons lessons) { if (id != lessons.LessonId) { return(BadRequest()); } _context.Entry(lessons).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LessonsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public NavigationViewModel( Lessons lessons, IRegionManager regionManager, IEventResolver <LessonSelectedEvent> lessonSelectedResolver) { if (lessons == null) { throw new ArgumentNullException(nameof(lessons)); } if (regionManager == null) { throw new ArgumentNullException(nameof(regionManager)); } if (lessonSelectedResolver == null) { throw new ArgumentNullException(nameof(lessonSelectedResolver)); } if (lessons.Count == 0) { throw new InvalidOperationException("lessons collection was empty."); } _lessons = lessons; _regionManager = regionManager; _lessonSelectedResolver = lessonSelectedResolver; // navigate to the initial view, HomeView LessonSelectedExecute(Lessons[0]); }
public override string ToString() { var selected = Lessons.ToArray(); if (!selected.Any()) { return("На данный момент у этого преподавателя нет пар"); } var strBuilder = new StringBuilder(); foreach (var group in selected.GroupBy(x => x.StartTime.Date)) { strBuilder.AppendFormat("{0:D}", group.Key).AppendLine(); foreach (var lesson in group) { strBuilder.AppendFormat("{0}) {1} - {2} [{3}]", lesson.Number, lesson.StartEndTime, lesson.Name, lesson.Type) .AppendLine() .AppendFormat("У группы {0}", lesson.Groups).AppendLine() .AppendFormat("В {0} ({1})", lesson.Auditory, lesson.Address).AppendLine(); } strBuilder.AppendLine(); } return(strBuilder.ToString()); }
public IActionResult Create(CreateViewModel viewModel) { if (ModelState.IsValid) { if (viewModel.File != null) { string FileName = viewModel.File.FileName; string FileExtension = Path.GetExtension(FileName); string NewFileName = String.Concat(Guid.NewGuid().ToString(), FileExtension); var path = $"{_ev.WebRootPath}/File/{NewFileName}"; using (var Stream = new FileStream(path, FileMode.Create)) { viewModel.File.CopyTo(Stream); }; viewModel.FileName = NewFileName; } var Lesson = new Lessons { LessonName = viewModel.Name, Suammary = viewModel.FileName }; _context.Add(Lesson); _context.SaveChanges(); return(Redirect("/Home/Lessons")); } return(View()); }
public async Task AddRecord() { try { Lessons = Lessons.Substring(0, Lessons.Length - 2); var record = new CreateRecord { Teacher = Teacher, Room = Room, Note = Note, ClassNumber = SelectedNumber, ClassLetter = SelectedLetter, Lessons = Lessons, Date = Date }; await _recordTempService.PostRecord(record); ResetFields(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public ActionResult EditPost(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lessons lessons = lessonB.FindLesson(id); try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } DropDownList(lessons.ID); return(View(lessons)); }
public override string ToString() { var exams = Lessons.Where(x => x.StartTime.Date > Date.Date).ToArray(); if (!exams.Any()) { return("На данный момент список экзаменов отсутствует"); } var strBuilder = new StringBuilder(); var grouped = exams.GroupBy(x => x.Name); foreach (var group in grouped) { var first = group.First(); var last = group.Last(); strBuilder.AppendFormat("{0:D}:", first.StartTime).AppendLine(); strBuilder.AppendFormat("{0:HH:mm}-{1:HH:mm} - {2} [{3}] ({4})", first.StartTime, last.EndTime, first.Name, first.Type, first.Teacher) .AppendLine() .AppendFormat("У группы {0}", first.Groups).AppendLine() .AppendFormat("В аудитории {0} ({1})", first.Auditory, first.Address).AppendLine(); strBuilder.AppendLine(); } return(strBuilder.ToString()); }
public List <Lessons> GetLessons(string name, string surname)//~wiki { List <Lessons> list = new List <Lessons>(); connection = new MySqlConnection(conStrBuilder.ConnectionString); command = new MySqlCommand(Query.GetLessons(name, surname), connection); try { connection.Open(); MySqlDataReader dataReader = command.ExecuteReader(); //dataReader.Read(); while (dataReader.Read()) { Lessons lesson = new Lessons(dataReader); list.Add(lesson); } } catch (Exception exception) { Console.WriteLine(exception.Message); } finally { connection.Close(); } return(list); }
public User(int telegramUserId, StateEnum state, int dutyDay) { TelegramUserId = telegramUserId; State = state; DutyDay = dutyDay; ChosenDay = Lessons.Unnamed; }
async Task ExecuteLoadCommand() { if (IsBusy) { return; } IsBusy = true; try{ Lessons.Clear(); var lessons = await Services.ScheduleService.GetCurrentLessons(); if (lessons.Count > 0) { lessons.ForEach(o => { Lessons.Add(o); }); } else { //alert } }catch (Exception ex) { Debug.WriteLine(ex); }finally{ IsBusy = false; } }
public async Task <IActionResult> Edit(uint id, [Bind("Id,LessonType,Name,LessonNumbers,Description,CurrentLessonNumber,Status,BeginDate,EndDate")] Lessons lessons) { if (id != lessons.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(lessons); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LessonsExists(lessons.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(lessons)); }
public JsonResult Update(Lessons value) { if (value != null) { Lessons lesson = lessonManager.Find(x => x.id == value.id); if (lesson != null) { lesson.name = value.name; int count = lessonManager.Update(lesson); if (count > 0) { _IRedisCacheService.GetAllRemove(); lesson.ModifiedOn = DateTime.Now; toastNotification.AddSuccessToastMessage("Güncelleme İşlemi Başarılı!"); return(Json(new { state = true })); } toastNotification.AddWarningToastMessage("Güncelleme İşlemi Sırasında Bir Hata Meydana Geldi!!"); return(Json(new { state = false })); } toastNotification.AddWarningToastMessage("Güncelleme İşlemi Sırasında Bir Hata Meydana Geldi!!"); return(Json(new { state = false })); } toastNotification.AddWarningToastMessage("Güncelleme İşlemi Sırasında Bir Hata Meydana Geldi!!"); return(Json(new { state = false })); }
public JsonResult SetInstructorProperty(int lessonId) { List <SelectListItem> selectListLesson = new List <SelectListItem>(); List <Lessons> lessonList = lessonManager.List(x => !x.isFull).ToList();//Cache'den çekersen JsonIgnore Çalışmıyor Lessons lesson = lessonManager.Find(x => x.id == lessonId); int empty = 0; if (lessonId == 0) //Ders Seçilmediyse { selectListLesson.Add(new SelectListItem("Ders Seçilmedi", empty.ToString())); for (int i = 0; i < lessonList.Count; i++) { selectListLesson.Add(new SelectListItem(lessonList[i].name, lessonList[i].id.ToString())); } } else { selectListLesson.Add(new SelectListItem(lesson.name, lesson.id.ToString())); for (int i = 0; i < lessonList.Count; i++) { selectListLesson.Add(new SelectListItem(lessonList[i].name, lessonList[i].id.ToString())); } selectListLesson.Add(new SelectListItem("Ders Seçilmedi", empty.ToString())); } return(Json(new { lessonList = selectListLesson })); }
public JsonResult DeleteLesson(int?value) { if (value != null) { Lessons lesson = lessonManager.Find(x => x.id == value); if (lesson != null) { int count = lessonManager.Remove(lesson); if (count > 0) { _IRedisCacheService.GetAllRemove(); toastNotification.AddSuccessToastMessage("Silme İşlemi Başarılı!"); return(Json(new { state = true })); } toastNotification.AddWarningToastMessage("Silme İşlemi Sırasında Bir Hata Meydana Geldi!!"); return(Json(new { state = false })); } toastNotification.AddWarningToastMessage("Silme İşlemi Sırasında Bir Hata Meydana Geldi!!"); return(Json(new { state = false })); } toastNotification.AddWarningToastMessage("Silme İşlemi Sırasında Bir Hata Meydana Geldi!!"); return(Json(new { state = false })); }
/// <summary> /// Обновление занятии /// </summary> /// <param name="children"></param> void UpdateLessons(Children children = null) { // Вычисление дат начала и конца недели var StartWeek = SelectedDate.AddDays(1 - (int)SelectedDate.DayOfWeek); var EndWeek = SelectedDate.AddDays(6 - (int)SelectedDate.DayOfWeek); if (children == null) { Lessons = new ObservableCollection <Lesson>(Db.Lessons.Include(x => x.Room) .Where(x => StartWeek >= x.DateStart && StartWeek <= x.DateEnd && EndWeek >= x.DateStart)); if (SelectedGroup.Name != "Все") { Lessons = new ObservableCollection <Lesson>(Lessons.Where(x => x.Group == SelectedGroup)); } if (SelectedEmployee?.Person.Lastname != "Все") { Lessons = new ObservableCollection <Lesson>(Lessons.Where(x => x.Employee == SelectedEmployee).ToList()); } } else { Lessons = new ObservableCollection <Lesson>(Db.Lessons.Include(x => x.Room) .Where(x => (x.DateStart.DayOfYear >= StartWeek.DayOfYear && x.DateEnd.DayOfYear >= StartWeek.DayOfYear) && children.ChildrenGroups.FirstOrDefault(y => y.Group == x.Group) != null).ToList()); } }
public ActionResult AddLesson(string nameLesson, HttpPostedFileBase fileDocumentWord, HttpPostedFileBase fileDocumentPPT, HttpPostedFileBase fileDocumentPDF, string urlVideo, string idSubject, string description) { if (nameLesson.Equals("") || urlVideo.Length == 0) { TempData["Error"] = "Dữ liệu (*) không được để trống"; return(RedirectToAction("AddLesson", "Lessons", new { id = idSubject })); } #region Add Lesson Lessons item = new Lessons(); item.ID = this.GetNextIDSubject(); item.Name = nameLesson; item.PPTFile = UploadsFile(fileDocumentPPT); item.WordFile = UploadsFile(fileDocumentWord); item.PdfFile = UploadsFile(fileDocumentPDF); item.Video = urlVideo; item.DateCreated = DateTime.Now; item.IDSubject = idSubject; item.Description = description; lessons.Add(item); #endregion #region Update Subject subject.UpdateChildren(idSubject); #endregion return(RedirectToAction("Index", "Subjects")); }
public async Task <ActionResult <Lessons> > PostLessons(Lessons lessons) { _context.Lessons.Add(lessons); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLessons", new { id = lessons.LessonId }, lessons)); }
public async Task <IHttpActionResult> PostLessons(Lessons lessons) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.lessons.Add(lessons); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (LessonsExists(lessons.id_lesson)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = lessons.id_lesson }, lessons)); }
public ActionResult DeleteConfirmed(int id) { Lessons lessons = db.Lessons.Find(id); db.Lessons.Remove(lessons); db.SaveChanges(); return(RedirectToAction("Index")); }
public void TestFrogJmp() { int X = 10, Y = 85, D = 30; int expected = 3; int actual = Lessons.FrogJmp(X, Y, D); Assert.AreEqual(expected, actual); }
private async Task AutoSelectLessonAsync() { _visualizeShellService.SetSelectedMenu(GlobalResources.DiscussionNavView); SelectedLesson = Lessons.FirstOrDefault(l => l.Id == _lessonInfo.Id); await SelectionChangedAsync(_lessonInfo); _lessonInfo.CloneLessonInfo(new LessonInfo()); }
public LearnViewModel(int lessonId) { var lesson = new Lessons()[lessonId - 1]; this.Cards = lesson.Facts .Select(f => new Card(f, StudyMode.QuestionOrAnswer)) .ToList(); this.Total = this.Cards.Count; this.Cards.ShuffleSort(); this.SetCard(0); }
public Layer(LayerStack layerStack, Lessons.Lesson lessonModel, AbstractLayer layerModel) { this.layerStack = layerStack; this.lessonModel = lessonModel; this.layerModel = layerModel; Strokes = StrokeConverter.ToWindowsStrokes(layerModel.Strokes); if (layerModel.GetType() == typeof (QuizAnswerLayer)) { DisplayChart(); } else if (layerModel.GetType() == typeof (GraphicalAnswerLayer)) { DisplaySaliencyMap(); } }
public LayerStack(Holder holderModel, Lessons.Lesson lessonModel) { this.lessonModel = lessonModel; this.holderModel = holderModel; }
/// <summary> /// 得到课程信息 /// </summary> /// <returns></returns> public List<Lessons> GetLessonsInfo() { System.Text.StringBuilder sb = new StringBuilder(); sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); sb.Append("<method name=\"getLessonsInfo\" groupid=\"" + groupid + "\" cpuid=\"" + cpuid + "\"/>"); byte[] byte1 = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); string response = this.SendRequest(byte1); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(response); string respcode = doc.GetElementsByTagName("respcode").Item(0).InnerText; string respmsg = doc.GetElementsByTagName("respmsg").Item(0).InnerText; if (System.Int32.Parse(respcode) < 0) { System.Windows.Forms.MessageBox.Show(respmsg); return null; } List<Lessons> lessons = new List<Lessons>(); XmlNodeList nodelist = doc.GetElementsByTagName("lesson"); int length = nodelist == null ? 0 : nodelist.Count; for (int i = 0; i < length; i++) { XmlElement element = (XmlElement)nodelist.Item(i); Lessons lesson = new Lessons(); lesson.Lessonid = Int32.Parse(element.GetElementsByTagName("lessonid").Item(0).InnerText); lesson.Title = element.GetElementsByTagName("title").Item(0).InnerText; lesson.Lessontype = element.GetElementsByTagName("lessontype").Item(0).InnerText; lesson.Lessondate = element.GetElementsByTagName("lessondate").Item(0).InnerText; lesson.Reqminute = element.GetElementsByTagName("reqminute").Item(0).InnerText; lessons.Add(lesson); } return lessons; }