Example #1
0
        public JsonResult Edit(Chapter model)
        {
            try
            {
                if (model.ChapterId > 0)
                {
                    var entity = _ChapterService.GetById(model.ChapterId);
                    //修改
                    entity.ChapterId = model.ChapterId;
                    entity.Title     = model.Title;
                    entity.UTime     = DateTime.Now;
                    entity.Sort      = model.Sort;
                    _ChapterService.Update(entity);
                }
                else
                {
                    if (_ChapterService.IsExistName(model.Title))
                    {
                        return(Json(new { Status = Successed.Repeat }, JsonRequestBehavior.AllowGet));
                    }
                    //添加
                    model.CTime = DateTime.Now;
                    model.UTime = DateTime.Now;

                    _ChapterService.Insert(model);
                }
                return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }
        }