### Run DDD Fundamentals Sample with Docker Compose Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md Commands to build and run the DDD Fundamentals sample application using Docker Compose. The build step can be run in parallel for faster execution. The up command starts all services, and troubleshooting tips for common errors like RabbitMQ or SQL Server connection issues are provided. ```powershell docker-compose build --parallel docker-compose up ``` -------------------------------- ### Run RabbitMQ with Management Interface Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md This command starts a RabbitMQ container with the management interface enabled. It maps the management port (15672) and the AMQP port (5672) to the host machine. The container is named 'ddd-sample-rabbit' and will be automatically removed when it stops. ```powershell docker run --rm -it --hostname ddd-sample-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management ``` -------------------------------- ### Initialize Kendo Scheduler with Data Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html Initializes the Kendo UI Scheduler with provided start date, time, end date, appointments, resources, and groups. It sets up the data source, event templates, and various configuration options for the scheduler. ```JavaScript $(function () { $("#kendoVersion").text(kendo.version); }); // Demo is using Kendo Scheduler until Blazor version supports Grouped Schedule View var currentAppointment = {}; var instanceKendoCall = {}; const colorFieldName = 'key'; function lowerCasefirst(string) { if (!string || string.length <= 0) { return ''; } return string.charAt(0).toLowerCase() + string.slice(1); } function createDataSourceResource(name, data, valueField, textField) { var result = {}; if (data[lowerCasefirst(valueField)]) { result['value'] = data[lowerCasefirst(valueField)]; } if (data[lowerCasefirst(textField)]) { result['text'] = data[lowerCasefirst(textField)]; } if (name.toLowerCase() == 'rooms') { result[colorFieldName] = createColor(data, valueField); } return result; } function createColorForAppointment(data) { if (data['roomId'] == 1) { return "#97c741"; } else if (data['roomId'] == 2) { return "#63aeb8"; } else if (data['roomId'] == 3) { return "#c163a2"; } else if (data['roomId'] == 4) { return "#ed652e"; } else if (data['roomId'] == 5) { return "#6380ba"; } } function getPictureBase64(data, callback) { var url = "https://localhost:5101/api/files/"; url = url + data['patientName'] + '.jpg'; var result = ''; $.getJSON(url, '', callback); } function createColor(data, valueField) { if (data[lowerCasefirst(valueField)] == 1) { return "#97c741"; } else if (data[lowerCasefirst(valueField)] == 2) { return "#63aeb8"; } else if (data[lowerCasefirst(valueField)] == 3) { return "#c163a2"; } else if (data[lowerCasefirst(valueField)] == 4) { return "#ed652e"; } else if (data[lowerCasefirst(valueField)] == 5) { return "#6380ba"; } return ''; } function createResource(schedulerResource) { var result = {}; var dataSource = []; if (schedulerResource['name'].toLowerCase() == 'rooms') { result['dataColorField'] = colorFieldName; } for (var i = 0; i < schedulerResource['data'].length; i++) { dataSource.push(createDataSourceResource(schedulerResource['name'], schedulerResource['data'][i], schedulerResource['valueField'], schedulerResource['textField'])); } result['dataSource'] = dataSource; result['name'] = schedulerResource['name'].toLowerCase(); result['field'] = lowerCasefirst(schedulerResource['field']); result['title'] = schedulerResource['title']; return result; } function addListenerToFireEdit(instance) { instanceKendoCall = instance; } function createGroups(schedulerGroups) { var groups = []; if (schedulerGroups) { for (var i = 0; i < schedulerGroups.length; i++) { groups.push(schedulerGroups[i].toLowerCase()); } } return groups; } function createResources(schedulerResources) { var resources = []; if (schedulerResources) { for (var i = 0; i < schedulerResources.length; i++) { resources.push(createResource(schedulerResources[i])); } } return resources; } function scheduler(startDate, startTime, endDate, appointments, schedulerResources, schedulerGroups, height) { var resources = createResources(schedulerResources) var groups = createGroups(schedulerGroups); console.log('resources', resources); hardRefresh(); var viewModel = new kendo.observable({ schedulerData: new kendo.data.SchedulerDataSource({ data: appointments, schema: { model: { id: "appointmentId", fields: { appointmentId: { from: "appointmentId", type: "string" }, title: { from: "title", defaultValue: "No title", validation: { required: true } }, start: { type: "date", from: "start" }, end: { type: "date", from: "end" }, description: { from: "description" }, roomId: { from: "roomId", nullable: true, type: "number" }, isAllDay: { type: "boolean", from: "isAllDay" }, ScheduleId: { type: "string", from: "ScheduleId" }, isConflict: { type: "boolean", from: "isPotentiallyConflicting" }, isConfirmed: { from: "isConfirmed" } } } } }), }); var onDataBound = function (e) { $("[data-is-conflicted=true]") .parent() .addClass("conflicted-event"); $("[data-is-confirmed=true]") .parent() .addClass("confirmed-event"); }; $("#scheduler").kendoScheduler({ date: startDate, startTime: startTime, endTime: endDate, height: height, resize: function (e) { e.preventDefault(); }, resizeEnd: function (e) { e.preventDefault(); }, moveEnd: function (e) { //if (!checkAvailability(e.start, e.end, e.event, e.resources)) { // e.preventDefault(); //} else { // onMoveEnd(e); //} }, views: [ { type: "day", selected: true, allDaySlot: false, minorTickCount: 4 }, { type: "workWeek", allDaySlot: false, minorTickCount: 4 }, "agenda" ], workWeekEnd: 6, timezone: "America/Detroit", //timezone: "Etc/UTC", dataSource: viewModel.schedulerData, dataBound: onDataBound, eventTemplate: kendo.template($("#event-template").html()), footer: false, group: { resources: groups }, resources: resources, edit: onEdit, remove: onDelete, }); } function occurrencesInRangeByResource(start, end, resourceFieldName, event, resources) { var scheduler = $("#scheduler").getKendoSche ``` -------------------------------- ### Run Papercut Test Mail Server Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md This command launches a Papercut container, which acts as a local test mail server. It exposes the SMTP port (25) and the Papercut UI port (37408) to the host. The container is named 'papercut' and uses the 'jijiechen/papercut:latest' image. ```powershell docker run --name=papercut -p 25:25 -p 37408:37408 jijiechen/papercut:latest ``` -------------------------------- ### Blazored.LocalStorage - Blazor Local Storage Access Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md A Blazor utility that enables easy access to the browser's local storage from Blazor WebAssembly applications, facilitating client-side data persistence. ```csharp /// /// Blazor utility for accessing browser local storage in Blazor WebAssembly apps. /// public interface ILocalStorageService { Task SetItemAsync(string key, T data); Task GetItemAsync(string key); Task RemoveItemAsync(string key); } ``` -------------------------------- ### Ardalis.ApiEndpoints - API Endpoint Simplification Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md A library that simplifies API endpoint creation by promoting a Request-EndPoint-Response (REPR) pattern, replacing traditional MVC structures for more focused and manageable endpoints. ```csharp /// /// A simple base class that lets you keep your API endpoints small and focused on one endpoint at a time. MVC is replaced with Request-EndPoint-Response (REPR). /// public abstract class ApiEndpoint { public abstract Task> HandleAsync(TRequest request); } ``` -------------------------------- ### Ardalis.Specification.EntityFrameworkCore - EF Core Repository Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md Extends Ardalis.Specification with Entity Framework Core-specific functionalities. It includes a default generic repository implementation that seamlessly integrates with the Specification pattern. ```csharp /// /// Adds EF Core-specific functionality, including a default implementation of a generic EF repository that supports Specifications. /// public class EfRepository : IRepository { private readonly DbContext _context; public EfRepository(DbContext context) { _context = context; } public async Task GetByIdAsync(int id) { return await _context.Set().FindAsync(id); } // ... other repository methods supporting specifications } ``` -------------------------------- ### MassTransit.RabbitMQ - RabbitMQ Communication Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md A client library for communicating with RabbitMQ message broker, enabling the implementation of robust messaging patterns in distributed systems. ```csharp /// /// Client for communicating with RabbitMQ. /// public interface IRabbitMqBus { Task Publish(T message) where T : class; Task Send(T message) where T : class; } ``` -------------------------------- ### Using Open Iconic SVG Sprite Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/css/open-iconic/README.md This demonstrates how to use Open Iconic's SVG sprite for displaying icons efficiently. It utilizes the `` and `` elements, with specific classes for styling and referencing individual icons within the sprite. The provided CSS snippet shows how to size the icons. ```HTML ``` ```CSS .icon { width: 16px; height: 16px; } ``` ```CSS .icon-account-login { fill: #f00; } ``` -------------------------------- ### Stop All Docker Containers Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md A command to forcefully stop all currently running Docker containers. Use with caution as it affects all containers, not just those related to this project. ```powershell docker kill $(docker ps -q) ``` -------------------------------- ### JavaScript Create Appointment Object Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html Creates or updates a `currentAppointment` object with details extracted from a Kendo UI scheduler event. It populates properties like ID, start/end times, description, and associated resource IDs. ```javascript function createAppointment(event) { currentAppointment = {}; if (event['appointmentId']) { currentAppointment['appointmentId'] = event['appointmentId']; } else { currentAppointment['appointmentId'] = '00000000-0000-0000-0000-000000000000'; } if (event['isConfirmed']) { currentAppointment['isConfirmed'] = true; } else { currentAppointment['isConfirmed'] = false; } currentAppointment['start'] = event['start']; console.log("Appt start: " + event['start'].toISOString()); currentAppointment['end'] = event['end']; currentAppointment['description'] = event['description']; currentAppointment['isAllDay'] = event['isAllDay']; currentAppointment['isConflict'] = event['isConflict']; currentAppointment['scheduleId'] = event['scheduleId']; currentAppointment['roomId'] = event['roomId']; currentAppointment['doctorId'] = event['doctorId']; currentAppointment['clientId'] = event['clientId']; currentAppointment['clientName'] = event['clientName']; currentAppointment['patientId'] = event['patientId']; currentAppointment['patientName'] = event['patientName']; currentAppointment['title'] = event['title']; currentAppointment['appointmentTypeId'] = event['appointmentTypeId']; currentAppointment['appointmentType'] = event['appointmentType']; } ``` -------------------------------- ### Using Open Iconic SVG Sprite Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/ClinicManagement/src/ClinicManagement.Blazor/wwwroot/css/open-iconic/README.md This demonstrates how to use Open Iconic's SVG sprite for displaying icons efficiently. It utilizes the `` and `` elements, with specific classes for styling and referencing individual icons within the sprite. The provided CSS snippet shows how to size the icons. ```HTML ``` ```CSS .icon { width: 16px; height: 16px; } ``` ```CSS .icon-account-login { fill: #f00; } ``` -------------------------------- ### Ardalis.GuardClauses - Consistent Guard Clauses Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md Provides a collection of common guard clauses to ensure consistent error handling and input validation across the application. It can be extended for custom domain-specific exceptions. ```csharp /// /// Contains common guard clauses so you can use them consistently. Also can be easily extended to apply your own guards for custom/domain exception cases. /// public static class Guard { public static void AgainstNull(object argument, string parameterName) { if (argument == null) { throw new ArgumentNullException(parameterName); } } } ``` -------------------------------- ### Ardalis.HttpClientTestExtensions - API Integration Testing Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md Reduces boilerplate code in ASP.NET Core API integration and functional tests. It provides extensions for simplifying HTTP client interactions during testing. ```csharp /// /// Removes boilerplate code from ASP.NET Core API integration/functional tests. /// public static class HttpClientExtensions { public static async Task PostAsJsonAsync(this HttpClient client, string requestUri, T value) { // Implementation details for posting JSON content return await client.PostAsync(requestUri, new StringContent(System.Text.Json.JsonSerializer.Serialize(value), System.Text.Encoding.UTF8, "application/json")); } } ``` -------------------------------- ### Integrating Open Iconic with Foundation Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/css/open-iconic/README.md This demonstrates how to include the Open Iconic Foundation stylesheet and apply the corresponding classes to display icons within a Foundation project. The `` tag with `fi-icon-name` class is used for this purpose. ```HTML ``` ```HTML ``` -------------------------------- ### Ardalis.Specification - Specification Pattern for ORMs Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md An implementation of the Specification design pattern, optimized for use with Object-Relational Mappers (ORMs) like Entity Framework (Core). It helps in creating reusable query logic. ```csharp /// /// An implementation of the Specification design pattern that is well-suited to work with ORMs like Entity Framework (Core). /// public interface ISpecification { Expression> Criteria { get; } List>> IncludeExpressions { get; } } ``` -------------------------------- ### Integrating Open Iconic with Foundation Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/ClinicManagement/src/ClinicManagement.Blazor/wwwroot/css/open-iconic/README.md This demonstrates how to include the Open Iconic Foundation stylesheet and apply the corresponding classes to display icons within a Foundation project. The `` tag with `fi-icon-name` class is used for this purpose. ```HTML ``` ```HTML ``` -------------------------------- ### MediatR - Mediator Pattern Implementation Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md A library used for implementing the mediator pattern, which facilitates communication between different parts of an application by decoupling senders and receivers of messages (commands and events). ```csharp /// /// Used to implement mediator pattern for commands and events. /// public interface IMediator { Task Send(IRequest request, CancellationToken cancellationToken = default); Task Send(IRequest request, CancellationToken cancellationToken = default); } ``` -------------------------------- ### Displaying Open Iconic SVGs Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/css/open-iconic/README.md This snippet shows the basic method for displaying Open Iconic icons using their SVG files. It involves using an `` tag with the `src` attribute pointing to the SVG file and including an `alt` attribute for accessibility. ```HTML icon name ``` -------------------------------- ### Integrating Open Iconic with Bootstrap Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/css/open-iconic/README.md This shows how to link the Open Iconic Bootstrap stylesheet and use the provided classes to display icons within a Bootstrap project. The `` tag with `oi` and `oi-icon-name` classes is used for icon rendering. ```HTML ``` ```HTML ``` -------------------------------- ### Kendo Scheduler Event Template Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html Defines an HTML template for rendering events in the Kendo UI Scheduler. This template allows for custom display of event details, including title, time, and potentially other data fields. ```HTML ``` -------------------------------- ### Displaying Open Iconic SVGs Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/ClinicManagement/src/ClinicManagement.Blazor/wwwroot/css/open-iconic/README.md This snippet shows the basic method for displaying Open Iconic icons using their SVG files. It involves using an `` tag with the `src` attribute pointing to the SVG file and including an `alt` attribute for accessibility. ```HTML icon name ``` -------------------------------- ### HTML Kendo Scheduler Appointment Template Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html An HTML template used for rendering individual appointments within a Kendo UI scheduler. It includes data attributes for conflict and confirmation status, inline styles for background color, and displays the appointment title. ```html
#: title #
``` -------------------------------- ### JavaScript Appointment Event Handlers (Move, Edit, Delete) Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html Handles user interactions with scheduler appointments, specifically for moving, editing, and deleting. These functions capture event data, update a current appointment object, invoke asynchronous methods on a KendoCall instance, and refresh the scheduler. ```javascript function onMoveEnd(e) { createAppointment(e.event); currentAppointment['roomId'] = e.resources['roomId']; currentAppointment['start'] = e['start']; currentAppointment['end'] = e['end']; instanceKendoCall.invokeMethodAsync('KendoCall', 'move', JSON.stringify(currentAppointment)); hardRefresh(); } function onEdit(e) { e.preventDefault(); createAppointment(e.event); instanceKendoCall.invokeMethodAsync('KendoCall', 'edit', JSON.stringify(currentAppointment)); } function onDelete(e) { e.preventDefault(); createAppointment(e.event); instanceKendoCall.invokeMethodAsync('KendoCall', 'delete', JSON.stringify(currentAppointment)); } ``` -------------------------------- ### Integrating Open Iconic with Bootstrap Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/ClinicManagement/src/ClinicManagement.Blazor/wwwroot/css/open-iconic/README.md This shows how to link the Open Iconic Bootstrap stylesheet and use the provided classes to display icons within a Bootstrap project. The `` tag with `oi` and `oi-icon-name` classes is used for icon rendering. ```HTML ``` ```HTML ``` -------------------------------- ### Standalone Open Iconic Icon Font Usage Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/css/open-iconic/README.md This shows how to link the default Open Iconic stylesheet and use the provided classes for standalone icon integration. The `` tag with the `oi` class and a `data-glyph` attribute is used to specify the icon. ```HTML ``` ```HTML ``` -------------------------------- ### Standalone Open Iconic Icon Font Usage Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/ClinicManagement/src/ClinicManagement.Blazor/wwwroot/css/open-iconic/README.md This shows how to link the default Open Iconic stylesheet and use the provided classes for standalone icon integration. The `` tag with the `oi` class and a `data-glyph` attribute is used to specify the icon. ```HTML ``` ```HTML ``` -------------------------------- ### Ardalis.Result - Generic Result Type Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/README.md Provides a generic result type for returning outcomes from application services. This type can be easily translated into HTTP status codes or ActionResult types in web applications. ```csharp /// /// Provides a generic result type that can be returned from application services. Can easily be translated into HTTP status codes or ActionResult types. /// public abstract class Result { public abstract bool IsSuccess { get; } public abstract T Value { get; } public abstract string ErrorMessage { get; } public static Result Success(T value) { return new SuccessResult(value); } public static Result Failure(string errorMessage) { return new FailureResult(errorMessage); } } public class SuccessResult : Result { private readonly T _value; public SuccessResult(T value) { _value = value; } public override bool IsSuccess => true; public override T Value => _value; public override string ErrorMessage => null; } public class FailureResult : Result { private readonly string _errorMessage; public FailureResult(string errorMessage) { _errorMessage = errorMessage; } public override bool IsSuccess => false; public override T Value => default(T); public override string ErrorMessage => _errorMessage; } ``` -------------------------------- ### JavaScript Scheduler Event Management Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html Manages scheduler events by finding occurrences within a date range, removing a specific event, and filtering occurrences by resource. It utilizes jQuery for extending event objects and a custom filter function. ```javascript function occurrencesInRangeByResource(start, end, event, resources) { var scheduler = $("#scheduler").data("kendoScheduler"); var occurrences = scheduler.occurrencesInRange(start, end); var idx = occurrences.indexOf(event); if (idx > -1) { occurrences.splice(idx, 1); } event = $.extend({}, event, resources); return filterByResource(occurrences, resourceFieldName, event[resourceFieldName]); } ``` -------------------------------- ### JavaScript Kendo Scheduler Hard Refresh Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html Destroys and empties the Kendo UI scheduler instance. This is typically used to force a complete refresh of the scheduler's UI and data binding. ```javascript function hardRefresh() { var scheduler = $("#scheduler").data("kendoScheduler"); if (scheduler) { scheduler.destroy(); $("#scheduler").empty(); } } ``` -------------------------------- ### JavaScript Filter Occurrences by Resource Source: https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Blazor/wwwroot/index.html Filters a list of scheduler occurrences based on a specific resource field and its value. This function iterates through occurrences and adds matching ones to a result array. ```javascript function filterByResource(occurrences, resourceFieldName, value) { var result = []; var occurrence; for (var idx = 0, length = occurrences.length; idx < length; idx++) { occurrence = occurrences[idx]; if (occurrence[resourceFieldName] === value) { result.push(occurrence); } } return result; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.