public HttpResponseMessage AcceptFriend([FromBody] IdAndCommentModel model) { if (ValidationService.AuthorizeToken(GetToken(), "post:/api/volunteer/acceptfriend") == false) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("无访问权限", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } Guid otherVolunteerId = new Guid(model.id); User myself = ValidationService.FindUserWithToken(GetToken()); User other = myService.FindUser(otherVolunteerId); Guid myId = myself.Id; //检查是否已经是好友 if (FriendService.CheckIfWeAreFriends(myId, otherVolunteerId) == true) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent("你们已经是好友了", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } //同意好友申请并添加好友 if (myService.FriendServiceInVolunteerService.AcceptFriendApplication(other, myself, model.comment) == false) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent("同意好友申请不成功", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } else { return(new HttpResponseMessage(HttpStatusCode.OK)); } }
public HttpResponseMessage JoinOrganization([FromBody] IdAndCommentModel model) { if (ValidationService.AuthorizeToken(GetToken(), "post:/api/organizer/join") == false) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("无访问权限", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } User CurrentUser = ValidationService.FindUserWithToken(GetToken()); User Organization = myService.FindUser(new Guid(model.id)); if (Organization == null) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Organization不存在", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } if (myService.OrganizerApplyToJoinOrganization(CurrentUser, Organization, model.comment)) { return(new HttpResponseMessage(HttpStatusCode.OK)); } return(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("请求不合法", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); }
public HttpResponseMessage RefuseToJoin([FromBody] IdAndCommentModel model) { if (ValidationService.AuthorizeToken(GetToken(), "post:/api/organization/refusetojoin") == false) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("无访问权限", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } User organization = ValidationService.FindUserWithToken(GetToken()); User organizer = (User)myService.FindOneById(new Guid(model.id)); if (myService.OrganizationRefuseOrganizerApplication(organizer, organization, model.comment)) { //myService.MessageService.SendMessage("System", organizer.Id, "你加入组织的申请被拒绝", "你加入组织" + organization.Name + "的申请被拒绝了", null, null); //myService.MessageService.SendMessage("System", organization.Id, "你拒绝某人加入组织的申请", organizer.Name + "加入组织的申请被你拒绝了", null, null); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent("Service错误", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") } }; }
public HttpResponseMessage KickOut([FromBody] IdAndCommentModel model) { if (ValidationService.AuthorizeToken(GetToken(), "post:/api/organization/kickout") == false) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("无访问权限", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } User organization = ValidationService.FindUserWithToken(GetToken()); User organizer = (User)myService.FindOneById(new Guid(model.id)); if (myService.OrganizationKickOrganizerOut(organizer, organization, model.comment)) { //myService.MessageService.SendMessage("System", organizer.Id, "你被组织踢出", "你被组织" + organization.Name + "踢出了", null, null); //myService.MessageService.SendMessage("System", organization.Id, "你将某人踢出了组织", organizer.Name + "被踢出了组织", null, null); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent("Service错误", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") } }; }