// GET: Course public ActionResult CourseInfo(int id) { cId = id; Course course = _courseBll.GetById(id); int orgnizationId = course.Organizationid; List <Organization> orglist = _organizationBll.GetAll(); ViewBag.OrgList = new SelectList(orglist, "Id", "Name", orgnizationId); List <Course> list = _courseBll.GetAll().Where(e => e.Organizationid == orgnizationId).ToList(); ViewBag.CourseId = new SelectList(list, "Id", "Name", cId); //ViewBag.CourseId = new SelectList(new List<Course>(), "Id", "Name"); ViewBag.Examtype = _examTypeBll.GetAll() .Select(c => new SelectListItem() { Value = c.Examtype.ToString(), Text = c.ExamtypeName }).ToList(); ViewBag.Id = new SelectList(new List <Organization>(), "Id", "Name"); // .Select(c => new SelectListItem() // { // Value = c.Id.ToString(), // Text = c.Name // }).ToList(); return(View()); }
public JsonResult GetById([FromForm] int courseId) { DataResult dr = new DataResult(); try { CourseBLL courseBLL = new CourseBLL(); CourseEntity courseEntity = courseBLL.GetById(courseId); courseEntity.videoUrl = ""; TeacherBLL teacherBLL = new TeacherBLL(); courseEntity.teacherEntity = teacherBLL.GetById(courseEntity.teacherId); CourseOrderBLL courseOrderBLL = new CourseOrderBLL(); courseEntity.countSold = courseOrderBLL.GetCountByCourseId(courseEntity.courseId); dr.code = "200"; dr.data = courseEntity; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }
protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e) { try { string id = Convert.ToString(e.CommandArgument); if (!string.IsNullOrEmpty(id)) { CourseBLL courseBLL = new CourseBLL(); DataTable dt = courseBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id))); if (dt != null) { if (dt.Rows.Count > 0) { string actionStatus = "Updated"; Courses course = new Courses(); course.CourseId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CourseId"])); course.CourseCode = Convert.ToString(dt.Rows[0]["CourseCode"]); course.Name = Convert.ToString(dt.Rows[0]["Name"]); course.Description = Convert.ToString(dt.Rows[0]["Description"]); course.Attachment = Convert.ToString(dt.Rows[0]["Attachment"]); course.IsActive = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"])); course.CreatedDate = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"])); course.CreatedBy = Convert.ToString(dt.Rows[0]["CreatedBy"]); course.CreatedFrom = Convert.ToString(dt.Rows[0]["CreatedFrom"]); course.UpdatedDate = DateTime.Now; course.UpdatedBy = UserInfo; course.UpdatedFrom = StationInfo; if (course.IsActive) { course.IsActive = false; actionStatus = "Deactivated"; } else { course.IsActive = true; actionStatus = "Activated"; } if (courseBLL.Update(course)) { Alert(AlertType.Success, actionStatus + " successfully."); LoadList(); } else { Alert(AlertType.Error, "Failed to update."); } } } } } catch (Exception) { Alert(AlertType.Error, "Failed to process."); } }
public ActionResult BatchNo() { var model = new BatchEntryCreateForView(); if (ModelState.IsValid) { int id = _bId; Batch batch = _batchEntryBll.GetById(id); var courseId = batch.CourseId; var course = _courseEntryBll.GetById(courseId); model = Mapper.Map <BatchEntryCreateForView>(batch); var organizationId = course.Organizationid; model.OrganizationId = organizationId; List <Organization> olist = _organizationBll.GetAll(); ViewBag.BatchOrganizationList = new SelectList(olist, "Id", "Name", organizationId);//If I not Write OrganizationId It also work Bcz Model Also contain OrganizationId //var courseId = course.Id; List <Course> clist = _courseEntryBll.GetAll(); ViewBag.BatchCourseList = new SelectList(clist, "Id", "Name", courseId);//If I not Write CourseId It also work Bcz Model Also contain CourseId } return(View(model)); }
public JsonResult GetDetailById([FromForm] string token, [FromForm] int courseId) { DataResult dr = new DataResult(); try { UserEntity userEntity = this.GetUserByToken(token); CourseOrderBLL courseOrderBLL = new CourseOrderBLL(); CourseOrderEntity courseOrderEntity = courseOrderBLL.GetByCourseAndUserId(courseId, userEntity.userId); if (courseOrderEntity == null) { dr.code = "201"; dr.msg = "未购买该课程"; return(Json(dr)); } CourseBLL courseBLL = new CourseBLL(); CourseEntity courseEntity = courseBLL.GetById(courseId); CourseSectionBLL courseSectionBLL = new CourseSectionBLL(); courseEntity.courseSectionEntities = courseSectionBLL.ListByCourseId(courseId); TeacherBLL teacherBLL = new TeacherBLL(); courseEntity.teacherEntity = teacherBLL.GetById(courseEntity.teacherId); courseEntity.countSold = courseOrderBLL.GetCountByCourseId(courseEntity.courseId); dr.code = "200"; dr.data = courseEntity; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }
private void Edit(int id) { try { CourseBLL courseBLL = new CourseBLL(); DataTable dt = courseBLL.GetById(id); if (dt != null) { if (dt.Rows.Count > 0) { this.ModelId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CourseId"])); this.ModelCode = Convert.ToString(dt.Rows[0]["CourseCode"]); txtName.Text = Convert.ToString(dt.Rows[0]["Name"]); txtDescription.Text = Convert.ToString(dt.Rows[0]["Description"]); this.ModelAttachment = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["Attachment"]))) ? string.Empty : Convert.ToString(dt.Rows[0]["Attachment"]); } } } catch (Exception) { Alert(AlertType.Error, "Failed to edit."); } }
public IActionResult GetById(int id = 0) { var response = logicBll.GetById(id); return(StatusCode((int)response.Message.Status, response)); }
/// <summary> /// 详细页面 /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Detail(int id) { CourseEntity courseEntity = courseBLL.GetById(id); return(View(courseEntity)); }
private void SaveAndUpdate() { try { if (string.IsNullOrEmpty(txtName.Text)) { Alert(AlertType.Warning, "Enter course name."); txtName.Focus(); } else { string name = Convert.ToString(txtName.Text); string description = Convert.ToString(txtDescription.Text); string attachment = string.Empty; if (fuAttachment.HasFile) { attachment = UploadAttachment(); } else { attachment = this.ModelAttachment; } CourseBLL courseBLL = new CourseBLL(); if (this.ModelId > 0) { DataTable dt = courseBLL.GetById(this.ModelId); Courses course = new Courses(); course.CourseId = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CourseId"])); course.CourseCode = Convert.ToString(dt.Rows[0]["CourseCode"]); course.Name = Convert.ToString(dt.Rows[0]["Name"]); course.Description = Convert.ToString(dt.Rows[0]["Description"]); course.Attachment = Convert.ToString(dt.Rows[0]["Attachment"]); course.IsActive = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"])); course.CreatedDate = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"])); course.CreatedBy = Convert.ToString(dt.Rows[0]["CreatedBy"]); course.CreatedFrom = Convert.ToString(dt.Rows[0]["CreatedFrom"]); course.Name = name.Trim(); course.Description = description; course.Attachment = attachment; course.UpdatedDate = DateTime.Now; course.UpdatedBy = this.UserInfo; course.UpdatedFrom = this.StationInfo; if (courseBLL.Update(course)) { this.MultiEntryDisallow = true; Alert(AlertType.Success, "Updated successfully."); ClearFields(); } else { Alert(AlertType.Error, "Failed to update."); } } else { Courses course = new Courses(); course.CourseCode = this.ModelCode; course.Name = name.Trim(); course.Description = description; course.Attachment = attachment; course.IsActive = true; course.CreatedDate = DateTime.Now; course.CreatedBy = this.UserInfo; course.CreatedFrom = this.StationInfo; if (courseBLL.Save(course)) { Alert(AlertType.Success, "Saved successfully."); ClearFields(); GenerateCode(); } else { Alert(AlertType.Error, "Failed to save."); } } } } catch (Exception ex) { Alert(AlertType.Error, ex.Message.ToString()); } }