public void CreateTest() { String stalkId = "4"; int talkId = 20; int UserInfoId = 5645; string msg = String.Empty; if (String.IsNullOrEmpty(stalkId)) { msg = "fail"; } if (FavorsService.GetEntities(u => u.TalkID == talkId && u.UserInfoID == UserInfoId).Count() > 0) { msg = "fail"; } Favors favors = new Favors() { UserInfoID = UserInfoId, TalkID = talkId, CreateTime = DateTime.Now, ModfiedOn = DateTime.Now, Status = (short)Model.Enum.DelFlagEnum.Normal, }; Talks talks = TalksService.GetEntities(u => u.TalkID == talkId).FirstOrDefault(); talks.TalkFavorsNum = talks.TalkFavorsNum + 1; if (FavorsService.Add(favors) != null && TalksService.Update(talks)) { msg = "success"; } msg = "fail"; }
public ActionResult Delete() { //if (string.IsNullOrEmpty(ids)) //{ // return Content("Please Select!"); //} //string[] strIds = Request["ids"].Split(','); //List<int> idList = new List<int>(); //foreach (var strId in strIds) //{ // idList.Add(int.Parse(strId)); //} //if (TalksService.DeleteListByLogical(idList)) //{ // return Content("ok"); //} //else //{ // return Content("error"); //} int tId = Convert.ToInt32(Request["ids"]); Talks talks = TalksService.GetEntities(u => u.TalkID == tId).FirstOrDefault(); if (talks == null) { return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); } else { talks.Status = delDeleted; if (TalksService.Update(talks)) { return(Json(new { msg = "success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); } } }