static object DeleteMember( NancyContext context, IDocumentSession documentSession, string alias) { if (context == null) throw new ArgumentNullException("context"); if (documentSession == null) throw new ArgumentNullException("documentSession"); if (String.IsNullOrEmpty(alias)) return 404; if (!context.IsSignedUp()) return 403; var memberToDelete = documentSession.GetMemberByAlias(alias); if (memberToDelete == null) return 404; var currentMember = context.GetCurrentMember(documentSession); Debug.Assert(currentMember != null, "`requireSignedUp()` should ensure the current member is not null."); if (!memberToDelete.Alias.Equals(currentMember.Alias, StringComparison.OrdinalIgnoreCase)) return 403; documentSession.DeleteMember(memberToDelete.Id); context.SetAlert("Your membership was deleted.", type: AlertType.Success); context.SignOutOfTwitter(); return context.Redirect(Paths.Home()); }
static object DeleteSession(NancyContext context) { context.Ensure("context"); context.SetAlert("You successfully signed out.", type: AlertType.Success); context.SignOutOfTwitter(); return context.Redirect(Paths.Home()); }