/// <summary> /// 保存一条回复(管理) /// </summary> /// <param name="mo"></param> /// <returns></returns> public ActionResultVM ReplyAdminSave(Domain.UserReply mo) { var vm = new ActionResultVM(); var uinfo = new Application.UserAuthService(HttpContext).Get(); var oldmo = db.UserReply.FirstOrDefault(x => x.UrId == mo.UrId); if (oldmo != null) { oldmo.UrAnonymousName = mo.UrAnonymousName; oldmo.UrAnonymousMail = mo.UrAnonymousMail; oldmo.UrAnonymousLink = mo.UrAnonymousLink; oldmo.UrStatus = mo.UrStatus; db.UserReply.Update(oldmo); int num = db.SaveChanges(); vm.Set(num > 0); } return(vm); }
public SharedResultVM ReplyAdd([FromForm] Domain.UserReply mo, [FromForm] string id) { var vm = new SharedResultVM(); try { if (string.IsNullOrWhiteSpace(id)) { vm.Set(SharedEnum.RTag.invalid); } else if (string.IsNullOrWhiteSpace(mo.UrContent)) { vm.Set(SharedEnum.RTag.invalid); vm.Msg = "回复内容不能为空"; } else { vm = Apps.LoginService.CompleteInfoValid(HttpContext); if (vm.Code == 200) { var uinfo = Apps.LoginService.Get(HttpContext); var guffmo = db.GuffRecord.Find(id); if (guffmo == null) { vm.Set(SharedEnum.RTag.invalid); } else { mo.Uid = uinfo.UserId; mo.UrTargetType = Application.EnumService.ConnectionType.GuffRecord.ToString(); mo.UrTargetId = id; mo.UrCreateTime = DateTime.Now; mo.UrStatus = 1; mo.UrTargetPid = 0; mo.UrAnonymousLink = ParsingTo.JsSafeJoin(mo.UrAnonymousLink); db.UserReply.Add(mo); guffmo.GrReplyNum += 1; db.GuffRecord.Update(guffmo); int num = db.SaveChanges(); vm.Set(num > 0); } } } } catch (Exception ex) { vm.Set(ex); Apps.FilterConfigs.WriteLog(HttpContext, ex); } return(vm); }
public ActionResultVM ReplyAdd(Domain.UserReply mo, string id) { var vm = new ActionResultVM(); try { var uinfo = new Application.UserAuthService(HttpContext).Get(); if (HttpContext.User.Identity.IsAuthenticated) { mo.Uid = uinfo.UserId; } else { if (string.IsNullOrWhiteSpace(mo.UrAnonymousName) || !Fast.ParsingTo.IsMail(mo.UrAnonymousMail)) { vm.Set(ARTag.invalid); vm.Msg = "昵称、邮箱不能为空"; return(vm); } mo.Uid = 0; } if (string.IsNullOrWhiteSpace(id)) { vm.Set(ARTag.invalid); } else if (string.IsNullOrWhiteSpace(mo.UrContent)) { vm.Set(ARTag.invalid); vm.Msg = "回复内容不能为空"; } else { var guffmo = db.GuffRecord.Find(id); if (guffmo == null) { vm.Set(ARTag.invalid); } else { mo.Uid = uinfo.UserId; mo.UrTargetType = Application.EnumService.ConnectionType.GuffRecord.ToString(); mo.UrTargetId = id; mo.UrCreateTime = DateTime.Now; mo.UrStatus = 1; mo.UrTargetPid = 0; mo.UrAnonymousLink = Fast.ParsingTo.JsSafeJoin(mo.UrAnonymousLink); db.UserReply.Add(mo); guffmo.GrReplyNum += 1; db.GuffRecord.Update(guffmo); int num = db.SaveChanges(); vm.Set(num > 0); } } } catch (Exception ex) { vm.Set(ex); Filters.FilterConfigs.WriteLog(HttpContext, ex); } return(vm); }