Danom.Mvc 1.0.0-beta1

This is a prerelease version of Danom.Mvc.
dotnet add package Danom.Mvc --version 1.0.0-beta1                
NuGet\Install-Package Danom.Mvc -Version 1.0.0-beta1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Danom.Mvc" Version="1.0.0-beta1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Danom.Mvc --version 1.0.0-beta1                
#r "nuget: Danom.Mvc, 1.0.0-beta1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Danom.Mvc as a Cake Addin
#addin nuget:?package=Danom.Mvc&version=1.0.0-beta1&prerelease

// Install Danom.Mvc as a Cake Tool
#tool nuget:?package=Danom.Mvc&version=1.0.0-beta1&prerelease                

Danom.Mvc

NuGet Version build

Danom.Mvc is a library that provides a set of rendering utilities to help integrate the Danom library with common tasks in ASP.NET Core MVC applications.

Getting Started

Install the Danom.Mvc NuGet package:

PM>  Install-Package Danom.Mvc

Or using the dotnet CLI

dotnet add package Danom.Mvc

Working With Option

using Danom.Mvc;
using Microsoft.AspNetCore.Mvc;

public sealed class OptionController
    : DanomController
{
    private readonly Option<string> _someOption = Option.Some("Hello world");
    private readonly Option<string> _noneOption = Option<string>.None();

    public IActionResult OptionSome() =>
        ViewOption(
            option: _someOption,
            viewName: "Detail");

    // Returns the ASP.NET default `NotFound` result
    public IActionResult OptionNone() =>
        ViewOption(
            option: _noneOption,
            viewName: "Detail");

    public IActionResult OptionNoneCustom() =>
        ViewOption(
            option: _noneOption,
            viewName: "Detail",
            noneAction: () => NotFound("Not found!"));
}

Working with Result

using Danom.Mvc;
using Microsoft.AspNetCore.Mvc;

public sealed class ResultController
    : DanomController
{
    private readonly Result<string, ResultErrors> _okResult = Result.Ok("Success!");
    private readonly Result<string, ResultErrors> _errorResult = Result<string>.Error(["An error occurred."]);
    private readonly Result<string, string> _stringErrorResult = Result<string, string>.Error("An error occurred.");

    public IActionResult ResultOk() =>
        ViewResult(
            result: _okResult,
            viewName: "Detail");

    public IActionResult ResultErrors() =>
        ViewResult(
            result: _errorResult,
            viewName: "Detail");

    // Demonstrating error customization, using a string literal for error output
    public IActionResult ResultError() =>
        ViewResult(
            result: _stringErrorResult,
            errorAction: errors => View("Detail", errors),
            viewName: "Detail");

}

Working with ResultOption

using Danom.Mvc;
using Microsoft.AspNetCore.Mvc;

public sealed class ResultOptionController
    : DanomController
{
    private readonly ResultOption<string, ResultErrors> _okResult = ResultOption.Ok("Success!");
    private readonly ResultOption<string, ResultErrors> _errorResult = ResultOption<string>.Error("An error occurred.");
    private readonly ResultOption<string, string> _stringErrorResult = ResultOption<string, string>.Error("An error occurred.");

    public IActionResult ResultOk() =>
        ViewResultOption(
            resultOption: _okResult,
            viewName: "Detail");

    public IActionResult ResultErrors() =>
        ViewResultOption(
            resultOption: _errorResult,
            viewName: "Detail");

    // Demonstrating error customization, using a string literal for error output
    public IActionResult ResultError() =>
        ViewResultOption(
            resultOption: _stringErrorResult,
            errorAction: errors => View("Detail", errors),
            viewName: "Detail");
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-beta1 43 10/11/2024
1.0.0-alpha1 53 8/30/2024