public ActionResult Save(SysCarousel entity) { if (entity.Id == 0) { if (_syscarouselService.IsExist(entity.Id)) { return(Json(new CommonResult { Success = false, Message = "标题已经存在,请重新输入!" }, "text/html", JsonRequestBehavior.AllowGet)); } base._syscarouselService.Save(entity); } else { var model = base._syscarouselService.Get(entity.Id); model.Title = entity.Title; model.Img = entity.Img; model.OrderNo = entity.OrderNo; model.Url = entity.Url; model.IsEnabled = entity.IsEnabled; base._syscarouselService.Update(model); } return(Json(new CommonResult { Success = true, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet)); }
public ActionResult AddOrEdit(int?id) { var list = base._syscarouselService.LoadAllEnable(); SysCarousel entity = null; if (!string.IsNullOrEmpty(id.ToString())) { entity = base._syscarouselService.Get(Convert.ToInt32(id)); } entity = entity ?? new SysCarousel { Title = string.Empty, }; return(View(entity)); }