// // GET: /Course/ public ActionResult Index() { var courseCategoryModel = new CourseCategoryModel(); courseCategoryModel.CategoryCourseList = (List <CategoryCourse>)categoryCourseRepository.SelectAll(); courseCategoryModel.CourseList = (List <Course>)courseRepository.SelectAll(); return(View(courseCategoryModel)); }
public IHttpActionResult PostCourseCategory(CourseCategoryModel data) { try { var result = oSvc.PostCourseCategory(data); return(Ok(result)); } catch (Exception ex) { ExceptionModel exc = oException.Set(ex); return(Ok(exc)); } }
public IHttpActionResult PutCourseCategory(int?id, CourseCategoryModel data) { try { if (!id.HasValue) { return(BadRequest()); } var result = oSvc.PutCourseCategory(id.Value, data); return(Ok(result)); } catch (Exception ex) { ExceptionModel exc = oException.Set(ex); return(Ok(exc)); } }
public bool PutCourseCategory(int blogCategoryId, CourseCategoryModel data) { string xml = Helper.XmlSerializer <CourseCategoryModel>(data); using (var context = new SQLContext()) { SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@blogcategoryid", SqlDbType.Int); param[0].Value = blogCategoryId; param[1] = new SqlParameter("@data", SqlDbType.Xml); param[1].Value = xml; param[2] = new SqlParameter("@userid", SqlDbType.Int); param[2].Value = 0; context.Database.ExecuteSqlCommand( "[dbo].[s_put_course_category] @blogcategoryid, @data, @userid", param); return(true); } }
public IHttpActionResult DeleteCourseCategory(int?id) { try { if (!id.HasValue) { return(BadRequest()); } List <int?> ids = new List <int?>(); ids.Add(id.Value); var result = oSvc.DeleteCourseCategory(ids); return(Ok(result)); } catch (Exception ex) { CourseCategoryModel result = new CourseCategoryModel() { //Exception = _exception.Set(ExceptionType.CATCH, ex) }; return(Ok(ex)); }; }
public CourseCategoryModel PostCourseCategory(CourseCategoryModel data) { string xml = Helper.XmlSerializer <CourseCategoryModel>(data); using (var context = new SQLContext()) { SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@data", SqlDbType.Xml); param[0].Value = xml; param[1] = new SqlParameter("@userid", SqlDbType.Int); param[1].Value = 0; var insert = context.Database.SqlQuery <CourseCategoryModel>("s_post_course_category @data, @userid", param); CourseCategoryModel result = insert.FirstOrDefault(); if (result != null) { return(result); } return(data); } }