/// <summary> /// Delete an existing Bady /// </summary> /// <param name="thisBady">Bady</param> /// <returns>bool</returns> public bool Delete(Bady thisBady) { string sql = string.Format("exec dbo.sp_Bady_d {0} " , ToQuote(thisBady.ID) ); try { int rowcount = SqlHelper.ExecuteNonQuery(ConnectStr, CommandType.Text, sql); if (rowcount >= 1) { return(true); } else { throw new Exception("SQL execution failed"); } } catch (Exception ex) { throw new Exception("SQL execution failed", ex); } }
public WebBady GetBady(string id) { var badyds = DataServiceContainer.Self.GetService <IBady>(); Bady bady = badyds.Get(new Guid(id)); return(AutoMapper.Mapper.Map <WebBady>(bady)); }
/// <summary> /// Don't repeat yourself! This private function is for shared by all query public functions /// </summary> /// <param name="sql"></param> /// <param name="page"></param> /// <param name="pg"></param> /// <returns></returns> IList <Bady> GetBadys(string sql, int page, string sortKey, out PaginationInfo paging) { using (DataSet ds = SqlHelper.ExecuteDataset(ConnectStr, CommandType.Text, sql)) { if (ds == null || ds.Tables.Count != 2) { throw new Exception("SQL execution failed"); } else { List <Bady> Comments = new List <Bady>(); foreach (DataRow dr in ds.Tables[0].Rows) { Bady Comment = new Bady() { ID = new Guid(dr["id"].ToString()), BadyId = ParseStr(dr["BadyId"]), Username = ParseStr(dr["Username"]), ImageUrl = ParseStr(dr["ImageUrl"]), Price = ParseStr(dr["Price"]), Platfrom = ParseStr(dr["Platfrom"]), Link = ParseStr(dr["Link"]), Badydescription = ParseStr(dr["Badydescription"]), Badyname = ParseStr(dr["Badyname"]), Groupid = ParseStr(dr["Groupid"]), Twitterid = ParseStr(dr["Twitterid"]), Statues = ParseInt(dr["Statues"]), Createby = ParseStr(dr["Createby"]), Createtime = ParseStr(dr["Createtime"]), Updateby = ParseStr(dr["Updateby"]), Updatetime = ParseStr(dr["Updatetime"]) }; Comments.Add(Comment); } paging = new PaginationInfo() { Current = page, Size = ParseInt(ds.Tables[1].Rows[0]["pagesize"]), TotalRecords = ParseInt(ds.Tables[1].Rows[0]["totalrecords"]), TotalPages = (int)Math.Ceiling(ParseInt(ds.Tables[1].Rows[0]["totalrecords"]) / ParseFloat(ds.Tables[1].Rows[0]["pagesize"])) }; return(Comments); } } }
public JsonResult Update(string link) { string imageurl = string.Empty; string title = string.Empty; string plat = string.Empty; ResultMsg msg = new ResultMsg { Result = false, Msg = "上传失败" }; if (link.ToLower().Contains("taobao") || link.ToLower().Contains("tmall")) { Beauty.Common.Helper.GetTaoBaoLinkInfo(link, out imageurl, out title); plat = "淘宝"; } else if (link.ToLower().Contains("wanggou")) { Beauty.Common.Helper.GetPaiPaiLinkInfo(link, out imageurl, out title); plat = "拍拍"; } if (!string.IsNullOrEmpty(imageurl) && !string.IsNullOrEmpty(link)) { Bady bady = new Bady { ID = Guid.NewGuid(), ImageUrl = imageurl, Badydescription = title, Link = link, Statues = 1, Platfrom = plat, Username = UserName }; Guid id = ibady.Create(bady); if (id == bady.ID) { WriteLog(UserName + "上传了宝贝 编号为" + id.ToString()); msg = new ResultMsg { Result = true, Msg = "上传成功" }; return(Json(msg, JsonRequestBehavior.AllowGet)); } return(Json(msg, JsonRequestBehavior.AllowGet)); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public void TestCanCreatebady() { IBady badyservice = new BadyService(); Bady bady = new Bady { ID = Guid.NewGuid(), Price = "330", ImageUrl = "http://img03.taobaocdn.com/bao/uploaded/i3/15334026849221246/T19gWmFgRcXXXXXXXX_!!0-item_pic.jpg", BadyId = "60225012", Badydescription = "kunbu 女包韩版 包包2013新款 女用单肩包 女手提包 女斜挎包大包", Link = "http://detail.tmall.com/item.htm?id=21431643167", Statues = 1, Platfrom = "tmall.com", Username = "******" }; Guid id = badyservice.Create(bady); Assert.AreEqual(id, bady.ID); }
/// <summary> /// Create a new Bady /// </summary> /// <param name="newBady">new Bady</param> /// <returns>new Bady id</returns> public Guid Create(Bady newBady) { string sql = string.Format("EXEC sp_Bady_c {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15}" , ToQuote(newBady.ID) , ToQuote(newBady.BadyId) , ToQuote(newBady.Username) , ToQuote(newBady.Badyname) , ToQuote(newBady.Badydescription) , ToQuote(newBady.Link) , ToQuote(newBady.Platfrom) , ToQuote(newBady.ImageUrl) , ToQuote(newBady.Price) , ToQuote(newBady.Groupid) , ToQuote(newBady.Twitterid) , ToQuote(CurrentUserName) , ToQuote(DateTime.Now) , ToQuote(CurrentUserName) , ToQuote(DateTime.Now) , ToQuote(newBady.Statues) ); try { int rowcount = SqlHelper.ExecuteNonQuery(ConnectStr, CommandType.Text, sql); if (rowcount == 1) { return(newBady.ID); } else { throw new Exception("SQL execution failed"); } } catch (Exception ex) { throw new Exception("SQL execution failed", ex); } }
public void CompleteShareTask(string taskid, string shareid, string badyid, string goodid, string twriteid, string groupid) { var taskds = DataServiceContainer.Self.GetService <ITask>(); var shareds = DataServiceContainer.Self.GetService <IShare>(); var badyds = DataServiceContainer.Self.GetService <IBady>(); var settingds = DataServiceContainer.Self.GetService <ISetting>(); var userds = DataServiceContainer.Self.GetService <IUser>(); Task t = taskds.Get(new Guid(taskid)); t.Runstatues = 2; taskds.Update(t); Share s = shareds.Get(new Guid(shareid)); s.Runstatues = 2; shareds.Update(s); Bady b = badyds.Get(new Guid(badyid)); b.BadyId = goodid; b.Twitterid = twriteid; b.Groupid = groupid; badyds.Update(b); IList <SettingGroup> groupsetting = settingds.GetSystemSetting(); //string val = GetSettingVal(groupsettings, "BBA6A74C-85F1-4612-AF9E-525599396A0A"); string serviceval = GetSettingVal(groupsetting, "93D5A072-4318-49D5-A1B8-9AAE4C752F26");// string val = GetSettingVal(groupsetting, "11BE7BA7-C738-41C1-B78B-FFE54E9A8FFF"); string val2 = GetSettingVal(groupsetting, "A39E4869-B383-43ED-92F0-5B2EA18B0BBA"); string val3 = GetSettingVal(groupsetting, "09008380-8EE3-4D16-8858-F956044DE5E9"); string val4 = GetSettingVal(groupsetting, "22F0B30D-8B72-4C6A-A193-0D1E26E74F02"); string val5 = GetSettingVal(groupsetting, "5C16F422-14CE-4285-AC0B-1132471C32DA"); string val6 = GetSettingVal(groupsetting, "DC2A7CED-31F2-42BE-A566-4DF62C163A93"); string supperval = GetSettingVal(groupsetting, "E798DAD0-754B-450A-94DD-EF136AAAB991"); //decimal addpoint = decimal.Parse(val) * (1 - decimal.Parse(serviceval)); decimal addpoint = 0; if (s.Liked == 5000 && s.IsSuper) { addpoint += decimal.Parse(val) * decimal.Parse(supperval) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 5000 && !s.IsSuper) { addpoint += decimal.Parse(val) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 10000 && s.IsSuper) { addpoint += decimal.Parse(val2) * decimal.Parse(supperval) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 10000 && !s.IsSuper) { addpoint += decimal.Parse(val2) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 20000 && s.IsSuper) { addpoint += decimal.Parse(val3) * decimal.Parse(supperval) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 20000 && !s.IsSuper) { addpoint += decimal.Parse(val3) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 30000 && s.IsSuper) { addpoint += decimal.Parse(val4) * decimal.Parse(supperval) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 30000 && !s.IsSuper) { addpoint += decimal.Parse(val4) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 50000 && s.IsSuper) { addpoint += decimal.Parse(val5) * decimal.Parse(supperval) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 50000 && !s.IsSuper) { addpoint += decimal.Parse(val5) * (1 - decimal.Parse(serviceval)) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 50001 && s.IsSuper) { addpoint += decimal.Parse(val6) * decimal.Parse(supperval) * (1 - decimal.Parse(serviceval)); } else if (s.Liked == 50001 && !s.IsSuper) { addpoint += decimal.Parse(val6) * (1 - decimal.Parse(serviceval)); } addpoint = decimal.Round(addpoint, 2); PaginationInfo paging = new PaginationInfo(); IList <User> users = userds.Get(null, t.Username, null, null, null, null, null, null, null, null, 1, 0, null, out paging); if (users != null && users.Count > 0) { User user = users[0]; user.Point += addpoint; userds.Update(user); MoneyRecord("完成分享任务,增加积分:" + addpoint.ToString(), user.Username, user.Point - user.FreezePoint); } users = userds.Get(null, s.Username, null, null, null, null, null, null, null, null, 1, 0, null, out paging); if (users != null && users.Count > 0) { User user = users[0]; user.Point -= decimal.Parse(val); user.FreezePoint -= decimal.Parse(val); userds.Update(user); MoneyRecord("分享任务被完成,扣除积分:" + val, user.Username, user.Point - user.FreezePoint); } }
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)); } }