Пример #1
0
 public void CreateNewCourse(Course course)
 {
     var test= courseContext.Courses.Max(z =>  z.CourseID.Substring(2));
       course.CourseID = "CR" + (Convert.ToInt32(test)+1);
     courseContext.Courses.Add(course);
     courseContext.SaveChanges();
 }
Пример #2
0
        public ActionResult Create(Course course)
        {
            if (ModelState.IsValid)
            {
                CreateModificationDetails(course);
                _repository.CreateNewCourse(course);
                return RedirectToAction("Index");
            }

            return View(course);
        }
Пример #3
0
 public void UpdateCourse(Course course)
 {
     courseContext.Entry(course).State = EntityState.Modified;
     courseContext.SaveChanges();
 }
Пример #4
0
 public void CreateModificationDetails(Course course)
 {
     course.ModificationType = "Created";
     ModificationDetails(course);
 }
Пример #5
0
 public void ModificationDetails(Course course)
 {
     course.ModifiedDate = DateTime.Now;
     course.ModifiedBy = Convert.ToString(Session["UserID"]);
 }
Пример #6
0
 public ActionResult Edit(Course course)
 {
     if (ModelState.IsValid)
     {
         UpdateModificationDetails(course);
         _repository.UpdateCourse(course);
         return RedirectToAction("Index");
     }
     return View(course);
 }