public ActionResult CreateCourseNew([Bind(Include = "CourseId,Name,CourseStatus")] Course course) { if (Session["userId"] == null || Session["userId"].ToString() == "") { return(RedirectToAction("Index", "Home")); } ModelContext db = new ModelContext(); Service_Course service_Course = new Service_Course(); service_Course.ServiceId = TempData["serviceid"].ToString(); string cid = db.Courses.Max(x => x.CourseId); int id = Convert.ToInt32(cid.Substring(1, cid.Length - 1)) + 1; cid = cid.Substring(0, 1) + id; course.CourseId = cid; service_Course.CourseId = course.CourseId; if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); CreateServiceCourse(service_Course); return(RedirectToAction("Index")); } return(View(course)); // return Content(""+course.Name); }
public timed_course(Service_Course s) { name = s.name; train = s.train; start_time = s.start_time; route = s.route; max_speed_points = new List <speed_point>(); operate_speed_points = new List <speed_point>(); dewell_time = new List <float>(); }
public ActionResult CreateServiceCourse(Service_Course service_Course) { if (Session["userId"] == null || Session["userId"].ToString() == "") { return(RedirectToAction("Index", "Home")); } ModelContext db = new ModelContext(); db.Service_Courses.Add(service_Course); db.SaveChanges(); return(null); }