Beispiel #1
0
 public ActionResult CreateCourse(TMS_CourseMaster formObj)
 {
     try
     {
         if (formObj.CourseId == 0)
         {
             TMS_CourseMaster obj = new TMS_CourseMaster();
             obj.CourseName  = formObj.CourseName;
             obj.Duration    = formObj.Duration;
             obj.Description = formObj.Description;
             obj.IsActive    = true;
             obj.CreatedBy   = ((TMS_UserMaster)Session["UserDetails"]).UserId;
             obj.CreatedOn   = DateTime.Today;
             obj.ModifiedBy  = ((TMS_UserMaster)Session["UserDetails"]).UserId;
             obj.ModifiedOn  = DateTime.Today;
             db.TMS_CourseMaster.Add(obj);
             db.SaveChanges();
             TempData["Success"] = formObj.CourseName + " Course Created Successfully.";
         }
         else
         {
             TMS_CourseMaster obj = db.TMS_CourseMaster.Where(x => x.CourseId == formObj.CourseId).FirstOrDefault();
             obj.CourseName  = formObj.CourseName;
             obj.Duration    = formObj.Duration;
             obj.Description = formObj.Description;
             obj.ModifiedBy  = ((TMS_UserMaster)Session["UserDetails"]).UserId;
             obj.ModifiedOn  = DateTime.Today;
             db.SaveChanges();
             TempData["Success"] = formObj.CourseName + " Updated Successfully";
         }
     }
     catch (Exception)
     { TempData["Danger"] = "Invalid request./ Data Invalid"; }
     return(RedirectToAction("CreateCourse"));
 }
Beispiel #2
0
        public ActionResult CreateCourse(int?id)
        {
            TMS_CourseMaster obj = new TMS_CourseMaster();

            if (id != null)
            {
                obj        = db.TMS_CourseMaster.Where(x => x.CourseId == id).FirstOrDefault();
                ViewBag.id = id;
            }
            ViewBag.List = db.TMS_CourseMaster.Where(x => x.IsActive == true).ToList().OrderByDescending(x => x.CourseId);
            return(View(obj));
        }