Ejemplo n.º 1
0
        public async Task InsertLikeValues(int colourId, int sourceId, int sweetId, string url, int idWine)
        {
            AppUser user = await _userManager.FindByEmailAsync(User.Identity.Name);

            await _tastesServices.InsertClickValues(colourId, sourceId, sweetId, 3, user.Id);

            UserScore userScore = new UserScore();

            userScore.VoteValue = 0;
            userScore.VoteDate  = DateTime.Now;
            userScore.AppUserId = user.Id;
            userScore.WineId    = idWine;

            await _likeServices.Create(userScore);

            Wine wine = await _winesServices.GetWineByIdAsync(idWine);

            wine.Score++;
            await _winesServices.UpdateWineAsync(wine);

            Response.Redirect(url);
        }
Ejemplo n.º 2
0
        public JsonResult PostLike(UserStore data)
        {
            PaginationInfo paging = new PaginationInfo();
            IList <Like>   likes  = ilike.Get(null, data.Bady.ID.ToString(), UserName, 3, 1, 1, 0, null, out paging);

            if (likes != null && likes.Count > 0)
            {
                Like like = likes[0];
                like.Likednum   = data.needliked;
                like.Commentnum = data.needcommment;
                like.Recordnum  = data.needrecord;
                like.Likenum    = data.needlike;
                like.Supernum   = data.needsuper;
                like.Comment    = data.msg;

                decimal totalpoint = 0;
                IList <SettingGroup> groupsetting = isetting.GetSystemSetting();
                string  likeprice         = GetSettingVal(groupsetting, "65AD5D23-2619-480E-B6A9-84C58AD07DCB");
                string  commentprice      = GetSettingVal(groupsetting, "4D2E7311-BA9F-468B-BC3B-3F938C9CC3EA");
                string  likedprice        = GetSettingVal(groupsetting, "FB8E6B56-DEA6-4D70-9C52-E451E7423F55");
                string  recordprice       = GetSettingVal(groupsetting, "88841710-5B5F-4581-9557-85103CD65534");
                string  supperrecordprice = GetSettingVal(groupsetting, "6FF927CF-5676-43B2-A9B4-F72C346E22DE");
                decimal alivepoint        = GetAlivePoint();

                totalpoint += data.needlike * decimal.Parse(likeprice);
                totalpoint += data.needrecord * decimal.Parse(recordprice);
                totalpoint += data.needliked * decimal.Parse(likedprice);
                totalpoint += data.needcommment * decimal.Parse(commentprice);
                totalpoint += data.needsuper * decimal.Parse(supperrecordprice);

                if (alivepoint >= totalpoint)
                {
                    like.Statues = 0;
                    bool isupdate = ilike.Update(like);
                    if (isupdate)
                    {
                        like.ID         = Guid.NewGuid();
                        like.Statues    = 1;
                        like.Runstatues = 0;
                        Guid iscreate = ilike.Create(like);
                        if (iscreate == like.ID)
                        {
                            WriteLog(UserName + "分派了首页直达任务 编号为" + like.ID.ToString());
                            ResultMsg msg = new ResultMsg {
                                Msg = "开始成功", Result = true
                            };
                            ReduceUserPoint(totalpoint, "发布首页直达任务,冻结积分:" + ((int)totalpoint).ToString());
                            return(Json(msg, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            ResultMsg msg = new ResultMsg {
                                Msg = "开始失败", Result = false
                            };
                            return(Json(false, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        ResultMsg msg = new ResultMsg {
                            Msg = "开始失败", Result = false
                        };
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    ResultMsg msg = new ResultMsg {
                        Msg = "可用积分不足", Result = false
                    };
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                decimal totalpoint = 0;
                IList <SettingGroup> groupsetting = isetting.GetSystemSetting();
                string likeprice         = GetSettingVal(groupsetting, "65AD5D23-2619-480E-B6A9-84C58AD07DCB");
                string commentprice      = GetSettingVal(groupsetting, "4D2E7311-BA9F-468B-BC3B-3F938C9CC3EA");
                string likedprice        = GetSettingVal(groupsetting, "FB8E6B56-DEA6-4D70-9C52-E451E7423F55");
                string recordprice       = GetSettingVal(groupsetting, "88841710-5B5F-4581-9557-85103CD65534");
                string supperrecordprice = GetSettingVal(groupsetting, "6FF927CF-5676-43B2-A9B4-F72C346E22DE");

                decimal alivepoint = GetAlivePoint();

                totalpoint += data.needlike * decimal.Parse(likeprice);
                totalpoint += data.needrecord * decimal.Parse(recordprice);
                totalpoint += data.needliked * decimal.Parse(likedprice);
                totalpoint += data.needcommment * decimal.Parse(commentprice);
                totalpoint += data.needsuper * decimal.Parse(supperrecordprice);
                //totalpoint += like.Supernum * decimal.Parse(superrecordprice);
                if (alivepoint >= totalpoint)
                {
                    Like like = new Like
                    {
                        ID         = Guid.NewGuid(),
                        Likednum   = data.needliked,
                        Commentnum = data.needcommment,
                        Recordnum  = data.needrecord,
                        Likenum    = data.needlike,
                        Bady       = new Bady {
                            ID = data.Bady.ID
                        },

                        Type       = 1,
                        Comment    = data.msg,
                        Runstatues = 0,
                        Statues    = 1,
                        Supernum   = data.needsuper,
                        Username   = UserName
                    };

                    Guid id = ilike.Create(like);
                    WriteLog(UserName + "分派了首页直达任务 编号为" + like.ID.ToString());
                    if (id == like.ID)
                    {
                        ResultMsg msg = new ResultMsg {
                            Msg = "开始成功", Result = true
                        };
                        ReduceUserPoint(totalpoint, "发布首页直达任务,冻结积分:" + ((int)totalpoint).ToString());
                        return(Json(msg, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        ResultMsg msg = new ResultMsg {
                            Msg = "开始失败", Result = false
                        };
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    ResultMsg msg = new ResultMsg {
                        Msg = "可用积分不足", Result = false
                    };
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
        }
Ejemplo n.º 3
0
        public JsonResult PostLike(List <Like> data)
        {
            try
            {
                IList <SettingGroup> groupsettings = iusersetting.GetByUsername(UserName);

                int likerate    = int.Parse(GetSettingVal(groupsettings, "3C309D27-C774-4E60-8706-17EA2C2B0691"));
                int recordrate  = int.Parse(GetSettingVal(groupsettings, "E038EAB0-9F3D-4967-BE16-06E04633D6C8"));
                int likedrate   = int.Parse(GetSettingVal(groupsettings, "6C715AE2-2D77-4827-B4C1-7E5352B7D00B"));
                int commentrate = int.Parse(GetSettingVal(groupsettings, "4E8E13CA-0726-4610-8CC5-1A5A3191A7BD"));

                IList <SettingGroup> groupsetting = isetting.GetSystemSetting();
                string likeprice        = GetSettingVal(groupsetting, "65AD5D23-2619-480E-B6A9-84C58AD07DCB");
                string commentprice     = GetSettingVal(groupsetting, "4D2E7311-BA9F-468B-BC3B-3F938C9CC3EA");
                string likedprice       = GetSettingVal(groupsetting, "FB8E6B56-DEA6-4D70-9C52-E451E7423F55");
                string recordprice      = GetSettingVal(groupsetting, "88841710-5B5F-4581-9557-85103CD65534");
                string superrecordprice = GetSettingVal(groupsetting, "6FF927CF-5676-43B2-A9B4-F72C346E22DE");

                decimal alivepoint = GetAlivePoint();

                decimal totalpoint = 0;
                foreach (Like like in data)
                {
                    like.Recordnum  = like.Likenum * recordrate / likerate;
                    like.Likednum   = like.Likenum * likedrate / likerate;
                    like.Commentnum = like.Likenum * commentrate / likerate;
                    like.Supernum   = like.Supernum > like.Likednum ? like.Likednum : like.Supernum;
                    if (like.Commentnum == 0 && !string.IsNullOrEmpty(like.Comment))
                    {
                        like.Commentnum = 1;
                    }
                    totalpoint += like.Likenum * decimal.Parse(likeprice);
                    totalpoint += like.Recordnum * decimal.Parse(recordprice);
                    totalpoint += like.Likednum * decimal.Parse(likedprice);
                    totalpoint += like.Commentnum * decimal.Parse(commentprice);
                    totalpoint += like.Supernum * decimal.Parse(superrecordprice);
                }

                if (alivepoint >= totalpoint)
                {
                    foreach (Like like in data)
                    {
                        if (!string.IsNullOrEmpty(like.Lnk))
                        {
                            var imgurl = string.Empty;
                            var title  = string.Empty;
                            Helper.GetShareLinkInfo(like.Lnk, out imgurl, out title);
                            if (!string.IsNullOrEmpty(imgurl) && !string.IsNullOrEmpty(title))
                            {
                                Bady bady = new Bady
                                {
                                    ID = Guid.NewGuid(),

                                    ImageUrl = imgurl,

                                    Badydescription = title,
                                    Link            = like.Lnk,
                                    Statues         = 1,
                                    Twitterid       = Helper.GetIDFromShareLink(like.Lnk),
                                    Username        = UserName
                                };
                                Guid id = ibady.Create(bady);

                                Share share = new Share
                                {
                                    ID         = Guid.NewGuid(),
                                    Bady       = bady,
                                    Comment    = like.Comment.Contains("###") ? like.Comment.Split(new string[] { "###" }, StringSplitOptions.None)[0] : like.Comment,
                                    IsSuper    = false,
                                    Liked      = 0,
                                    Keyword    = like.Keyword,
                                    Username   = UserName,
                                    Statues    = 1,
                                    Runstatues = 2
                                };

                                id = ishare.Create(share);

                                like.Statues    = 1;
                                like.ID         = Guid.NewGuid();
                                like.Recordnum  = like.Likenum * recordrate / likerate;
                                like.Likednum   = like.Likenum * likedrate / likerate;
                                like.Commentnum = like.Likenum * commentrate / likerate;
                                like.Supernum   = like.Supernum > like.Likednum ? like.Likednum : like.Supernum;
                                like.Bady       = bady;

                                if (string.IsNullOrEmpty(like.Username))
                                {
                                    like.Username = UserName;
                                }
                                like.Type = 0;
                                if (like.Commentnum == 0 && !string.IsNullOrEmpty(like.Comment))
                                {
                                    like.Commentnum = 1;
                                }

                                id = ilike.Create(like);
                            }
                            else
                            {
                                ResultMsg msg = new ResultMsg {
                                    Result = false, Msg = "请上传正确的美丽说分享连接"
                                };

                                return(Json(msg, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            like.Statues    = 1;
                            like.ID         = Guid.NewGuid();
                            like.Recordnum  = like.Likenum * recordrate / likerate;
                            like.Likednum   = like.Likenum * likedrate / likerate;
                            like.Commentnum = like.Likenum * commentrate / likerate;
                            like.Supernum   = like.Supernum > like.Likednum ? like.Likednum : like.Supernum;
                            if (string.IsNullOrEmpty(like.Username))
                            {
                                like.Username = UserName;
                            }
                            like.Type = 0;
                            if (like.Commentnum == 0 && !string.IsNullOrEmpty(like.Comment))
                            {
                                like.Commentnum = 1;
                            }

                            Guid id = ilike.Create(like);
                            WriteLog(UserName + "分派喜欢任务 编号为" + id.ToString());
                        }
                    }

                    AddCrossActionMsg("OK", "发起喜欢任务成功");
                    ResultMsg msg2 = new ResultMsg {
                        Result = true, Msg = "发起喜欢任务成功"
                    };
                    ReduceUserPoint(totalpoint, "发布喜欢任务,冻结积分:" + ((int)totalpoint).ToString());
                    return(Json(msg2, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ResultMsg msg = new ResultMsg {
                        Result = false, Msg = "可用积分不足"
                    };
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
            catch
            {
                AddCrossActionMsg("Fail", "喜欢失败");
                ResultMsg msg = new ResultMsg {
                    Result = false, Msg = "喜欢失败"
                };
                return(Json(msg, JsonRequestBehavior.AllowGet));
            }
        }