//是否收藏 private CampaignForDetail IsFavorite(CampaignForDetail goodinfo, int count_id) { try { goodinfo.favorite = entity.hp_favorite.First(o => o.goodid == goodinfo.id && o.countid == count_id).state; } catch (Exception e) { } return goodinfo; }
public string GetInfoByIdFromCampaign(int id, string countid_str) { string jsonstr = ""; try { var model = entity.hp_goodinfo.First(o => o.id == id && o.state == StringHelper.NORMAL); CampaignForDetail goodinfo = new CampaignForDetail(model); if (countid_str != "" && countid_str != null) { int countid = Convert.ToInt32(countid_str); goodinfo=IsFavorite(goodinfo, countid); } jsonstr = ReturnJson.toJson("100", "成功", goodinfo); } catch (Exception e) { jsonstr = ReturnJson.toJson("101", "失败", -1); } return jsonstr; }