Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public SharedResultVM LsitReplySave(UserReply mo, UserMessage um)
        {
            var vm = new SharedResultVM();

            vm = Apps.LoginService.CompleteInfoValid(HttpContext);
            if (vm.Code == 200)
            {
                if (!mo.Uid.HasValue || string.IsNullOrWhiteSpace(mo.UrContent) || string.IsNullOrWhiteSpace(mo.UrTargetId))
                {
                    vm.Set(SharedEnum.RTag.lack);
                }
                else
                {
                    var uinfo = Apps.LoginService.Get(HttpContext);
                    mo.Uid = uinfo.UserId;

                    var now = DateTime.Now;

                    //回复消息
                    um.UmId         = UniqueTo.LongId().ToString();
                    um.UmTriggerUid = mo.Uid;
                    um.UmType       = Application.EnumService.MessageType.UserWriting.ToString();
                    um.UmTargetId   = mo.UrTargetId;
                    um.UmAction     = 2;
                    um.UmStatus     = 1;
                    um.UmContent    = mo.UrContent;
                    um.UmCreateTime = now;

                    //回复内容
                    mo.UrCreateTime = now;
                    mo.UrStatus     = 1;
                    mo.UrTargetPid  = 0;
                    mo.UrTargetType = Application.EnumService.ReplyType.UserWriting.ToString();

                    mo.UrAnonymousLink = ParsingTo.JsSafeJoin(mo.UrAnonymousLink);

                    db.UserReply.Add(mo);

                    //回填文章最新回复记录
                    var mow = db.UserWriting.FirstOrDefault(x => x.UwId.ToString() == mo.UrTargetId);
                    if (mow != null)
                    {
                        mow.UwReplyNum += 1;
                        mow.UwLastUid   = mo.Uid;
                        mow.UwLastDate  = now;

                        um.UmTargetIndex = mow.UwReplyNum;

                        db.UserWriting.Update(mow);
                    }

                    if (um.Uid != um.UmTriggerUid)
                    {
                        db.UserMessage.Add(um);
                    }

                    int num = db.SaveChanges();

                    vm.Set(num > 0);
                }
            }

            return(vm);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 回复
        /// </summary>
        /// <param name="mo">回复信息</param>
        /// <param name="um">消息通知</param>
        /// <returns></returns>
        public ActionResultVM LsitReplySave(UserReply mo, UserMessage um)
        {
            var vm = new ActionResultVM();

            var uinfo = new UserAuthAid(HttpContext).Get();

            if ((uinfo.UserId != 0 && string.IsNullOrWhiteSpace(uinfo.Nickname)) || (uinfo.UserId == 0 && string.IsNullOrWhiteSpace(mo.UrAnonymousName)))
            {
                vm.Set(ARTag.refuse);
                vm.msg = "昵称不能为空";

                return(vm);
            }

            mo.Uid = uinfo.UserId;

            var now = DateTime.Now;

            //回复消息
            um.UmId         = UniqueTo.LongId().ToString();
            um.UmTriggerUid = mo.Uid;
            um.UmType       = EnumAid.MessageType.UserWriting.ToString();
            um.UmTargetId   = mo.UrTargetId;
            um.UmAction     = 2;
            um.UmStatus     = 1;
            um.UmContent    = mo.UrContent;
            um.UmCreateTime = now;

            using (var db = new ContextBase())
            {
                //回复内容
                mo.UrCreateTime = now;
                mo.UrStatus     = 1;
                mo.UrTargetPid  = 0;
                mo.UrTargetType = EnumAid.ReplyType.UserWriting.ToString();

                mo.UrAnonymousLink = ParsingTo.JsSafeJoin(mo.UrAnonymousLink);

                db.UserReply.Add(mo);

                //回填文章最新回复记录
                var mow = db.UserWriting.FirstOrDefault(x => x.UwId.ToString() == mo.UrTargetId);
                if (mow != null)
                {
                    mow.UwReplyNum += 1;
                    mow.UwLastUid   = mo.Uid;
                    mow.UwLastDate  = now;

                    um.UmTargetIndex = mow.UwReplyNum;

                    db.UserWriting.Update(mow);
                }

                if (um.Uid != um.UmTriggerUid)
                {
                    db.UserMessage.Add(um);
                }

                int num = db.SaveChanges();

                vm.Set(num > 0);
            }

            return(vm);
        }
Exemplo n.º 4
0
        public ActionResultVM ReplyAdd(UserReply mo, string id)
        {
            var vm = new ActionResultVM();

            try
            {
                var uinfo = new UserAuthAid(HttpContext).Get();

                if (HttpContext.User.Identity.IsAuthenticated)
                {
                    mo.Uid = uinfo.UserId;
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(mo.UrAnonymousName) || !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
                {
                    using var db = new ContextBase();
                    var guffmo = db.GuffRecord.Find(id);
                    if (guffmo == null)
                    {
                        vm.Set(ARTag.invalid);
                    }
                    else
                    {
                        mo.Uid          = uinfo.UserId;
                        mo.UrTargetType = EnumAid.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);
                ConsoleTo.Log(ex);
            }

            return(vm);
        }
Exemplo n.º 5
0
        public ActionResultVM Update(GuffRecord mo)
        {
            var vm = new ActionResultVM();

            try
            {
                var uinfo = new UserAuthAid(HttpContext).Get();

                if (string.IsNullOrWhiteSpace(mo.GrContent) && string.IsNullOrWhiteSpace(mo.GrImage) && string.IsNullOrWhiteSpace(mo.GrAudio) && string.IsNullOrWhiteSpace(mo.GrVideo))
                {
                    vm.code = 1;
                    vm.msg  = "内容不能为空(内容、图片、音频、视频 至少有一项有内容)";
                }
                else if (string.IsNullOrWhiteSpace(mo.GrTag))
                {
                    vm.code = 2;
                    vm.msg  = "标签不能为空";
                }
                else if (uinfo.UserId == 0)
                {
                    vm.Set(ARTag.unauthorized);
                }
                else
                {
                    using var db = new ContextBase();
                    var currMo = db.GuffRecord.Find(mo.GrId);

                    if (currMo == null)
                    {
                        vm.Set(ARTag.invalid);
                    }
                    else
                    {
                        currMo.GrTypeName  = ParsingTo.JsSafeJoin(mo.GrTypeName);
                        currMo.GrTypeValue = ParsingTo.JsSafeJoin(mo.GrTypeValue);
                        currMo.GrObject    = ParsingTo.JsSafeJoin(mo.GrObject);

                        currMo.GrContent   = mo.GrContent;
                        currMo.GrContentMd = mo.GrContentMd;

                        currMo.GrImage  = ParsingTo.JsSafeJoin(mo.GrImage);
                        currMo.GrAudio  = ParsingTo.JsSafeJoin(mo.GrAudio);
                        currMo.GrVideo  = ParsingTo.JsSafeJoin(mo.GrVideo);
                        currMo.GrFile   = ParsingTo.JsSafeJoin(mo.GrFile);
                        currMo.GrRemark = mo.GrRemark;

                        currMo.GrTag        = mo.GrTag;
                        currMo.GrUpdateTime = DateTime.Now;
                        currMo.GrOpen       = mo.GrOpen ?? 1;

                        db.Update(currMo);

                        int num = db.SaveChanges();

                        vm.data = mo.GrId;
                        vm.Set(num > 0);
                    }
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                ConsoleTo.Log(ex);
            }

            return(vm);
        }
Exemplo n.º 6
0
        public ActionResultVM Add(GuffRecord mo)
        {
            var vm = new ActionResultVM();

            try
            {
                var uinfo = new UserAuthAid(HttpContext).Get();

                if (string.IsNullOrWhiteSpace(mo.GrContent) && string.IsNullOrWhiteSpace(mo.GrImage) && string.IsNullOrWhiteSpace(mo.GrAudio) && string.IsNullOrWhiteSpace(mo.GrVideo))
                {
                    vm.code = 1;
                    vm.msg  = "内容不能为空(内容、图片、音频、视频 至少有一项有内容)";
                }
                else if (string.IsNullOrWhiteSpace(mo.GrTag))
                {
                    vm.code = 2;
                    vm.msg  = "标签不能为空";
                }
                else if (uinfo.UserId == 0)
                {
                    vm.Set(ARTag.unauthorized);
                }
                else
                {
                    using var db = new ContextBase();

                    if (db.UserInfo.Find(uinfo.UserId).UserMailValid != 1)
                    {
                        vm.code = 1;
                        vm.msg  = "请先验证邮箱";
                    }
                    else
                    {
                        var now = DateTime.Now;

                        mo.Uid          = uinfo.UserId;
                        mo.GrId         = UniqueTo.LongId().ToString();
                        mo.GrCreateTime = now;
                        mo.GrUpdateTime = now;
                        mo.GrStatus     = 1;
                        mo.GrReadNum    = 0;
                        mo.GrLaud       = 0;
                        mo.GrMark       = 0;
                        mo.GrReplyNum   = 0;
                        mo.GrOpen ??= 1;

                        mo.GrTypeName  = ParsingTo.JsSafeJoin(mo.GrTypeName);
                        mo.GrTypeValue = ParsingTo.JsSafeJoin(mo.GrTypeValue);
                        mo.GrObject    = ParsingTo.JsSafeJoin(mo.GrObject);
                        mo.GrImage     = ParsingTo.JsSafeJoin(mo.GrImage);
                        mo.GrAudio     = ParsingTo.JsSafeJoin(mo.GrAudio);
                        mo.GrVideo     = ParsingTo.JsSafeJoin(mo.GrVideo);
                        mo.GrFile      = ParsingTo.JsSafeJoin(mo.GrFile);
                        mo.GrTag       = ParsingTo.JsSafeJoin(mo.GrTag);

                        db.GuffRecord.Add(mo);

                        int num = db.SaveChanges();

                        vm.data = mo.GrId;
                        vm.Set(num > 0);
                    }
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                ConsoleTo.Log(ex);
            }

            return(vm);
        }
Exemplo n.º 7
0
        public SharedResultVM Update([FromForm] Domain.GuffRecord mo)
        {
            var vm = new SharedResultVM();

            try
            {
                var uinfo = Apps.LoginService.Get(HttpContext);

                if (string.IsNullOrWhiteSpace(mo.GrContent) && string.IsNullOrWhiteSpace(mo.GrImage) && string.IsNullOrWhiteSpace(mo.GrAudio) && string.IsNullOrWhiteSpace(mo.GrVideo))
                {
                    vm.Code = 1;
                    vm.Msg  = "内容不能为空(内容、图片、音频、视频 至少有一项有内容)";
                }
                else if (string.IsNullOrWhiteSpace(mo.GrTag))
                {
                    vm.Code = 2;
                    vm.Msg  = "标签不能为空";
                }
                else if (uinfo.UserId == 0)
                {
                    vm.Set(SharedEnum.RTag.unauthorized);
                }
                else
                {
                    var currMo = db.GuffRecord.Find(mo.GrId);

                    if (currMo == null)
                    {
                        vm.Set(SharedEnum.RTag.invalid);
                    }
                    else if (currMo.Uid != uinfo.UserId)
                    {
                        vm.Set(SharedEnum.RTag.unauthorized);
                    }
                    else
                    {
                        currMo.GrTypeName  = ParsingTo.JsSafeJoin(mo.GrTypeName);
                        currMo.GrTypeValue = ParsingTo.JsSafeJoin(mo.GrTypeValue);
                        currMo.GrObject    = ParsingTo.JsSafeJoin(mo.GrObject);

                        currMo.GrContent   = mo.GrContent;
                        currMo.GrContentMd = mo.GrContentMd;

                        currMo.GrImage  = ParsingTo.JsSafeJoin(mo.GrImage);
                        currMo.GrAudio  = ParsingTo.JsSafeJoin(mo.GrAudio);
                        currMo.GrVideo  = ParsingTo.JsSafeJoin(mo.GrVideo);
                        currMo.GrFile   = ParsingTo.JsSafeJoin(mo.GrFile);
                        currMo.GrRemark = mo.GrRemark;

                        currMo.GrTag        = mo.GrTag;
                        currMo.GrUpdateTime = DateTime.Now;
                        currMo.GrOpen       = mo.GrOpen ?? 1;

                        db.Update(currMo);

                        int num = db.SaveChanges();

                        vm.Data = mo.GrId;
                        vm.Set(num > 0);
                    }
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Apps.FilterConfigs.WriteLog(HttpContext, ex);
            }

            return(vm);
        }
Exemplo n.º 8
0
        public SharedResultVM Add([FromForm] Domain.GuffRecord mo)
        {
            var vm = new SharedResultVM();

            try
            {
                var uinfo = Apps.LoginService.Get(HttpContext);

                if (string.IsNullOrWhiteSpace(mo.GrContent) && string.IsNullOrWhiteSpace(mo.GrImage) && string.IsNullOrWhiteSpace(mo.GrAudio) && string.IsNullOrWhiteSpace(mo.GrVideo))
                {
                    vm.Code = 1;
                    vm.Msg  = "内容不能为空(内容、图片、音频、视频 至少有一项有内容)";
                }
                else if (string.IsNullOrWhiteSpace(mo.GrTag))
                {
                    vm.Code = 2;
                    vm.Msg  = "标签不能为空";
                }
                else if (uinfo.UserId == 0)
                {
                    vm.Set(SharedEnum.RTag.unauthorized);
                }
                else
                {
                    vm = Apps.LoginService.CompleteInfoValid(HttpContext);
                    if (vm.Code == 200)
                    {
                        var now = DateTime.Now;

                        mo.Uid          = uinfo.UserId;
                        mo.GrId         = UniqueTo.LongId().ToString();
                        mo.GrCreateTime = now;
                        mo.GrUpdateTime = now;
                        mo.GrStatus     = 1;
                        mo.GrReadNum    = 0;
                        mo.GrLaud       = 0;
                        mo.GrMark       = 0;
                        mo.GrReplyNum   = 0;
                        mo.GrOpen ??= 1;

                        mo.GrTypeName  = ParsingTo.JsSafeJoin(mo.GrTypeName);
                        mo.GrTypeValue = ParsingTo.JsSafeJoin(mo.GrTypeValue);
                        mo.GrObject    = ParsingTo.JsSafeJoin(mo.GrObject);
                        mo.GrImage     = ParsingTo.JsSafeJoin(mo.GrImage);
                        mo.GrAudio     = ParsingTo.JsSafeJoin(mo.GrAudio);
                        mo.GrVideo     = ParsingTo.JsSafeJoin(mo.GrVideo);
                        mo.GrFile      = ParsingTo.JsSafeJoin(mo.GrFile);
                        mo.GrTag       = ParsingTo.JsSafeJoin(mo.GrTag);

                        db.GuffRecord.Add(mo);

                        int num = db.SaveChanges();

                        vm.Data = mo.GrId;
                        vm.Set(num > 0);
                    }
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Apps.FilterConfigs.WriteLog(HttpContext, ex);
            }

            return(vm);
        }