// GET: api/Topic public DTO.ReturnJasonConstruct <List <DTO.Topic> > Get() { try { string[] separators = { "@||@" }; DTO.ReturnJasonConstruct <List <DTO.Topic> > dto = new DTO.ReturnJasonConstruct <List <DTO.Topic> >(); dto.status = (int)DTO.executeStatus.success; dto.DTOObject = new List <DTO.Topic>(); UserInformationEntities db = new UserInformationEntities(); var objectList = db.TopicStack.ToList(); foreach (var item in objectList) { DTO.Topic obj = new DTO.Topic(); obj.topic = item.Topic; obj.choices = new List <DTO.Choice>(); string[] choices = item.Choices.Split(separators, StringSplitOptions.RemoveEmptyEntries); string[] goal = item.Goals.Split(separators, StringSplitOptions.RemoveEmptyEntries); for (int n = 0; n < choices.Length; n++) { obj.choices.Add(new DTO.Choice { choice = choices[n], goal = int.Parse(goal[n]) }); } dto.DTOObject.Add(obj); } return(dto); } catch (Exception ex) { throw ex; } }
// GET: api/Signature public DTO.ReturnJasonConstruct <DTO.Signature> Get(string url) { DTO.ReturnJasonConstruct <DTO.Signature> returnDTO = new DTO.ReturnJasonConstruct <DTO.Signature>(); DTO.Signature dto = new DTO.Signature(); dto.nonceStr = Guid.NewGuid().ToString(); dto.timeStamp = WeChat.GetTimeStamp(); dto.signature = WeChat.GetSignature(dto.nonceStr, dto.timeStamp, url); returnDTO.DTOObject = dto; return(returnDTO); }
// GET: api/Gift/5 public DTO.ReturnJasonConstruct <List <DTO.Gift> > Get(Guid id) { UserInformationEntities db = new UserInformationEntities(); var q = from c in db.lottery1 from d in db.LotteryGift where c.LotteryGiftID == d.ID && c.UserID == id && d.GiftName != "谢谢惠顾" && c.Receive == false select new { GiftName = d.GiftName, GiftDescribtion = d.GiftDescribtion, remark = c.UberID }; DTO.ReturnJasonConstruct <List <DTO.Gift> > giftList = new DTO.ReturnJasonConstruct <List <DTO.Gift> >(); giftList.status = (int)DTO.executeStatus.success; giftList.DTOObject = new List <DTO.Gift>(); foreach (var item in q) { string remark = ""; if (item.GiftName.IndexOf("优步") != -1) { var uberObj = db.UBer.SingleOrDefault(p => p.ID == item.remark); if (uberObj != null) { remark = "优惠码:" + uberObj.ExchangeNumber.ToString(); } } //DTO.ReturnJasonConstruct<List<DTO.Gift>> dto = new DTO.ReturnJasonConstruct<List<DTO.Gift>>(); DTO.Gift dtoObject = new DTO.Gift(); dtoObject.giftName = item.GiftName; dtoObject.giftDescribtion = item.GiftDescribtion; dtoObject.remark = remark; giftList.DTOObject.Add(dtoObject); } return(giftList); }