Esempio n. 1
0
 public ActionResult ViewCourse(int?id)
 {
     DAL.Entities           DC = new DAL.Entities();
     StarDev.Models.Courses _m = new Models.Courses();
     _m.ShowCourse = DC.ViewCourse.Where(x => x.ShowCourseID == id).ToList();
     return(View(_m));
 }
        public ActionResult Edit(int id)
        {
            var m = new Models.Courses();
            var i = tdb.Courses.First(t => t.ID == id);

            return(View(i));
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var coursesID = Request.QueryString["ID"];

            if (coursesID == null)
            {
                Contoso.Models.Courses courses = new Contoso.Models.Courses();
                courses.Title        = txtTitle.Text;
                courses.Credits      = Convert.ToInt32(txtCredits.Text);
                courses.DepartmentID = Convert.ToInt32(ddlDepartmentID.SelectedValue);
                courses.CreatedDate  = Convert.ToDateTime(txtCreatedDate.Text);
                courses.CreatedBy    = txtCreatedBy.Text;
                courses.UpdatedDate  = Convert.ToDateTime(txtUpdatedDate.Text);
                courses.UpdatedBy    = txtUpdatedBy.Text;

                CoursesService coursesService = new CoursesService();
                coursesService.AddCourses(courses);
            }
            if (coursesID != null)
            {
                Contoso.Models.Courses courses = new Models.Courses();
                courses.ID           = Convert.ToInt32(coursesID);
                courses.Title        = txtTitle.Text;
                courses.Credits      = Convert.ToInt32(txtCredits.Text);
                courses.DepartmentID = Convert.ToInt32(ddlDepartmentID.SelectedValue);
                courses.CreatedDate  = Convert.ToDateTime(txtCreatedDate.Text);
                courses.CreatedBy    = txtCreatedBy.Text;
                courses.UpdatedDate  = Convert.ToDateTime(txtUpdatedDate.Text);
                courses.UpdatedBy    = txtUpdatedBy.Text;

                CoursesService coursesService = new CoursesService();
                coursesService.UpdateCourses(courses);
            }
        }
Esempio n. 4
0
        public ActionResult Courses(int page = 1)
        {
            DAL.Entities           DC = new DAL.Entities();
            StarDev.Models.Courses _m = new Models.Courses();
            int TotalCount            = DC.Courses.Count();
            int PageItem = 6;
            int skip     = (page - 1) * PageItem;

            ViewBag.pageId    = page;
            ViewBag.pageCount = (TotalCount / PageItem);
            if (TotalCount % PageItem != 0)
            {
                ViewBag.PageCount = (TotalCount / PageItem) + 1;
            }
            _m.GetAllCourse = DC.Courses.OrderBy(x => x.CourseID).Skip(skip).Take(PageItem).ToList();
            return(View(_m));
        }
 public ActionResult coursesAdd(Models.Courses courses)
 {
     try
     {
         tdb.Courses.Add(courses);
         if (courses.Nums <= 0)
         {
             return(Content("nums err"));
         }
         tdb.SaveChanges();
         return(Content("ok"));
     }
     catch
     {
         return(Content("err"));
     }
 }
Esempio n. 6
0
        public ActionResult Course(string name)
        {
            DAL.Entities           DC = new DAL.Entities();
            StarDev.Models.Courses _m = new Models.Courses();
            var q = (from A in DC.Courses
                     where
                     (!string.IsNullOrEmpty(name) ? A.Title.Contains(name) || A.content.Contains(name) : true)
                     select A).ToList();

            _m.GetAllCourse = q;

            if (q.Count > 0)
            {
                return(View(_m));
            }
            else
            {
                return(RedirectToAction("NotFound", "Home"));
            }
        }
 public ActionResult editCourses(Models.Courses courses)
 {
     try
     {
         var id = tdb.Courses.First(t => t.ID == courses.ID);
         id.Name = courses.Name;
         if (courses.Nums <= 0)
         {
             return(Content("nums err"));
         }
         id.Nums    = courses.Nums;
         id.MajorID = courses.MajorID;
         id.Term    = courses.Term;
         id.Memo    = courses.Memo;
         id.Status  = courses.Status;
         tdb.SaveChanges();
         return(Content("ok"));
     }
     catch
     {
         return(Content("err"));
     }
 }