Skip to content

Commit b92a06c

Browse files
committed
Update Bookings.d.ts
1 parent 68c7b93 commit b92a06c

File tree

2 files changed

+5
-80
lines changed

2 files changed

+5
-80
lines changed

MyApp.ServiceModel/Bookings.cs

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Complete declarative AutoQuery services for Bookings CRUD example:
2+
// https://docs.servicestack.net/autoquery-crud-bookings
3+
14
using System;
25
using System.IO;
36
using System.Collections;
@@ -10,10 +13,7 @@
1013
namespace MyApp.ServiceModel;
1114

1215
[Tag("Bookings")]
13-
[Route("/bookings/{Id}","GET")]
14-
[Route("/bookings","GET")]
1516
[AutoApply(Behavior.AuditQuery)]
16-
[Description("Find Bookings")]
1717
[ValidateHasRole("Employee")]
1818
public class QueryBookings : QueryDb<Booking>
1919
{
@@ -23,7 +23,6 @@ public class QueryBookings : QueryDb<Booking>
2323

2424
[Tag("Bookings")]
2525
[AutoApply(Behavior.AuditCreate)]
26-
[Description("Create a new Booking")]
2726
[ValidateHasRole("Employee")]
2827
public class CreateBooking : ICreateDb<Booking>, IReturn<IdResponse>
2928
{
@@ -36,7 +35,6 @@ public class CreateBooking : ICreateDb<Booking>, IReturn<IdResponse>
3635
public DateTime? BookingEndDate { get; set; }
3736
[ValidateGreaterThan(0)]
3837
public decimal Cost { get; set; }
39-
public string? CouponId { get; set; }
4038
[Input(Type="textarea")]
4139
public string? Notes { get; set; }
4240
public bool? Cancelled { get; set; }
@@ -56,62 +54,21 @@ public class UpdateBooking : IPatchDb<Booking>, IReturn<IdResponse>
5654
public DateTime? BookingEndDate { get; set; }
5755
[ValidateGreaterThan(0)]
5856
public decimal? Cost { get; set; }
59-
public string? CouponId { get; set; }
6057
[Input(Type="textarea")]
6158
public string? Notes { get; set; }
6259
public bool? Cancelled { get; set; }
6360
}
6461

6562
[Tag("Bookings")]
6663
[AutoApply(Behavior.AuditSoftDelete)]
64+
[ValidateHasRole("Manager")]
6765
[ValidateHasRole("Employee")]
6866
public class DeleteBooking : IDeleteDb<Booking>, IReturnVoid
6967
{
7068
public int? Id { get; set; }
7169
public List<int>? Ids { get; set; }
7270
}
7371

74-
[Tag("Bookings")]
75-
[AutoApply(Behavior.AuditQuery)]
76-
public class QueryCoupons : QueryDb<Coupon>
77-
{
78-
public string? Id { get; set; }
79-
public List<string>? Ids { get; set; }
80-
}
81-
82-
[Tag("Bookings")]
83-
[AutoApply(Behavior.AuditCreate)]
84-
[ValidateIsAuthenticated]
85-
public class CreateCoupon : ICreateDb<Coupon>, IReturn<IdResponse>
86-
{
87-
[ValidateNotEmpty]
88-
public string Id { get; set; }
89-
[ValidateNotEmpty]
90-
public string Description { get; set; }
91-
public decimal Discount { get; set; }
92-
public DateTime? ExpiryDate { get; set; }
93-
}
94-
95-
[Tag("Bookings")]
96-
[AutoApply(Behavior.AuditModify)]
97-
[ValidateIsAuthenticated]
98-
public class UpdateCoupon : IPatchDb<Coupon>, IReturn<IdResponse>
99-
{
100-
public string Id { get; set; }
101-
public string? Description { get; set; }
102-
public decimal? Discount { get; set; }
103-
public DateTime? ExpiryDate { get; set; }
104-
}
105-
106-
[Tag("Bookings")]
107-
[AutoApply(Behavior.AuditSoftDelete)]
108-
[ValidateIsAuthenticated]
109-
public class DeleteCoupon : IDeleteDb<Coupon>, IReturnVoid
110-
{
111-
public string? Id { get; set; }
112-
public List<string>? Ids { get; set; }
113-
}
114-
11572

11673
[Icon(Svg="<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M16 10H8c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm3-7h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H8V2c0-.55-.45-1-1-1s-1 .45-1 1v1H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-1 16H6c-.55 0-1-.45-1-1V8h14v10c0 .55-.45 1-1 1zm-5-5H8c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1z'/></svg>")]
11774
[Notes("Captures a Persons Name & Room Booking information")]
@@ -129,28 +86,13 @@ public class Booking : AuditBase
12986
public DateTime? BookingEndDate { get; set; }
13087
[IntlNumber(Currency="USD")]
13188
public decimal Cost { get; set; }
132-
[Ref(Model=nameof(Coupon),RefId=nameof(Coupon.Id),RefLabel=nameof(Coupon.Description))]
133-
[References(typeof(Coupon))]
134-
public string? CouponId { get; set; }
135-
[Format(FormatMethods.Hidden)]
136-
[Reference]
137-
public Coupon? Discount { get; set; }
13889
public string? Notes { get; set; }
13990
public bool? Cancelled { get; set; }
14091
[Format(FormatMethods.Hidden)]
14192
[Reference(SelfId=nameof(CreatedBy),RefId=nameof(User.UserName),RefLabel=nameof(User.DisplayName))]
14293
public User Employee { get; set; }
14394
}
14495

145-
[Icon(Svg="<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M2 9.5V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v5.5a2.5 2.5 0 1 0 0 5V20a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-5.5a2.5 2.5 0 1 0 0-5zm2-1.532a4.5 4.5 0 0 1 0 8.064V19h16v-2.968a4.5 4.5 0 0 1 0-8.064V5H4v2.968zM9 9h6v2H9V9zm0 4h6v2H9v-2z' /></svg>")]
146-
public class Coupon : AuditBase
147-
{
148-
public string Id { get; set; }
149-
public string Description { get; set; }
150-
public decimal Discount { get; set; }
151-
public DateTime? ExpiryDate { get; set; }
152-
}
153-
15496

15597
public enum RoomType
15698
{

MyApp.ServiceModel/Bookings.d.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ export enum RoomType {
1414
Suite,
1515
}
1616

17-
@Read.route("/bookings","GET")
18-
@Read.route("/bookings/{Id}","GET")
19-
@Read.description("Find Bookings")
20-
@Create.description("Create a new Booking")
17+
@Delete.validateHasRole("Manager")
2118
@tag("Bookings")
2219
@icon({svg:"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M16 10H8c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm3-7h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H8V2c0-.55-.45-1-1-1s-1 .45-1 1v1H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-1 16H6c-.55 0-1-.45-1-1V8h14v10c0 .55-.45 1-1 1zm-5-5H8c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1z'/></svg>"})
2320
@notes("Captures a Persons Name & Room Booking information")
@@ -39,23 +36,9 @@ export class Booking extends AuditBase {
3936
@intlNumber({currency:"USD"})
4037
@validateGreaterThan(0)
4138
cost: decimal
42-
@ref({model:"nameof(Coupon)",refId:"nameof(Coupon.Id)",refLabel:"nameof(Coupon.Description)"})
43-
@references("typeof(Coupon)")
44-
couponId?: string
45-
@reference()
46-
discount?: Coupon
4739
@input({type:"textarea"})
4840
notes?: string
4941
cancelled?: boolean
5042
@reference({selfId:"nameof(CreatedBy)",refId:"nameof(User.UserName)",refLabel:"nameof(User.DisplayName)"})
5143
employee: User
5244
}
53-
54-
@tag("Bookings")
55-
@icon({svg:"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M2 9.5V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v5.5a2.5 2.5 0 1 0 0 5V20a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-5.5a2.5 2.5 0 1 0 0-5zm2-1.532a4.5 4.5 0 0 1 0 8.064V19h16v-2.968a4.5 4.5 0 0 1 0-8.064V5H4v2.968zM9 9h6v2H9V9zm0 4h6v2H9v-2z' /></svg>"})
56-
export class Coupon extends AuditBase {
57-
id: string
58-
description: string
59-
discount: number
60-
expiryDate?: Date
61-
}

0 commit comments

Comments
 (0)