public async Task<HttpResponseMessage> PostContactAgreeOrDiscard([FromBody]DualParameter postParameter) { string openid = postParameter.openID; string textMsg = postParameter.textMsg; long itemId= postParameter.itemId; if(string.IsNullOrEmpty(openid) || itemId==0 || !(textMsg == "Agree" || textMsg == "Discard")) { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments); } using(UserRepository userRepository = new UserRepository()) { using(NoticeRepository noticeRepository = new NoticeRepository()) { var msg = await noticeRepository.GetNotice(itemId); string back = ""; bool result = false; if(textMsg == "Agree") { //好友记录改为1 result = await userRepository.ActiveUserContact(msg.Receiver_uuid,msg.RelationID_uuid); //该条要把状态变化成已同意 msg.Status = 1; //需要发回的消息 back = "我已经同意加您为好友,打个招呼吧"; } else if(textMsg == "Discard") { //好友记录删除 result = await userRepository.DeleteUserContact(msg.Receiver_uuid, msg.RelationID_uuid); //该条要把状态变化成已拒绝 msg.Status = 2; //需要发回的消息 back = "我拒绝了您的好友请求。"; } //通过队列修改redis和sql中的状态 if(result) { await WeChatNoticeSendMQHelper.UpdateNoticeAddContact(msg); await WeChatSendMQHelper.SendMessage(msg.Receiver_uuid.ToString().ToUpper(), msg.RelationID_uuid.ToString().ToUpper(), back); return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Success); } else { return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Fail); } } } }