public InventoryItem(NancyContext context, InventoryItemDto item) : base(context.Request.Url.ToString(), new [] { "item", "detail" }) { Properties = new Dictionary <string, object> { { "Name", item.Name }, { "Quantity", item.Quantity } }; Links = new LinksFactory(context) .With(new GetInventoryLink(), WithLink <GetInventoryLink> .Property(x => x.Title = "Back to inventory")) .Build(); Actions = new ActionsFactory(context) .With(new AddInventoryItemQuantityAction(item.Id, item.Version), WithAction <AddInventoryItemQuantityAction> .Field(x => x.Version) .Having(x => x.Type = "hidden")) .With(new RemoveInventoryItemQuantityAction(item.Id, item.Version), WithAction <RemoveInventoryItemQuantityAction> .Field(x => x.Version) .Having(x => x.Type = "hidden")) .With(new RenameInventoryItemAction(item.Id, item.Version, item.Name), WithAction <RenameInventoryItemAction> .Field(x => x.Version) .Having(x => x.Type = "hidden")) .Build(); }
protected UnauthorisedResponse(NancyContext context, IList <string> @class) : base(context.Request.Url.ToString(), @class) { Actions = new ActionsFactory(context) .With(new PostLogin(), WithAction <PostLogin> .Field(x => x.Password).Having(x => x.Type = "password")) .With(new PostRegister(), WithAction <PostRegister> .Field(x => x.Password).Having(x => x.Type = "password"), WithAction <PostRegister> .Field(x => x.ConfirmPassword).Having(x => x.Type = "password")) .With(new PostResetPassword()) .Build(); }
public InventoryCollectionItem(NancyContext context, InventoryListItemDto item) : base($"{context.Request.Url.SiteBase}{context.Request.Url.BasePath}{context.Request.Url.Path}/{item.Id}", "inventory-item") { Properties = new Dictionary <string, object> { { "Name", item.Name } }; Links = new LinksFactory(context).With(new GetInventoryItemLink(item.Id)).Build(); Actions = new ActionsFactory(context) .With(new RemoveInventoryItemAction(item.Id, item.Version), WithAction <RemoveInventoryItemAction> .Field(x => x.Version) .Having(x => x.Type = "hidden")) .Build(); }
public User(NancyContext context, Domain.User user) : base(context.Request.Url.ToString(), "user") { Properties = new Dictionary <string, object> { { "Username", user.Username }, { "Claims", string.Join(", ", user.Claims.Select(x => x.ToString()).ToList()) } }; Links = new LinksFactory(context).With(new GetUsers(), WithLink <GetUsers> .Property(x => x.Title = "Back to all users")).Build(); Actions = new ActionsFactory(context).With(new PutClaims(user), WithAction <PutClaims> .Field(x => x.Claims) .Having(x => x.Type = "select") .Having(x => x.Options = GetClaimsOptions())).Build(); }