Beispiel #1
0
 public int Update(TrainBaseLesson trainBaseLesson)
 {
     using (_db = new ApplicationDbContext())
     {
         _db.Entry(trainBaseLesson).State = System.Data.Entity.EntityState.Modified;
         return(_db.SaveChanges());
     }
 }
Beispiel #2
0
 public AppConfigs.OperResult  AddLesson(TrainBaseLesson trainbaseLesson)
 {
     using (_db = new ApplicationDbContext())
     {
         _db.Entry(trainbaseLesson).State = EntityState.Added;
         return(_db.SaveChanges() > 0?AppConfigs.OperResult.success:AppConfigs.OperResult.failUnknown);
     }
 }
Beispiel #3
0
        public ActionResult Edit(TrainBaseLesson trainBaseLesson)
        {
            if (trainBaseLesson.Id == null)
            {
                throw new Exception("no id found.");
            }

            if (ModelState.IsValid)
            {
                if (trainBaseLesson.ImagePath == null)
                {
                    trainBaseLesson.ImagePath = AppConfigs.defaultImagePath;
                }
                int i = _lessonSv.Update(trainBaseLesson);
                return(Json(new { i }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { error = "model error" }, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult Add([Bind(Exclude = "Maker,MakeDay,ClickTimes,VideoCount,OrderCode")] TrainBaseLesson trainBaseLesson)
        {
            var result = new OperResultModel();

            if (ModelState.IsValid)
            {
                trainBaseLesson.MakeDay    = DateTime.Now;
                trainBaseLesson.Maker      = MyUserId;
                trainBaseLesson.ClickTimes = 0;
                trainBaseLesson.VideoCount = 0;
                result.OperResult          = _lessonSv.AddLesson(trainBaseLesson);
                result.Message             = "success";
            }

            if (!_lessonBLL.Exist(trainBaseLesson.Id))
            {
                result.OperResult = AppConfigs.OperResult.failDueToExist;
                result.Message    = "record not found ";
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }