1+ // Complete declarative AutoQuery services for Bookings CRUD example:
2+ // https://docs.servicestack.net/autoquery-crud-bookings
3+
14using System ;
25using System . IO ;
36using System . Collections ;
1013namespace 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" ) ]
1818public 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" ) ]
2827public 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" ) ]
6866public 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
15597public enum RoomType
15698{
0 commit comments