MySql Simple

Simplifying processes in your .NET Core MVC application

Sample code

The following is a sample code to set up a form and submission using the library.

Your model:


    class Employee {

        [MaxLength(40, ErrorMessage = "Name is too long")]
        [Required]
        public string Name { get; set; }

        [Display(Name = "Employee title")]
        [MaxLength(50)]
        public string Title { get; set; }

    }

Your razor form:


<form data-form-submit="@Url.Action("Add")" data-ng-success-url="@Url.Content("~/completed")">
    @{ var i = Html.getInputMaker<Employee>(); }
    @i.Make(m => m.Name)
    @i.Make(m => m.Title)
</form>

And finally your controller action:


[ValidateModel]
public IActionResult Add(Employee employee) => employee.Add();