public IActionResult Edit(string dsdid) { var code = RouteData.Values["id"]?.ToString(); var uinfo = new Application.UserAuthService(HttpContext).Get(); using (var db = new ContextBase()) { var ds = db.DocSet.Find(code); if (ds?.Uid != uinfo.UserId) { return(Content("unauthorized")); } } var mo = new DocSetDetail { DsCode = code }; if (!string.IsNullOrWhiteSpace(dsdid)) { using var db = new ContextBase(); mo = db.DocSetDetail.Where(x => x.DsdId == dsdid).FirstOrDefault(); } return(View(mo)); }
public IActionResult Edit(string dsdid) { var code = RouteData.Values["id"]?.ToString(); var uinfo = Apps.LoginService.Get(HttpContext); var ds = db.DocSet.Find(code); if (ds?.Uid != uinfo.UserId) { return(Content("unauthorized")); } var mo = new DocSetDetail { DsCode = code }; if (!string.IsNullOrWhiteSpace(dsdid)) { mo = db.DocSetDetail.FirstOrDefault(x => x.DsdId == dsdid); } return(View(mo)); }
public SharedResultVM Save(DocSetDetail mo) { var vm = Apps.LoginService.CompleteInfoValid(HttpContext); if (vm.Code == 200) { var uinfo = Apps.LoginService.Get(HttpContext); var ds = db.DocSet.Find(mo.DsCode); if (ds?.Uid != uinfo.UserId) { vm.Set(SharedEnum.RTag.unauthorized); } else { mo.DsdUpdateTime = DateTime.Now; mo.Uid = uinfo.UserId; if (string.IsNullOrWhiteSpace(mo.DsdPid)) { mo.DsdPid = Guid.Empty.ToString(); } if (!mo.DsdOrder.HasValue) { mo.DsdOrder = 99; } if (string.IsNullOrWhiteSpace(mo.DsdId)) { mo.DsdId = Core.UniqueTo.LongId().ToString(); mo.DsdCreateTime = mo.DsdUpdateTime; db.DocSetDetail.Add(mo); } else { //查询原创建时间 var currmo = db.DocSetDetail.FirstOrDefault(x => x.DsdId == mo.DsdId); if (currmo != null) { currmo.DsdTitle = mo.DsdTitle; currmo.DsdPid = mo.DsdPid; currmo.DsdOrder = mo.DsdOrder; currmo.DsdContentMd = mo.DsdContentMd; currmo.DsdContentHtml = mo.DsdContentHtml; db.DocSetDetail.Update(currmo); } } int num = db.SaveChanges(); vm.Set(num > 0); vm.Data = mo.DsdId; } } return(vm); }
public ActionResultVM Save(DocSetDetail mo) { var vm = new ActionResultVM(); var uinfo = new Application.UserAuthService(HttpContext).Get(); using (var db = new ContextBase()) { var ds = db.DocSet.Find(mo.DsCode); if (ds?.Uid != uinfo.UserId) { vm.Set(ARTag.unauthorized); } else { mo.DsdUpdateTime = DateTime.Now; mo.Uid = uinfo.UserId; if (string.IsNullOrWhiteSpace(mo.DsdPid)) { mo.DsdPid = Guid.Empty.ToString(); } if (!mo.DsdOrder.HasValue) { mo.DsdOrder = 99; } if (string.IsNullOrWhiteSpace(mo.DsdId)) { mo.DsdId = Core.UniqueTo.LongId().ToString(); mo.DsdCreateTime = mo.DsdUpdateTime; db.DocSetDetail.Add(mo); } else { //查询原创建时间 var currmo = db.DocSetDetail.AsNoTracking().FirstOrDefault(x => x.DsdId == mo.DsdId); mo.DsdCreateTime = currmo.DsdCreateTime; db.DocSetDetail.Update(mo); } int num = db.SaveChanges(); vm.Set(num > 0); vm.Data = mo.DsdId; } } return(vm); }
public ActionResultVM SaveCatalog(DocSetDetail mo) { var vm = new ActionResultVM(); var uinfo = new Application.UserAuthService(HttpContext).Get(); using var db = new ContextBase(); var ds = db.DocSet.Find(mo.DsCode); if (ds?.Uid != uinfo.UserId) { vm.Set(ARTag.unauthorized); return(vm); } mo.DsdOrder ??= 99; mo.DsdUpdateTime = DateTime.Now; if (string.IsNullOrWhiteSpace(mo.DsdPid)) { mo.DsdPid = Guid.Empty.ToString(); } if (string.IsNullOrWhiteSpace(mo.DsdId)) { mo.DsdId = Guid.NewGuid().ToString(); mo.DsdCreateTime = mo.DsdUpdateTime; mo.Uid = uinfo.UserId; db.DocSetDetail.Add(mo); } else { var currmo = db.DocSetDetail.Where(x => x.DsdId == mo.DsdId).FirstOrDefault(); currmo.DsdTitle = mo.DsdTitle; currmo.DsdOrder = mo.DsdOrder; currmo.DsdPid = mo.DsdPid; db.DocSetDetail.Update(currmo); } int num = db.SaveChanges(); vm.Set(num > 0); return(vm); }
public SharedResultVM SaveCatalog(DocSetDetail mo) { var vm = Apps.LoginService.CompleteInfoValid(HttpContext); if (vm.Code == 200) { var uinfo = Apps.LoginService.Get(HttpContext); var ds = db.DocSet.Find(mo.DsCode); if (ds?.Uid != uinfo.UserId) { vm.Set(SharedEnum.RTag.unauthorized); return(vm); } mo.DsdOrder ??= 99; mo.DsdUpdateTime = DateTime.Now; if (string.IsNullOrWhiteSpace(mo.DsdPid)) { mo.DsdPid = Guid.Empty.ToString(); } if (string.IsNullOrWhiteSpace(mo.DsdId)) { mo.DsdId = Guid.NewGuid().ToString(); mo.DsdCreateTime = mo.DsdUpdateTime; mo.Uid = uinfo.UserId; db.DocSetDetail.Add(mo); } else { var currmo = db.DocSetDetail.FirstOrDefault(x => x.DsdId == mo.DsdId); currmo.DsdTitle = mo.DsdTitle; currmo.DsdOrder = mo.DsdOrder; currmo.DsdPid = mo.DsdPid; db.DocSetDetail.Update(currmo); } int num = db.SaveChanges(); vm.Set(num > 0); } return(vm); }
public string SaveCatalog(DocSetDetail mo) { var uinfo = new Func.UserAuthAid(HttpContext).Get(); using (var db = new ContextBase()) { var ds = db.DocSet.Find(mo.DsCode); if (ds?.Uid != uinfo.UserId) { return("unauthorized"); } mo.DsdOrder = mo.DsdOrder ?? 99; mo.DsdUpdateTime = DateTime.Now; if (string.IsNullOrWhiteSpace(mo.DsdPid)) { mo.DsdPid = Guid.Empty.ToString(); } if (string.IsNullOrWhiteSpace(mo.DsdId)) { mo.DsdId = Guid.NewGuid().ToString(); mo.DsdCreateTime = mo.DsdUpdateTime; mo.Uid = uinfo.UserId; db.DocSetDetail.Add(mo); } else { var currmo = db.DocSetDetail.Where(x => x.DsdId == mo.DsdId).FirstOrDefault(); currmo.DsdTitle = mo.DsdTitle; currmo.DsdOrder = mo.DsdOrder; currmo.DsdPid = mo.DsdPid; db.DocSetDetail.Update(currmo); } int num = db.SaveChanges(); return(num > 0 ? "success" : "fail"); } }