<commit_before>﻿@using UniversityStudentSystem.Web.Areas.Admin.Helpers;
@using UniversityStudentSystem.Web.Areas.Admin.Models;
@{
    string controller = "Tests";
    ViewBag.Title = "Administration - " + controller;
}

@(Html.FullFeaturedGrid<TestAdminModel>(controller, test => test.Id, cols =>
{
    cols.Bound(test => test.Name);
    cols.Bound(test => test.StartDate).Format("{0:dd/MM/yyyy HH:mm}");
    cols.Bound(test => test.EndDate).Format("{0:dd/MM/yyyy HH:mm}");
    cols.Bound(test => test.IsEnabled);
    cols.Command(cmd => { cmd.Destroy(); cmd.Edit(); }); //// cmd.Edit();
}))


@section KendoCss{
    @Styles.Render("~/bundles/css-kendo-silver")
}

@section KendoHead{

    @Scripts.Render("~/bundles/js-kendo")
}

@section KendoJs{
    @Scripts.Render("~/bundles/js-kendo-grid")
}

@{ 
    var culture = System.Globalization.CultureInfo.CurrentCulture.ToString();
}

@section Scripts{
    @Scripts.Render("~/bundles/jqueryval")
    <script>

        $(document).ready(function () {
            var kendoGrid = $('#grid').getKendoGrid();
            console.log(kendoGrid);

            kendoGrid.dataSource.transport.parameterMap = function (data, type) {
                if (type == 'update') {

                    var startDate = data.StartDate.getDate() + '/' + (data.StartDate.getMonth() + 1) + '/' + data.StartDate.getFullYear() + ' ' + data.StartDate.getHours() + ':' + data.StartDate.getMinutes();
                    var endDate = data.EndDate.getDate() + '/' + (data.EndDate.getMonth() + 1) + '/' + data.EndDate.getFullYear() + ' ' + data.EndDate.getHours() + ':' + data.EndDate.getMinutes();

                    return {
                        Id: data.Id,
                        Name: data.Name,
                        IsEnabled: data.IsEnabled,
                        StartDate: startDate,
                        EndDate: endDate
                    }
                }
            };
        })

        jQuery.extend(jQuery.validator.methods, {
            date: function (value, element) {
                var res = this.optional(element) || kendo.parseDate(value, "dd/MM/yyyy HH:mm") != null;
                return res;
            },
            number: function (value, element) {
                return this.optional(element) || kendo.parseFloat(value) != null;
            }
        });

        kendo.ui.validator.rules.mvcdate = function (input) {
            if ($(input).attr('data-role') !== 'datetimepicker') {
                return true;
            }
            //KENDO :(
            //use the custom date format here
            //kendo.parseDate - http://docs.telerik.com/kendo-ui/api/javascript/kendo#methods-parseDate

            return input.val() === "" || kendo.parseDate(input.val(), "dd/MM/yyyy HH:mm") !== null;
        }

        //kendo.ui.validator.rules.mvcnumber = function (input) {
        //    return input;
        //    //kendo.parseDate - http://docs.telerik.com/kendo-ui/api/javascript/kendo#methods-parseDate
        //}

</script>
    <script src="@Url.Content("~/Scripts/Kendo/kendo.culture." + culture + ".min.js")"></script>    
}<commit_msg>Fixing validation for kendo datetimepicker  with configuration for sending correct format to the server. #2<commit_after>﻿@using UniversityStudentSystem.Web.Areas.Admin.Helpers;
@using UniversityStudentSystem.Web.Areas.Admin.Models;
@{
    string controller = "Tests";
    ViewBag.Title = "Administration - " + controller;
}

@(Html.FullFeaturedGrid<TestAdminModel>(controller, test => test.Id, cols =>
{
    cols.Bound(test => test.Name);
    cols.Bound(test => test.StartDate).Format("{0:dd/MM/yyyy HH:mm}");
    cols.Bound(test => test.EndDate).Format("{0:dd/MM/yyyy HH:mm}");
    cols.Bound(test => test.IsEnabled);
    cols.Command(cmd => { cmd.Destroy(); cmd.Edit(); });
}))


@section KendoCss{
    @Styles.Render("~/bundles/css-kendo-silver")
}

@section KendoHead{

    @Scripts.Render("~/bundles/js-kendo")
}

@section KendoJs{
    @Scripts.Render("~/bundles/js-kendo-grid")
}

@{ 
    var culture = System.Globalization.CultureInfo.CurrentCulture.ToString();
}

@section Scripts{
    @Scripts.Render("~/bundles/jqueryval")
    <script>

        $(document).ready(function () {
            var kendoGrid = $('#grid').getKendoGrid();
            console.log(kendoGrid);

            kendoGrid.dataSource.transport.parameterMap = function (data, type) {
                if (type == 'update') {

                    var startDate = data.StartDate.getDate() + '/' + (data.StartDate.getMonth() + 1) + '/' + data.StartDate.getFullYear() + ' ' + data.StartDate.getHours() + ':' + data.StartDate.getMinutes();
                    var endDate = data.EndDate.getDate() + '/' + (data.EndDate.getMonth() + 1) + '/' + data.EndDate.getFullYear() + ' ' + data.EndDate.getHours() + ':' + data.EndDate.getMinutes();

                    return {
                        Id: data.Id,
                        Name: data.Name,
                        IsEnabled: data.IsEnabled,
                        StartDate: startDate,
                        EndDate: endDate
                    }
                }
            };
        })

        jQuery.extend(jQuery.validator.methods, {
            date: function (value, element) {
                var res = this.optional(element) || kendo.parseDate(value, "dd/MM/yyyy HH:mm") != null;
                return res;
            },
            number: function (value, element) {
                return this.optional(element) || kendo.parseFloat(value) != null;
            }
        });

        kendo.ui.validator.rules.mvcdate = function (input) {
            if ($(input).attr('data-role') !== 'datetimepicker') {
                return true;
            }
            //KENDO :(
            //use the custom date format here
            //kendo.parseDate - http://docs.telerik.com/kendo-ui/api/javascript/kendo#methods-parseDate

            return input.val() === "" || kendo.parseDate(input.val(), "dd/MM/yyyy HH:mm") !== null;
        } 

        //kendo.ui.validator.rules.mvcnumber = function (input) {
        //    return input;
        //    //kendo.parseDate - http://docs.telerik.com/kendo-ui/api/javascript/kendo#methods-parseDate
        //}

</script>
    <script src="@Url.Content("~/Scripts/Kendo/kendo.culture." + culture + ".min.js")"></script>    
}
{'fraction_non_alphanumeric': 0.16424510423247, 'fraction_numerical': 0.001421351863550221, 'mean_word_length': 2.0638606676342524, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4446291', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1913, 'n_words': 293}