public static IDispatcherEndpointsBuilder AddUserRouter(this IDispatcherEndpointsBuilder endpoints) => endpoints // delete one user by id .Delete <DeleteUser>( path: "users/{Id}", afterDispatch: async(command, context) => { context.Response.StatusCode = 204; await context.Response.WriteJsonAsync(new { id = command.Id }); }, auth: true, roles: UserRole.Administrator.ToString()) // get all users (with pagination) .Get <GetAllUsers, IEnumerable <UserDTO> >( path: "users", auth: true, roles: UserRole.Administrator.ToString()) // get profile of authorized user .Get <GetProfile, UserDTO>( path: "profile", beforeDispatch: (command, context) => { command.Id = context.GetUserId(); return(Task.CompletedTask); }, auth: true);
public static IDispatcherEndpointsBuilder AddLaundriesRouter(this IDispatcherEndpointsBuilder endpoints) => endpoints .Post <CreateLaundry>( path: "laundries", afterDispatch: async(command, context) => { await context.Response.Created($"laundries/{command.Id}"); }) .Delete <DeleteLaundry>( path: "laundries/{Id}", afterDispatch: async(command, context) => { context.Response.StatusCode = 204; await context.Response.WriteJsonAsync(new { id = command.Id }); }) .Post <DismissManager>( path: "laundry/dismiss", auth: true, roles: UserRole.Administrator.ToString()) .Post <EmployManager>( path: "laundry/employ", auth: true, roles: UserRole.Administrator.ToString() ) .Get <GetAllLaundries, IEnumerable <LaundryDTO> >( path: "laundries") .Get <GetLaundryById, LaundryDTO>( path: "laundries/{id}");
internal static IDispatcherEndpointsBuilder AddServicesRouter(this IDispatcherEndpointsBuilder endpoints) => endpoints .Post <AddService>( path: "service/add", auth: true, roles: UserRole.Administrator.ToString()) .Post <MakeServiceAvailableInLaundry>( path: "service/enable", auth: true, roles: $"{UserRole.Administrator},{UserRole.Manager}" );
public static IDispatcherEndpointsBuilder AddAuthRouter(this IDispatcherEndpointsBuilder endpoints) => endpoints
public static IDispatcherEndpointsBuilder AddOrdersRouter(this IDispatcherEndpointsBuilder endpoints) => endpoints .Post <CreateOrder>( path: "order/create", auth: true) .Post <CancelOrder>( path: "order/cancel", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.ClientId = id; return(Task.CompletedTask); }, auth: true, roles: UserRole.Client.ToString()) .Post <PutOrderInProgress>( path: "order/progress", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.ManagerId = id; return(Task.CompletedTask); }, auth: true, roles: UserRole.Manager.ToString()) .Post <FinishOrder>( path: "order/finish", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.ManagerId = id; return(Task.CompletedTask); }, auth: true, roles: UserRole.Manager.ToString()) .Post <PassOrder>( path: "order/pass", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.ClientId = id; return(Task.CompletedTask); }, auth: true, roles: UserRole.Client.ToString()) .Post <AddServiceToOrder>( path: "order/service/add", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.ClientId = id; return(Task.CompletedTask); }, auth: true, roles: UserRole.Client.ToString()) .Post <RemoveServiceFromOrder>( path: "order/service/remove", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.ClientId = id; return(Task.CompletedTask); }, auth: true, roles: UserRole.Client.ToString()) .Post <CompleteServiceInOrder>( path: "order/service/complete", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.ManagerId = id; return(Task.CompletedTask); }, auth: true, roles: UserRole.Manager.ToString()) .Get <GetOrder, Order>( path: "order/{orderId}", beforeDispatch: (command, context) => { var id = context.GetUserId(); command.UserId = id; return(Task.CompletedTask); }, auth: true);