public override Maybe <Link> ToHomeAccount() { var username = HttpContext?.User?.Identity?.Name; return (username == null?ToAction <HomeController>(x => x.AccountHome(TemplateParameter.Create <string>())) : ToAction <HomeController>(x => x.AccountHome(username))); }
public NegotiatedResult Index() { var currentAccount = Database.GetCurrentAccount(); return(NegotiatedResult(new Home() { Links = new[] { Url.LinkHome(Rel.Self), Url.Link <AccountsController>(x => x.Detail(currentAccount.Id), description: "My account details"), Url.Link <SubscribersController>(x => x.Index(currentAccount.Id, null), description: "My Subscribers"), Url.Link <SubscribersController>(x => x.Detail(TemplateParameter.Create <int>(), TemplateParameter.Create <int>())), Url.Link <SubscribersController>(x => x.Unsubscribe(TemplateParameter.Create <int>(), TemplateParameter.Create <int>())), Url.Link <SubscribersController>(x => x.Modify(TemplateParameter.Create <int>(), TemplateParameter.Create <int>(), null)), // Hide because standard user does not need this list // Url.Link<AccountsController>(x => x.Index(), Rel.AccountCollection, "Account List"), } })); }
public NegotiatedResult Detail(int accountId) { var account = Database.GetAccountById(accountId); if (account == null) { var currentAccount = Database.GetCurrentAccount(); return(NegotiatedResult(new Error($"Account {accountId} not found.", StatusCodes.Status404NotFound) { Links = new[] { Url.LinkHome(), Url.Link <AccountsController>(x => x.Index()), Url.Link <AccountsController>(x => x.Detail(currentAccount.Id), description: "My account details") } })); } return(NegotiatedResult(new AccountDetail() { Links = new[] { Url.LinkHome(), Url.LinkSelf <AccountsController>(x => x.Detail(accountId)), Url.Link <SubscribersController>(x => x.Index(account.Id, null)), Url.Link <SubscribersController>(x => x.Detail(account.Id, TemplateParameter.Create <int>())), Url.Link <SubscribersController>(x => x.Unsubscribe(account.Id, TemplateParameter.Create <int>())), Url.Link <SubscribersController>(x => x.Modify(account.Id, TemplateParameter.Create <int>(), null)), // Hide because standard user does not need this list // Url.Link<AccountsController>(x => x.Index(), Rel.Parent | Rel.AccountItem, "Accounts list"), }, Id = account.Id, FirstName = account.FirstName, LastName = account.LastName, Email = account.Email, Birthday = account.Birthday })); }