Carfamsoft.ModelToView 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Carfamsoft.ModelToView --version 1.0.0
NuGet\Install-Package Carfamsoft.ModelToView -Version 1.0.0
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="Carfamsoft.ModelToView" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Carfamsoft.ModelToView --version 1.0.0
#r "nuget: Carfamsoft.ModelToView, 1.0.0"
#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 Carfamsoft.ModelToView as a Cake Addin
#addin nuget:?package=Carfamsoft.ModelToView&version=1.0.0

// Install Carfamsoft.ModelToView as a Cake Tool
#tool nuget:?package=Carfamsoft.ModelToView&version=1.0.0
using Carfamsoft.ModelToView.WebPages;
using Carfamsoft.ModelToView.ComponentModel.DataAnnotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;

namespace ModelToViewTest
{
    [TestClass]
    public class HtmlControlRendererTest
    {
        [TestMethod]
        public void Should_Render_Object_As_Html()
        {
            // arrange
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");

            var renderer = CreateRenderer(GetModel());

            // act
            var result = renderer.Render();
            Debug.WriteLine(result);

            // assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Contains("First name"));
        }

        [TestMethod]
        public void Should_Render_Object_As_Html_In_French()
        {
            // arrange
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr");

            var renderer = CreateRenderer(GetModel());

            // act
            var result = renderer.Render();
            Debug.WriteLine(result);

            // assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Contains("Prénom(s)"));
        }

        static RegisterBusinessModel GetModel() => new RegisterBusinessModel
        {
            UserName = "bigabdoul",
            FirstName = "Abdoul",
            LastName = "Kaba",
            Gender = "M",
            Email = "abdoul.kaba@example.com",
            CountryId = 223,
            City = "Bamako",
            Address = "Bamako",
            Password = "123456",
            ConfirmPassword = "123456",
            MobilePhone = "12345678",
        };

        static ObjectHtmlViewEngine CreateRenderer(object model) =>
            new ObjectHtmlViewEngine(model, new ControlRenderOptions
            {
                NgModel = "m"
            });
    }

    // DisplayStrings is a type defined in another assembly. It provides localized strings.
    [DisplayResource(ResourceType = typeof(DisplayStrings))]
    public class RegisterBusinessModel
    {
        /*********** Authentication ***********/

        [Required]
        [Display(Name = "UserName", GroupName = "Authentication", Order = 1)]
        [DisplayHint(Icon = "fas fa fa-user")]
        public string UserName { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6, ErrorMessageResourceName = "PasswordLengthError", ErrorMessageResourceType = typeof(DisplayStrings))]
        [DataType(DataType.Password)]
        [Display(Name = "Password", GroupName = "Authentication", Order = 2)]
        [DisplayHint(Icon = "fas fa fa-lock")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "ConfirmPassword", GroupName = "Authentication", Order = 3)]
        [DisplayHint(Icon = "fas fa fa-lock")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.", ErrorMessageResourceName = "ConfirmPasswordError", ErrorMessageResourceType = typeof(DisplayStrings))]
        public string ConfirmPassword { get; set; }

        /*********** Personal Info ***********/

        [Required]
        [Display(Name = "FirstName", GroupName = "PersonalInfo", Order = 1)]
        [DisplayHint(Icon = "fas fa fa-user")]
        public string FirstName { get; set; }

        [Required]
        [Display(Name = "LastName", GroupName = "PersonalInfo", Order = 2)]
        [DisplayHint(Icon = "fas fa fa-user")]
        public string LastName { get; set; }

        [Display(Name = "Gender", GroupName = "PersonalInfo", Order = 3)]
        [DisplayHint(Tag = "select", Options = "=Select|F=Female|M=Male")]
        public string Gender { get; set; }

        /*********** Contact ***********/

        [Required, StringLength(56)]
        [Display(Name = "Email", GroupName = "Contact", Order = 1)]
        [DisplayHint(Icon = "fas fa fa-envelope")]
        public string Email { get; set; }

        [StringLength(15)]
        [Display(Name = "MobilePhone", GroupName = "Contact", Order = 2)]
        [DisplayHint(Icon = "fas fa fa-mobile")]
        public string MobilePhone { get; set; }

        [StringLength(15)]
        [Display(Name = "HomePhone", GroupName = "Contact", Order = 3)]
        [DisplayHint(Icon = "fas fa fa-phone")]
        public string HomePhone { get; set; }

        /*********** Address ***********/

        [Display(Name = "CountryId", GroupName = "Address", Order = 1)]
        [DisplayHint(Icon = "fas fa fa-globe-africa")]
        public int? CountryId { get; set; }

        [StringLength(50)]
        [Display(Name = "CityName", GroupName = "Address", Order = 2)]
        [DisplayHint(Icon = "fas fa fa-city")]
        public string City { get; set; }

        [StringLength(100)]
        [Display(Name = "Address", GroupName = "Address", Order = 3)]
        [DisplayHint(Tag = "textarea", Icon = "fas fa fa-home")]
        public string Address { get; set; }

        [DisplayIgnore]
        public string Token { get; set; }
    }
}
Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Carfamsoft.ModelToView:

Package Downloads
Carfamsoft.ModelToView.Mvc

Provides extension methods for the HtmlHelper class in order to render auto-generated, editable forms and HTML controls.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 813 3/12/2021
1.1.0 648 3/7/2021
1.0.3 713 3/3/2021
1.0.2 688 3/3/2021
1.0.1 734 3/3/2021
1.0.0 278 3/3/2021