public HttpResponseMessage RejectMember(NotificationDTO postData) { try { var recipient = InternalMessagingController.Instance.GetMessageRecipient(postData.NotificationId, UserInfo.UserID); if (recipient == null) return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate recipient"); var notification = NotificationsController.Instance.GetNotification(postData.NotificationId); ParseKey(notification.Context); if (_memberId <= 0) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate Member"); } if (_roleInfo == null) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate Role"); } var member = UserController.GetUserById(PortalSettings.PortalId, _memberId); if (member != null) { RoleController.DeleteUserRole(member, _roleInfo, PortalSettings, false) ; var notifications = new Notifications(); var groupOwner = UserController.GetUserById(PortalSettings.PortalId, _roleInfo.CreatedByUserID); notifications.AddMemberNotification(Constants.MemberRejectedNotification, _tabId, _moduleId, _roleInfo, groupOwner, member); NotificationsController.Instance.DeleteAllNotificationRecipients(postData.NotificationId); return Request.CreateResponse(HttpStatusCode.OK, new {Result = "success"}); } } catch (Exception exc) { Logger.Error(exc); return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc); } return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unknown Error"); }
public ActionResult RejectMember(int notificationId) { try { var recipient = InternalMessagingController.Instance.GetMessageRecipient(notificationId, UserInfo.UserID); if (recipient == null) return Json(new { Result = "error" }); var notification = NotificationsController.Instance.GetNotification(notificationId); ParseKey(notification.Context); if (MemberId <= 0) return Json(new { Result = "error" }); if (roleInfo == null) return Json(new { Result = "error" }); var member = UserController.GetUserById(PortalSettings.PortalId, MemberId); if (member != null) { var roleController = new RoleController(); roleController.DeleteUserRole(PortalSettings.PortalId, MemberId, roleInfo.RoleID); var notifications = new Notifications(); var groupOwner = UserController.GetUserById(PortalSettings.PortalId, roleInfo.CreatedByUserID); notifications.AddMemberNotification(Constants.MemberRejectedNotification, TabId, ModuleId, roleInfo, groupOwner, member); NotificationsController.Instance.DeleteAllNotificationRecipients(notificationId); return Json(new { Result = "success" }); } } catch (Exception exc) { DnnLog.Error(exc); } return Json(new { Result = "error" }); }