private void _BoMapToVM(CourseItem bo, CourseItemVM boVM) { boVM.Id = bo.Id; boVM.Name = bo.Name; boVM.Description = bo.Description; boVM.SortCode = bo.SortCode; if (bo.ParentCourseItem != null) { boVM.ParentCourseItemId = bo.ParentCourseItem.Id.ToString(); boVM.ParentCourseItemName = bo.ParentCourseItem.Name; } if (bo.Course != null) { boVM.CourseId = bo.Course.Id.ToString(); boVM.CourseName = bo.Course.Name; } if (bo.CourseItemContent != null) { boVM.CourseItemContentID = bo.CourseItemContent.Id.ToString(); boVM.CourseItemContentName = bo.CourseItemContent.Name; } if (bo.Creator != null) { boVM.CreatorUserID = bo.Creator.Id.ToString(); boVM.CreatorUserName = bo.Creator.UserName; } }
public ActionResult DetailItem(int courseId, string title, string remark, string filePath) { CourseItem item = new CourseItem { courseId = courseId, title = title, remark = remark, filePath = filePath }; bool success = CourseItemService.Create(item); if (success) { ViewData["resp"] = base.RespResult(true, "上传成功!"); } else { ViewData["resp"] = base.RespResult(false, "上传失败,请稍后重试!"); } Course course = CourseService.GetById(courseId); return(View(course)); }
private void _VMMapToBo(CourseItem bo, CourseItemVM boVM) { bo.Id = boVM.Id; bo.Name = boVM.Name; bo.Description = boVM.Description; bo.SortCode = boVM.SortCode; }
// Init the data of the list in rows in the panel private void init_List() { // check if there is data to init if (lessons == null || lessons.amount() <= 0) { return; } string[] names = getCoursesName(); if (names == null) { return; } cards = new CourseItem[names.Length]; for (int i = 0; i < names.Length; i++) { if (i == 0) { cards[i] = new CourseItem(this, getLessonsOfCourse(names[i]), 5, 0 + 10); } else { cards[i] = new CourseItem(this, getLessonsOfCourse(names[i]), cards[i - 1].getLocation().X, cards[i - 1].getLocation().Y + cards[i - 1].getCard().Height + 10); } pnl_courseList.Controls.Add(cards[i].getCard()); } checkToSetEmptyInfo(); }
public async Task <Response <CourseItemViewModel> > Handle(AddCourseItemByTeacherCommand request, CancellationToken cancellationToken) { var course = _courseRepository.GetQueryable().Include(x => x.Teacher).First(x => x.Id == request.CourseId); course.HasPendingItemToApprove = true; var item = new CourseItem { Order = request.Order, CourseId = request.CourseId, TeacherMessageForAdmin = request.TeacherMessageForAdmin, State = CourseItemApprovalState.PendingToApproveByAdmin, Title = request.Title, IsPreview = request.IsPreview, }; if (request.File != null) { await _coursesFileManager.SaveFile(request.File, course.Teacher.UserName, item.CourseId); item.FilePath = _coursesFileManager.GetFilePathForDownload(request.File, course.Teacher.UserName, item.CourseId); item.ContentType = GetContentType(request.File.ContentType); } await _courseItemRepository.AddAsync(item); await _courseRepository.EditAsync(course); return(Response <CourseItemViewModel> .Success(_mapper.Map <CourseItemViewModel>(item))); }
public void AddCourseItem(string id, string courseName, string score, string teacher) { var newItem = new CourseItem(id, courseName, score, teacher); this.allItems.Add(newItem); this.selectedItem = null; }
public StudentItem Find(int id) { var student = new Student(); student = unit.StudentRepository.Find(id); var studentItem = new StudentItem() { Id = student.StudentId, Name = student.Name, Roll = student.Roll, Email = student.Email, Address = student.Address, CourseItems = new List <CourseItem>() }; foreach (var item in student.Courses) { var courseItem = new CourseItem() { Id = item.CourseId, Code = item.Code, Name = item.Name }; studentItem.CourseItems.Add(courseItem); } return(studentItem); }
public void CreateButtonPush() { var item = new CourseItem(); //データ入力 item.name = InputItemName.text; //賞品名 item.description = InputItemDescription.text; //賞品の説明 item.place = InputItemPlace.text; //受け渡し場所 // JSONにシリアライズ var json = JsonUtility.ToJson(item, true); // jsonファイルをフォルダに保存する var path = "/sdcard/StampShot/course/item/" + item.name + ".json"; //ファイル名をspot名にしてファイル指定 var writer = new StreamWriter(path, false); // 上書き writer.WriteLine(json); writer.Flush(); writer.Close(); //撮影した写真をpng形式で保存 File.WriteAllBytes("/sdcard/StampShot/course/item/" + item.name + ".png", CameraReader.bytes); SceneManager.LoadScene("2Menu"); }
public void readJSON(Uri location) { string text = new StreamReader(Application.GetResourceStream(location).Stream).ReadToEnd(); //Console.WriteLine(text); //JObject json = JObject.Parse(text); String[] yearTitles = { "Part II", "Part III", "Part IV" }; JArray courses = JArray.Parse(text); for (int i = 0; i < courses.Count; i++) { CourseSet cs = new CourseSet() { Title = yearTitles[i] }; JArray yearCourses = courses[i] as JArray; for (int j = 0; j < yearCourses.Count; j++) { JObject course = yearCourses[j] as JObject; CourseItem ci = new CourseItem(); ci.Name = course["name"].ToString(); ci.Code = course["code"].ToString(); ci.Points = course["points"].ToString(); ci.Desc = course["text"].ToString(); cs.CourseList.Add(ci.Code, ci); } CourseSets.Add(i, cs); } CurrentCourseSet = 0; }
public async Task <CourseItemVM> GetVM(Guid boId, Guid courseID) { var boVM = new CourseItemVM(); // 初始化数据对象 var bo = _boRepository.GetSingle(boId, x => x.ParentCourseItem, y => y.Course, w => w.CourseItemContent, z => z.Creator); if (bo == null) { bo = new CourseItem(); bo.Course = _courseRepository.GetSingle(courseID); boVM.IsNew = true; } else { boVM.IsNew = false; } // 映射基本的属性值 _BoMapToVM(bo, boVM); // 设置供前端下拉选项所需要的数据集合 await SetTypeItems(boVM, courseID); return(boVM); }
private async Task UpdateData(Course course, CourseItem item) { _unitOfWork.Begin(); await _courseRepository.EditAsync(course); await _courseItemRepository.EditAsync(item); _unitOfWork.Commit(); }
private void MapRequestToProperties(EditCourseItemCommand request, CourseItem item) { item.State = request.State; item.Order = request.Order; item.Title = request.Title; item.AdminMessageForTeacher = request.AdminMessageForTeacher; item.IsPreview = request.IsPreview; item.ContentType = request.File != null?GetContentType(request.File.ContentType) : ContentType.File; }
public async Task <bool> SaveBo(CourseItemVM boVM) { var bo = _boRepository.GetSingle(boVM.Id, y => y.Course, z => z.CourseItemContent); if (bo == null) { bo = new CourseItem(); } _VMMapToBo(bo, boVM); if (!String.IsNullOrEmpty(boVM.ParentCourseItemId)) { bo.ParentCourseItem = _boRepository.GetSingle(Guid.Parse(boVM.ParentCourseItemId)); } else { bo.ParentCourseItem = bo; } if (!String.IsNullOrEmpty(boVM.CourseId)) { bo.Course = _courseRepository.GetSingle(Guid.Parse(boVM.CourseId)); } else { bo.Course = _courseRepository.GetAll().FirstOrDefault(); } if (!String.IsNullOrEmpty(boVM.CourseItemContentID) && bo.CourseItemContent == null) { bo.CourseItemContent = _courseItemContentRepository.GetSingle(Guid.Parse(boVM.CourseItemContentID)); } if (!String.IsNullOrEmpty(boVM.CreatorUserID)) { bo.Creator = await _userManager.FindByIdAsync(boVM.CreatorUserID); } // 检查和创建缺省的单元内容 if (bo.CourseItemContent == null) { bo.CourseItemContent = new CourseItemContent() { Name = bo.Name } } ; else { bo.CourseItemContent.Name = bo.Name; } var saveResult = await _boRepository.AddOrEditAndSaveAsyn(bo); return(saveResult); }
public static int Update(CourseItem inst) { string sql = "udpate courseItem set " + " courseId = " + inst.courseId + " ,title = '" + inst.title + "'" + " ,remark = '" + inst.remark + "'" + " ,filePath = '" + inst.filePath + "'" + " where id = " + inst.id; return(OleDbHelper.ExecuteCommand(sql)); }
public static int Add(CourseItem inst) { string sql = "insert into courseItem (courseId,title,remark,addtime,filePath) "; sql += string.Format(" values({0},'{1}','{2}','{3}','{4}')", inst.courseId, inst.title, inst.remark, DateTime.Now, inst.filePath); if (OleDbHelper.ExecuteCommand(sql) > 0) { return(OleDbHelper.GetScalar("select @@IDENTITY")); } return(0); }
public IActionResult courseItemDetails(String courseId, String courseItemName) { if (!courseItems.ContainsKey(courseId)) { return(new NotFoundObjectResult("Course item not found for particular courseId")); } CourseItem courseItem = courseItems[courseId].Find(e => e.Name.Equals(courseItemName)); return(new OkObjectResult(courseItem)); }
private void gridCourse_CellClick(object sender, GridViewCellEventArgs e) { if (e.RowIndex >= 0) { btnDelete.Enabled = true; btnEdit.Enabled = true; _courseItem = CourseService.GetCount().ToList()[e.RowIndex]; canPerformOtherAction = true; } }
private static CourseItem Read(DataRow r) { CourseItem inst = new CourseItem(); inst.id = CommonUtil.ParseInt(r["id"]); inst.courseId = CommonUtil.ParseInt(r["courseId"]); inst.title = CommonUtil.ParseStr(r["title"]); inst.remark = CommonUtil.ParseStr(r["remark"]); inst.addtime = CommonUtil.ParseStr(r["addtime"]); inst.filePath = CommonUtil.ParseStr(r["filePath"]); return(inst); }
public ActionResult Index() { var course = new CourseItem() { Id = 1, Name = "Bangla 1", Code = "1001", IsDelete = false }; CourseService courseCreateService = new CourseService(); //courseCreateService.Create(course); var courseITem = courseCreateService.Find(4); var courses = courseCreateService.GetAll(); return(View()); }
public async Task Then_Gets_Course_From_Api( string courseId, CourseItem apiResponse, [Frozen] Mock <IApiClient> mockApiClient, CourseService service) { mockApiClient .Setup(client => client.Get <CourseItem>( It.Is <GetCourseApiRequest>(request => request.GetUrl == $"courses/{courseId}"))) .ReturnsAsync(apiResponse); var result = await service.GetCourse(courseId); result.Should().BeEquivalentTo(apiResponse.Course); }
public static CourseItem GetById(int id) { string sql = string.Format("select * from courseItem where id = {0}", id); CourseItem inst = null; using (DataTable dt = OleDbHelper.GetDataSet(sql)) { foreach (DataRow r in dt.Rows) { inst = Read(r); } } return(inst); }
public void Constructor_WithNoneNullArguments_AssignsProperties() { // arrange var course = new Mock <ICourse>(); var opportunity = new Mock <Interfaces.IOpportunity>(); var provider = new Mock <IProvider>(); // act var actual = new CourseItem(course.Object, opportunity.Object, provider.Object); // assert Assert.NotNull(actual.Course); Assert.NotNull(actual.Opportunity); Assert.NotNull(actual.Provider); }
private async void CourseItemClick(object sender, ItemClickEventArgs e) { TempCourseItem = e.ClickedItem as CourseItem; // Init dialog data // Init data foreach (var c in CourseCategories) { if (c.CategoryID == TempCourseItem.CategoryID) { NewPointParentCategoryName.Text = c.CategoryName.ToUpper(); } } NewPointCategoryName.Text = TempCourseItem.Name; var bodoviTxt = ""; var minPoints = int.Parse(TempCourseItem.MinPoints.ToString()).ToString(); if (minPoints.EndsWith("1") && minPoints != "11") { bodoviTxt = "bod"; } else if (minPoints.EndsWith("2") || minPoints.EndsWith("3") || minPoints.EndsWith("4") && minPoints != "12" && minPoints != "13" && minPoints != "14") { bodoviTxt = "boda"; } else { bodoviTxt = "bodova"; } MaxNewPoints.Text = $"/{TempCourseItem.Points}"; MinNewPoints.Text = $"{TempCourseItem.MinPoints} {bodoviTxt}"; if (TempCourseItem.MinPoints < 1) { ConditionStackPanel.Visibility = Visibility.Collapsed; } NewPoints.Text = ""; // Open dialog await EditPointsDialog.ShowAsync(); }
protected static void sPopulateView <H, C, B>(Complex <H, C, B> view, CourseItem item, List <CourseItem> childItems) { view.ItemTitle = item.Title; view.ItemCode = item.Code; view.ItemDescription = item.Description; if (childItems != null && childItems.Count > 0) { string[][] data; data = childItems.Select(assignment => { return(new string[] { assignment.Title, assignment.Description, assignment.Code }); }).ToArray(); view.SetChildItems(data); } }
public ActionResult Add(HttpPostedFileBase upload, FormCollection fc) { int CourseId = (int)TempData["id"]; CourseItem File = new CourseItem(); File.CourseId = CourseId; File.Description = fc["desc"]; File.ContentType = upload.ContentType; File.FileName = System.IO.Path.GetFileName(upload.FileName); using (var reader = new System.IO.BinaryReader(upload.InputStream)) { File.Content = reader.ReadBytes(upload.ContentLength); } File.Course = db.Courses.Where(x => x.CourseId == CourseId).FirstOrDefault(); db.CourseItems.Add(File); db.SaveChanges(); return(RedirectToAction("Details", new { id = CourseId })); }
private void NewForm_Load(object sender, EventArgs e) { var semesterItems = SemesterService.GetCount().OrderBy(c => c.Id); var levels = LevelService.GetCount().OrderBy(c => c.Id); ddlSemester.DataSource = semesterItems.ToList().Select(c => c.Name); ddLevel.DataSource = levels.ToList().Select(c => c.Name); if (IsEdit) { CourseModel = CourseService.GetItem(Id); txtCode.Text = CourseModel.Code; txtTitle.Text = CourseModel.Title; nddUnit.Value = CourseModel.Unit; ddlSemester.SelectedIndex = ((IEnumerable <dynamic>)ddlSemester.DataSource).ToList().IndexOf(CourseModel.SemeterName); ddLevel.SelectedIndex = ((IEnumerable <dynamic>)ddLevel.DataSource).ToList().IndexOf(CourseModel.LevelName); } }
public async Task <CourseItemViewModel> Handle(AddCourseItemCommand request, CancellationToken cancellationToken) { var course = _courseRepo.GetQueryable().Include(x => x.Teacher).First(x => x.Id == request.CourseId); var item = new CourseItem { CourseId = request.CourseId, State = request.State, AdminMessageForTeacher = request.AdminMessageForTeacher, Order = request.Order != 0?request.Order:_courseItemRepo.GetQueryable().Count(x => x.CourseId == request.CourseId) + 1, Title = request.Title, ContentType = request.File != null?GetContentType(request.File.ContentType) : ContentType.File, FilePath = _coursesFileManager.GetFilePathForDownload(request.File, course.Teacher.UserName, request.CourseId), IsPreview = request.IsPreview }; await _coursesFileManager.SaveFile(request.File, course.Teacher.UserName, request.CourseId); await _courseItemRepo.AddAsync(item); return(_mapper.Map <CourseItemViewModel>(item)); }
private DescriptionLine[] GetDescription() { CourseItem courseItem = (CourseItem)(listBoxCourses.SelectedItem); Id <Course> id; if (courseItem == null) { id = Id <Course> .None; } else { id = courseItem.id; } courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(id)); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForUI); return(descFormatter.CreateDescription(false)); }
private void LoadData() { _sp.Children.Clear(); DynamicJson courseList = RestRC.BACARepository.Request(ApiList.courseList, string.Empty).AsDynamicJson(); dynamic categoryList = RestRC.BACARepository.Request(ApiList.categoryList, string.Empty).ToDynamicJson().list; if (categoryList != null) { foreach (DynamicJson category in categoryList) { if (category.GetStr("type") != "1") { continue; } IndexInfo catelogElement = new IndexInfo() { model = category }; catelogElement.Title.Content = category.GetStr("title"); foreach (DynamicJson course in courseList.GetChild <List <object> >("list")) { if (category.GetStr("id") == course.GetStr("basecoursecategoryid")) { CourseItem ci = new CourseItem(); ci._imgCourse.Source = AppResources.GetImageSource(course.GetStr("coverimg")); ci._imgCourse.Tag = course.GetStr("Id"); ci._imgTeacher.Source = AppResources.GetImageSource(course.GetChild <DynamicJson>("teacherEntity").GetStr("headimg")); ci._imgTeacher.Tag = course.GetStr("teacherid"); ci._tblDesc.Text = string.Format("教师:{0}\r\n{1}", course.GetChild <DynamicJson>("teacherEntity").GetStr("name"), course.GetStr("describeshort")); catelogElement._wpCourseItems.Children.Add(ci); ci._imgCourse.PreviewMouseLeftButtonUp += _imgCourse_PreviewMouseLeftButtonUp; ci._imgTeacher.PreviewMouseLeftButtonUp += _imgTeacher_PreviewMouseLeftButtonUp; } } _sp.Children.Add(catelogElement); } } }
public static Market DeserializeMarket(Market market) { string name = ""; var data = new List <CourseItem>(); try { using (FileStream stream = new FileStream(GetFileName(market), FileMode.Open)) { try { using (BinaryReader reader = new BinaryReader(stream)) { int ver = reader.ReadInt32(); name = reader.ReadString(); while (true) { var ticks = reader.ReadInt64(); var course = reader.ReadDouble(); double delta = reader.ReadDouble(); double vol = reader.ReadDouble(); var item = new CourseItem(new DateTime(ticks), course, delta, vol); data.Add(item); } } } catch (EndOfStreamException e) { } } market.CourseData = data.ToArray(); } catch (Exception e) { Console.WriteLine(e); throw; } return(market); }
public void readJSON(Uri location) { string text = new StreamReader(Application.GetResourceStream(location).Stream).ReadToEnd(); //Console.WriteLine(text); //JObject json = JObject.Parse(text); String[] yearTitles = { "Part II", "Part III", "Part IV" }; JArray courses = JArray.Parse(text); for (int i = 0; i < courses.Count; i++) { CourseSet cs = new CourseSet() { Title = yearTitles[i] }; JArray yearCourses = courses[i] as JArray; for (int j = 0; j < yearCourses.Count; j++) { JObject course = yearCourses[j] as JObject; CourseItem ci = new CourseItem(); ci.Name = course["name"].ToString(); ci.Code = course["code"].ToString(); ci.Points = course["points"].ToString(); ci.Desc = course["text"].ToString(); cs.CourseList.Add(ci.Code, ci); } CourseSets.Add(i, cs); } CurrentCourseSet = 0; }
private static void WriteModules(CourseItem ci, XmlTextWriter xw) { for (var i = 0; i < ci.Nodes.Count; i++) { if (ci.Nodes[i] is TrainingModule) { #region Запись учебных модулей var tm = ci.Nodes[i] as TrainingModule; xw.WriteStartElement("module"); xw.WriteAttributeString("name", tm.Text); xw.WriteAttributeString("type", "text"); xw.WriteAttributeString("id", "#module{" + tm.Id.ToString().ToUpper() + "}"); tm.XmlWriter.WriteXml(xw); RibbonStatusStripEx.Instance.MakeProgressStep(0); System.Windows.Forms.Application.DoEvents(); if (tm.Nodes.Count != 0) { WriteModules(tm, xw); } xw.WriteFullEndElement(); #endregion } else if (ci.Nodes[i] is TestModule) { #region Запись контролей var tm = ci.Nodes[i] as TestModule; tm.XmlWriter.WriteXml(xw); #endregion RibbonStatusStripEx.Instance.MakeProgressStep(0); System.Windows.Forms.Application.DoEvents(); } } }