Quantcast
Channel: ASP.NET Core
Viewing all 9386 articles
Browse latest View live

An unhandled exception occurred while processing the request.

$
0
0

I got the following message below and have no idea what to do?

TypeLoadException: Method 'Create' in type 'Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlTranslatingExpressionVisitorFactory' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.

Below is my code for ApplicationDbContext:

<div>using Bumples15.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
</div> <div>namespace Bumples15.Data
{
    public class ApplicationDbContext : IdentityDbContext
    {
       
        public ApplicationDbContext(DbContextOptions options) : base(options) * it underlined base(options)
        {
        }
        public DbSet<Product> Product { get; set; }
        public DbSet<Order> Order { get; set; }
</div> <div>
    }
}
</div>

Thanks Jen


Javascript and Asp.Net Core 3.1 input check boxes broken

$
0
0

Hello,

     So I had this working in Asp.net Core 2.2 with Twitter-Bootstrap 3.3.7.  I then upgraded to Asp.net Core 3.1 and Twitter-Bootstrap 4.4.  Now I am unable to get some of my javascript functions to work.  Setting breakpoints in the javascript in Chrome and Edge, they do not get hit at all.  Though I ran the output from the web through JS Fiddle and it works perfectly fine there.  So I am at a loss for what I did to break this.

What I have is a gating function within javascript that will uncheck any check boxes that are in sequence after a check box if it is unchecked, if it is checked it will enable the next available check box, leaving the others disabled.  When I run it in IIS Express this no longer happens.

Here is the Javascript I have for one page:

//Loops through the checkboxes and disables the next ones if the previous is not checked
function changeFields(fields) {
    fields.change(function () {
        Array.prototype.reduce.call(fields, function (prev, curr) {
            curr.disabled = !prev.checked || prev.disabled;


            //If you want to uncheck remaining use this instead of above line:
            curr.checked = prev.checked ? curr.checked : false;
            curr.disabled = !prev.checked;

            return curr;
        });
    });
}

//Call the for the CharacterCraft
changeFields($(".cALScb"));
changeFields($(".cALMcb"));
changeFields($(".cBLScb"));
changeFields($(".cBLMcb"));
changeFields($(".cCLScb"));
changeFields($(".cCLMcb"));



Here is the what I have in view calling this:

<form asp-controller="CharacterCrafts" asp-action="Edit" method="post"><div class="form-horizontal"><hr />
        @Html.ValidationSummary( true, "", new { @class = "text-danger" } )<div class="col-lg-12 text-center"><b style="text-align: center; font-family: 'Times New Roman', Times, serif; font-size: x-large">@Html.DisplayFor( a => a.CharNames.CharFullName )</b><br /><b style="text-align: center; font-family: 'Times New Roman', Times, serif; font-size: large">@Html.DisplayFor( a => a.CharNames.ProfName )</b></div><br /><br /><div class="form-group"><div class="form-group row"><div class="col-lg-2">
                    @Html.Label( "Crafting Class" )</div><div class="col-lg-1">
                    @Html.Label( "Tier Achieved" )</div><div class="col-lg-1">
                    @Html.Label( "Tier Name" )</div><div class="col-lg-1">
                    @Html.Label( "Mastery" )</div><div class="col-lg-1">
                    @Html.Label( "Tier Achieved" )</div><div class="col-lg-1">
                    @Html.Label( "Tier Name" )</div><div class="col-lg-1">
                    @Html.Label( "Mastery" )</div><div class="col-lg-1">
                    @Html.Label( "Tier Achieved" )</div><div class="col-lg-1">
                    @Html.Label( "Tier Name" )</div><div class="col-lg-1">
                    @Html.Label( "Mastery" )</div></div><div class="form-group row">
                @for ( var h = 0; h<1; h++ )
                {<div class="col-lg-2"><br /><br /><br /><b>@Html.DisplayFor( a => a.CraftListA[ h ].CraftClassName )</b><br /><br /></div><div class="form-group row col-lg-10">
                        @{ int j = 0;}
                        @for ( var i = 0; i<Model.CraftListA.Count; i++ )
                        {<input type="hidden" asp-for="@Model.CraftListA[i].CharCraftCharID" /><input type="hidden" asp-for="@Model.CraftListA[i].CharCraftClassID" /><input type="hidden" asp-for="@Model.CraftListA[i].CharCraftLevelID" /><input type="hidden" asp-for="@Model.CraftListA[i].CraftLevelTier" /><div class="col-lg-1"><input type="checkbox" asp-for="@Model.CraftListA[i].CraftLevelSet" class="cALScb" /></div><div class="col-lg-2"><b>@Html.DisplayFor( a => a.CraftListA[ i ].CraftLevelName )</b></div><div class="col-lg-1"><input type="checkbox" asp-for="@Model.CraftListA[i].CraftLevelMastery" class="cALMcb" /></div>
                            j++;
                            if ( j==3 )
                            {<br />
                                j=0;
                            }
                            else
                            {
                                continue;
                            }
                        }</div>
                }</div><div class="form-group row">
                @for ( var h = 0; h<1; h++ )
                {<div class="col-lg-2"><br /><br /><br /><b>@Html.DisplayFor( a => a.CraftListB[ h ].CraftClassName )</b><br /><br /></div><div class="form-group row col-lg-10">
                        @{ int j = 0;}
                        @for ( var i = 0; i<Model.CraftListB.Count; i++ )
                        {<input type="hidden" asp-for="@Model.CraftListB[i].CharCraftCharID" /><input type="hidden" asp-for="@Model.CraftListB[i].CharCraftClassID" /><input type="hidden" asp-for="@Model.CraftListB[i].CharCraftLevelID" /><input type="hidden" asp-for="@Model.CraftListB[i].CraftLevelTier" /><div class="col-lg-1"><input type="checkbox" asp-for="@Model.CraftListB[i].CraftLevelSet" class="cBLScb" /></div><div class="col-lg-2"><b>@Html.DisplayFor( a => a.CraftListB[ i ].CraftLevelName )</b></div><div class="col-lg-1"><input type="checkbox" asp-for="@Model.CraftListB[i].CraftLevelMastery" class="cBLMcb" /></div>
                            j++;
                            if ( j==3 )
                            {<br />
                                j=0;
                            }
                            else
                            {
                                continue;
                            }
                        }</div>
                }</div><div class="form-group row">
                @for ( var h = 0; h<1; h++ )
                {<div class="col-lg-2"><br /><br /><br /><b>@Html.DisplayFor( a => a.CraftListC[ h ].CraftClassName )</b><br /><br /></div><div class="form-group row col-lg-10">
                        @{ int j = 0;}
                        @for ( var i = 0; i<Model.CraftListC.Count; i++ )
                        {<input type="hidden" asp-for="@Model.CraftListC[i].CharCraftCharID" /><input type="hidden" asp-for="@Model.CraftListC[i].CharCraftClassID" /><input type="hidden" asp-for="@Model.CraftListC[i].CharCraftLevelID" /><input type="hidden" asp-for="@Model.CraftListC[i].CraftLevelTier" /><div class="col-lg-1"><input type="checkbox" asp-for="@Model.CraftListC[i].CraftLevelSet" class="cCLScb" /></div><div class="col-lg-2"><b>@Html.DisplayFor( a => a.CraftListC[ i ].CraftLevelName )</b></div><div class="col-lg-1"><input type="checkbox" asp-for="@Model.CraftListC[i].CraftLevelMastery" class="cCLMcb" /></div>
                            j++;
                            if ( j==3 )
                            {<br />
                                j=0;
                            }
                            else
                            {
                                continue;
                            }
                        }</div>
                }</div></div><div class="form-group row"><div class="col-lg-12 row"><div class="col-lg-3"><b>Select a Guild:</b></div>
                @for ( var i = 0; i<Model.Guild.Count; i++ )
                {<input type="hidden" asp-for="@Model.Guild[i].FactionID" /><div class="col-lg-1"><input type="checkbox" asp-for="@Model.Guild[i].isChecked" /></div><div class="col-lg-3"><b>@Html.DisplayFor( a => a.Guild[ i ].FactionName )</b></div>
                }</div></div><div class="form-group row"><div class="col-lg-12 row"><div class="col-lg-offset-2 col-lg-2"><input type="submit" value="Save" class="btn btn-secondary" /></div><div class="col-lg-5"></div><div class="col-lg-2"><a asp-controller="Menu" , asp-action="EdChar" , null, class="btn btn-danger">Cancel</a></div></div></div></div></form>

Everything displays correctly on the page, but after an unchecked check box everything is still enabled.  This can been seen in the output from Edge:

<div class="form-group"><div class="form-group row"><div class="col-lg-2"><label for="Crafting_Class">Crafting Class</label></div><div class="col-lg-1"><label for="Tier_Achieved">Tier Achieved</label></div><div class="col-lg-1"><label for="Tier_Name">Tier Name</label></div><div class="col-lg-1"><label for="Mastery">Mastery</label></div><div class="col-lg-1"><label for="Tier_Achieved">Tier Achieved</label></div><div class="col-lg-1"><label for="Tier_Name">Tier Name</label></div><div class="col-lg-1"><label for="Mastery">Mastery</label></div><div class="col-lg-1"><label for="Tier_Achieved">Tier Achieved</label></div><div class="col-lg-1"><label for="Tier_Name">Tier Name</label></div><div class="col-lg-1"><label for="Mastery">Mastery</label></div></div><div class="form-group row"><div class="col-lg-2"><br><br><br><b>Farmer</b><br><br></div><div class="form-group row col-lg-10"><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_0__CharCraftCharID" name="CraftListA[0].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_0__CharCraftClassID" name="CraftListA[0].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_0__CharCraftLevelID" name="CraftListA[0].CharCraftLevelID" value="1"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_0__CraftLevelTier" name="CraftListA[0].CraftLevelTier" value="1"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_0__CraftLevelSet" name="CraftListA[0].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Apprentice</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_0__CraftLevelMastery" name="CraftListA[0].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_1__CharCraftCharID" name="CraftListA[1].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_1__CharCraftClassID" name="CraftListA[1].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_1__CharCraftLevelID" name="CraftListA[1].CharCraftLevelID" value="5"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_1__CraftLevelTier" name="CraftListA[1].CraftLevelTier" value="2"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_1__CraftLevelSet" name="CraftListA[1].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Journeyman</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_1__CraftLevelMastery" name="CraftListA[1].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_2__CharCraftCharID" name="CraftListA[2].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_2__CharCraftClassID" name="CraftListA[2].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_2__CharCraftLevelID" name="CraftListA[2].CharCraftLevelID" value="4"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_2__CraftLevelTier" name="CraftListA[2].CraftLevelTier" value="3"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_2__CraftLevelSet" name="CraftListA[2].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Expert</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_2__CraftLevelMastery" name="CraftListA[2].CraftLevelMastery" value="true"></div><br><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_3__CharCraftCharID" name="CraftListA[3].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_3__CharCraftClassID" name="CraftListA[3].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_3__CharCraftLevelID" name="CraftListA[3].CharCraftLevelID" value="2"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_3__CraftLevelTier" name="CraftListA[3].CraftLevelTier" value="4"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_3__CraftLevelSet" name="CraftListA[3].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Artisan</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_3__CraftLevelMastery" name="CraftListA[3].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_4__CharCraftCharID" name="CraftListA[4].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_4__CharCraftClassID" name="CraftListA[4].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_4__CharCraftLevelID" name="CraftListA[4].CharCraftLevelID" value="6"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_4__CraftLevelTier" name="CraftListA[4].CraftLevelTier" value="5"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_4__CraftLevelSet" name="CraftListA[4].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Master</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_4__CraftLevelMastery" name="CraftListA[4].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_5__CharCraftCharID" name="CraftListA[5].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_5__CharCraftClassID" name="CraftListA[5].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_5__CharCraftLevelID" name="CraftListA[5].CharCraftLevelID" value="7"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_5__CraftLevelTier" name="CraftListA[5].CraftLevelTier" value="6"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_5__CraftLevelSet" name="CraftListA[5].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Supreme</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_5__CraftLevelMastery" name="CraftListA[5].CraftLevelMastery" value="true"></div><br><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_6__CharCraftCharID" name="CraftListA[6].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_6__CharCraftClassID" name="CraftListA[6].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_6__CharCraftLevelID" name="CraftListA[6].CharCraftLevelID" value="9"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_6__CraftLevelTier" name="CraftListA[6].CraftLevelTier" value="7"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_6__CraftLevelSet" name="CraftListA[6].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Westfold</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_6__CraftLevelMastery" name="CraftListA[6].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_7__CharCraftCharID" name="CraftListA[7].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_7__CharCraftClassID" name="CraftListA[7].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_7__CharCraftLevelID" name="CraftListA[7].CharCraftLevelID" value="3"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_7__CraftLevelTier" name="CraftListA[7].CraftLevelTier" value="8"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_7__CraftLevelSet" name="CraftListA[7].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Eastenmnet</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_7__CraftLevelMastery" name="CraftListA[7].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListA_8__CharCraftCharID" name="CraftListA[8].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListA_8__CharCraftClassID" name="CraftListA[8].CharCraftClassID" value="2"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListA_8__CharCraftLevelID" name="CraftListA[8].CharCraftLevelID" value="8"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListA_8__CraftLevelTier" name="CraftListA[8].CraftLevelTier" value="9"><div class="col-lg-1"><input type="checkbox" class="cALScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListA_8__CraftLevelSet" name="CraftListA[8].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Westemnet</b></div><div class="col-lg-1"><input type="checkbox" class="cALMcb" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListA_8__CraftLevelMastery" name="CraftListA[8].CraftLevelMastery" value="true"></div><br></div></div><div class="form-group row"><div class="col-lg-2"><br><br><br><b>Scholar</b><br><br></div><div class="form-group row col-lg-10"><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_0__CharCraftCharID" name="CraftListB[0].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_0__CharCraftClassID" name="CraftListB[0].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_0__CharCraftLevelID" name="CraftListB[0].CharCraftLevelID" value="1"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_0__CraftLevelTier" name="CraftListB[0].CraftLevelTier" value="1"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_0__CraftLevelSet" name="CraftListB[0].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Apprentice</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_0__CraftLevelMastery" name="CraftListB[0].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_1__CharCraftCharID" name="CraftListB[1].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_1__CharCraftClassID" name="CraftListB[1].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_1__CharCraftLevelID" name="CraftListB[1].CharCraftLevelID" value="5"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_1__CraftLevelTier" name="CraftListB[1].CraftLevelTier" value="2"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_1__CraftLevelSet" name="CraftListB[1].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Journeyman</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_1__CraftLevelMastery" name="CraftListB[1].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_2__CharCraftCharID" name="CraftListB[2].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_2__CharCraftClassID" name="CraftListB[2].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_2__CharCraftLevelID" name="CraftListB[2].CharCraftLevelID" value="4"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_2__CraftLevelTier" name="CraftListB[2].CraftLevelTier" value="3"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_2__CraftLevelSet" name="CraftListB[2].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Expert</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_2__CraftLevelMastery" name="CraftListB[2].CraftLevelMastery" value="true"></div><br><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_3__CharCraftCharID" name="CraftListB[3].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_3__CharCraftClassID" name="CraftListB[3].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_3__CharCraftLevelID" name="CraftListB[3].CharCraftLevelID" value="2"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_3__CraftLevelTier" name="CraftListB[3].CraftLevelTier" value="4"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_3__CraftLevelSet" name="CraftListB[3].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Artisan</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_3__CraftLevelMastery" name="CraftListB[3].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_4__CharCraftCharID" name="CraftListB[4].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_4__CharCraftClassID" name="CraftListB[4].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_4__CharCraftLevelID" name="CraftListB[4].CharCraftLevelID" value="6"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_4__CraftLevelTier" name="CraftListB[4].CraftLevelTier" value="5"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_4__CraftLevelSet" name="CraftListB[4].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Master</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_4__CraftLevelMastery" name="CraftListB[4].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_5__CharCraftCharID" name="CraftListB[5].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_5__CharCraftClassID" name="CraftListB[5].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_5__CharCraftLevelID" name="CraftListB[5].CharCraftLevelID" value="7"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_5__CraftLevelTier" name="CraftListB[5].CraftLevelTier" value="6"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_5__CraftLevelSet" name="CraftListB[5].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Supreme</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_5__CraftLevelMastery" name="CraftListB[5].CraftLevelMastery" value="true"></div><br><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_6__CharCraftCharID" name="CraftListB[6].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_6__CharCraftClassID" name="CraftListB[6].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_6__CharCraftLevelID" name="CraftListB[6].CharCraftLevelID" value="9"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_6__CraftLevelTier" name="CraftListB[6].CraftLevelTier" value="7"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_6__CraftLevelSet" name="CraftListB[6].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Westfold</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_6__CraftLevelMastery" name="CraftListB[6].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_7__CharCraftCharID" name="CraftListB[7].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_7__CharCraftClassID" name="CraftListB[7].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_7__CharCraftLevelID" name="CraftListB[7].CharCraftLevelID" value="3"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_7__CraftLevelTier" name="CraftListB[7].CraftLevelTier" value="8"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_7__CraftLevelSet" name="CraftListB[7].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Eastenmnet</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_7__CraftLevelMastery" name="CraftListB[7].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListB_8__CharCraftCharID" name="CraftListB[8].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListB_8__CharCraftClassID" name="CraftListB[8].CharCraftClassID" value="7"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListB_8__CharCraftLevelID" name="CraftListB[8].CharCraftLevelID" value="8"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListB_8__CraftLevelTier" name="CraftListB[8].CraftLevelTier" value="9"><div class="col-lg-1"><input type="checkbox" class="cBLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListB_8__CraftLevelSet" name="CraftListB[8].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Westemnet</b></div><div class="col-lg-1"><input type="checkbox" class="cBLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListB_8__CraftLevelMastery" name="CraftListB[8].CraftLevelMastery" value="true"></div><br></div></div><div class="form-group row"><div class="col-lg-2"><br><br><br><b>Weaponsmith</b><br><br></div><div class="form-group row col-lg-10"><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_0__CharCraftCharID" name="CraftListC[0].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_0__CharCraftClassID" name="CraftListC[0].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_0__CharCraftLevelID" name="CraftListC[0].CharCraftLevelID" value="1"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_0__CraftLevelTier" name="CraftListC[0].CraftLevelTier" value="1"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_0__CraftLevelSet" name="CraftListC[0].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Apprentice</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_0__CraftLevelMastery" name="CraftListC[0].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_1__CharCraftCharID" name="CraftListC[1].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_1__CharCraftClassID" name="CraftListC[1].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_1__CharCraftLevelID" name="CraftListC[1].CharCraftLevelID" value="5"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_1__CraftLevelTier" name="CraftListC[1].CraftLevelTier" value="2"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_1__CraftLevelSet" name="CraftListC[1].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Journeyman</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_1__CraftLevelMastery" name="CraftListC[1].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_2__CharCraftCharID" name="CraftListC[2].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_2__CharCraftClassID" name="CraftListC[2].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_2__CharCraftLevelID" name="CraftListC[2].CharCraftLevelID" value="4"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_2__CraftLevelTier" name="CraftListC[2].CraftLevelTier" value="3"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_2__CraftLevelSet" name="CraftListC[2].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Expert</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_2__CraftLevelMastery" name="CraftListC[2].CraftLevelMastery" value="true"></div><br><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_3__CharCraftCharID" name="CraftListC[3].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_3__CharCraftClassID" name="CraftListC[3].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_3__CharCraftLevelID" name="CraftListC[3].CharCraftLevelID" value="2"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_3__CraftLevelTier" name="CraftListC[3].CraftLevelTier" value="4"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_3__CraftLevelSet" name="CraftListC[3].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Artisan</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_3__CraftLevelMastery" name="CraftListC[3].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_4__CharCraftCharID" name="CraftListC[4].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_4__CharCraftClassID" name="CraftListC[4].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_4__CharCraftLevelID" name="CraftListC[4].CharCraftLevelID" value="6"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_4__CraftLevelTier" name="CraftListC[4].CraftLevelTier" value="5"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_4__CraftLevelSet" name="CraftListC[4].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Master</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_4__CraftLevelMastery" name="CraftListC[4].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_5__CharCraftCharID" name="CraftListC[5].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_5__CharCraftClassID" name="CraftListC[5].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_5__CharCraftLevelID" name="CraftListC[5].CharCraftLevelID" value="7"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_5__CraftLevelTier" name="CraftListC[5].CraftLevelTier" value="6"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_5__CraftLevelSet" name="CraftListC[5].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Supreme</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_5__CraftLevelMastery" name="CraftListC[5].CraftLevelMastery" value="true"></div><br><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_6__CharCraftCharID" name="CraftListC[6].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_6__CharCraftClassID" name="CraftListC[6].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_6__CharCraftLevelID" name="CraftListC[6].CharCraftLevelID" value="9"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_6__CraftLevelTier" name="CraftListC[6].CraftLevelTier" value="7"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_6__CraftLevelSet" name="CraftListC[6].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Westfold</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" checked="checked" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_6__CraftLevelMastery" name="CraftListC[6].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_7__CharCraftCharID" name="CraftListC[7].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_7__CharCraftClassID" name="CraftListC[7].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_7__CharCraftLevelID" name="CraftListC[7].CharCraftLevelID" value="3"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_7__CraftLevelTier" name="CraftListC[7].CraftLevelTier" value="8"><div class="col-lg-1"><input type="checkbox" class="cCLScb" checked="checked" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_7__CraftLevelSet" name="CraftListC[7].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Eastenmnet</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_7__CraftLevelMastery" name="CraftListC[7].CraftLevelMastery" value="true"></div><input type="hidden" data-val="true" data-val-required="The CharCraftCharID field is required." id="CraftListC_8__CharCraftCharID" name="CraftListC[8].CharCraftCharID" value="1"><input type="hidden" data-val="true" data-val-required="The CharCraftClassID field is required." id="CraftListC_8__CharCraftClassID" name="CraftListC[8].CharCraftClassID" value="9"><input type="hidden" data-val="true" data-val-required="The CharCraftLevelID field is required." id="CraftListC_8__CharCraftLevelID" name="CraftListC[8].CharCraftLevelID" value="8"><input type="hidden" data-val="true" data-val-required="The CraftLevelTier field is required." id="CraftListC_8__CraftLevelTier" name="CraftListC[8].CraftLevelTier" value="9"><div class="col-lg-1"><input type="checkbox" class="cCLScb" data-val="true" data-val-required="The CraftLevelSet field is required." id="CraftListC_8__CraftLevelSet" name="CraftListC[8].CraftLevelSet" value="true"></div><div class="col-lg-2"><b>Westemnet</b></div><div class="col-lg-1"><input type="checkbox" class="cCLMcb" data-val="true" data-val-required="The CraftLevelMastery field is required." id="CraftListC_8__CraftLevelMastery" name="CraftListC[8].CraftLevelMastery" value="true"></div><br></div></div></div>

Ideally from the output the very last check box should be disabled, but it is not.  Though if I go to JS Fiddle, this works as such: https://jsfiddle.net/MikeRM2/bzfcme06/

So this leads to wondering what went wrong, as it works in JS Fiddle but not on the actual site.  I am not getting any errors in the console or debug.  Any thoughts on why this is not working anymore would be appreciated.

Problem for using Asp.net c# and html mixing code

$
0
0

I tried to use below code in asp.net but there is error in html tags like and and say it could not find begin tag. but begin tag is in first if. the errors are in between line 44 to 52.

@{string n ="";int j =0;foreach(var item inModel.RelatedProduct){if(item.ProductId!= n)
                j =1;else
                j =0;if(j==1){<div class="modal fade" id="myModal" role="dialog"><div class="modal-dialog modal-dialog-centered " role="document"><div class="modal-content"><div class="modal-header"><h5 class="modal-title">@item.CatalogDescription</h5><button class="close" type="button" data-dismiss="modal"><span aria-hidden="true">&times;</span></button></div><div class="modal-body"><table class="table table-hover"><thead class="thead-dark"><tr><td>Customer</td></tr>}@if(j ==1|| j ==0){<tr><td>@item.CustomerName</td><td>@item.Price</td></tr>}@if(j==1){</table></div><div class="modal-footer"><button class="btn" data-dismiss="modal">Cancel</button></div></div></div></div>}}}

Net Core 3 Identity

$
0
0

Hey everyone. I'm new to asp net core and i need some help. I scaffolded the Identity into my  web form razor project. The database name is ProiectLicenta where i can see all the Indentity tables. Basically what i am trying to do is if anyone registers i want their usernames and emails from the AspNetUsers table listed in another page called userlist. That table on the userlist has to update everytime a new person registers. Is it posible?

One or more constructors in Home Controller - error

$
0
0

Dear all,

I am getting the following error in asp.net core project. Can somebody let me know how to overcome this error.

InvalidOperationException: Multiple constructors accepting all given argument types have been found in type 'EmployeeManagement.Controllers.HomeController'. There should only be one applicable constructor.

  • Microsoft.Extensions.DependencyInjection.ActivatorUtilities.TryFindMatchingConstructor(Type instanceType, Type[] argumentTypes, ref ConstructorInfo matchingConstructor, ref Nullable<int>[] parameterMap)

  • Microsoft.Extensions.DependencyInjection.ActivatorUtilities.FindApplicableConstructor(Type instanceType, Type[] argumentTypes, out ConstructorInfo matchingConstructor, out Nullable<int>[] parameterMap)

  • Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateFactory(Type instanceType, Type[] argumentTypes)

  • Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.CreateActivator(ControllerActionDescriptor descriptor)

  • Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.CreateControllerFactory(ControllerActionDescriptor descriptor)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCache.GetCachedResult(ControllerContext controllerContext)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider.OnProvidersExecuting(ActionInvokerProviderContext context)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ActionInvokerFactory.CreateInvoker(ActionContext actionContext)

  • Microsoft.AspNetCore.Mvc.Routing.ActionEndpointFactory+<>c__DisplayClass7_0.<CreateRequestDelegate>b__0(HttpContext context)

  • Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)

  • Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

  • Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

code in home controller

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using EmployeeManagement.Models;

namespace EmployeeManagement.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}

private readonly IEmployeeRepository _employeeRepository;

public HomeController(IEmployeeRepository employeeRepository)
{
_employeeRepository = employeeRepository;
}

/*public IActionResult Index()
{
return View();
}*/
public string Index()
{
return _employeeRepository.GetEmployee(1).Name;
}

public IActionResult Privacy()
{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

Continue Upload When Internet Connected

$
0
0

hi,
with this code i upload my file in .net core ,
i want when internet is disconnected , the upload operation is paused and
when internet is connected it continue the upload
how can i do this in javascript & .net core?

 document.getElementById('upload-video').addEventListener('change', function (event) {

       var file = event.target.files[0];
       console.log($("#upload-video").val());
       var fileReader = new FileReader();
       var extension = file.type.split("/");

           fileReader.onload = function () {
               var blob = new Blob([fileReader.result], { type: file.type });
               var url = URL.createObjectURL(blob);
               var video = document.createElement('video');
               var timeupdate = function () {
                   if (snapImage()) {
                       video.removeEventListener('timeupdate', timeupdate);
                       video.pause();
                   }
               };
               video.addEventListener('loadeddata', function () {
                   GetDuration(video.duration);


               });

               var snapImage = function () {
                   var canvas = document.createElement('canvas');

                   canvas.width = video.videoWidth;
                   canvas.height = video.videoHeight;

                   canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
                   var image = canvas.toDataURL();
                   var success = image.length > 10000;
                   var image = canvas.toDataURL();
                   if (success) {
                       var img = document.getElementById('video-image');
                       img.src = image;

                       if (document.contains(document.getElementById("upload-preview-loader"))) {
                           document.getElementById('upload-preview-loader').remove();
                       }

                       img.hidden = false;
                       document.getElementById('div-image').appendChild(img);
                       URL.revokeObjectURL(url);

                   }

                   return success;
               };
               video.addEventListener('timeupdate', timeupdate);
               video.preload = 'metadata';
               video.src = url;
               video.muted = true;
               video.playsInline = true;
               video.currentTime = 30;
               video.play();


           
               SendVideo();



           fileReader.readAsArrayBuffer(file);
       }
   });
function SendVideo() {

    var image = $("#upload-video").get(0).files;
    var aVF = new FormData();
    aVF.append("file", image[0])$.ajax({
        method: 'POST',
        url: '/Video/Upload',
        data: aVF,
        processData: false,
        contentType: false,
        xhr: function () {$("#progress-bar-video").addClass("bg-info");$("#progress-bar-video").removeClass("bg-success");
            var xhr = new window.XMLHttpRequest();
            xhr.upload.addEventListener("progress", function (evt) {
                if (evt.lengthComputable) {
                    //console.log(evt.loaded + " / " + evt.total);
                    var progress = Math.round((evt.loaded / evt.total) * 100);$(".progress-bar").css("width", progress + "%").attr("aria-valuenow", progress);$(".progress-bar").html('(' + progress + "%) در حال بارگذاری");
                }
            }, false);
            return xhr;
        },
        success: function (data) {

         //do something
            }

            //




        },
        complete: function (data) {
            //do something
        },
        error: function (result) {
        }
    });
}




Help figuring out 5 levels of @ indirection on Razor page

$
0
0

My code reads a website field from a database.  The field's values are things likewww.google.com, www.bing.com etc without the preceding http:// (orhttps://).

The MVC model returns and displays this field correctly, but I can't get it to prepend http:// and then make the entire thing clickable.

This is the code I have:

@foreach (var item in Model) {
<tr>
   <td>
   @if (item.PrimarySiteName != null)
   {
      @Html.Raw(@("http://" + @item.PrimarySite))
   }
   </td>

</tr>

}

Without the @Html.Raw, the field actually displays correctly, but this code doesn't even run.  Maybe I need to use <a href=""> to wrap the prepended string.  Depending upon how I mess with the code, sometimes the double slash is interpreted as a comment ( when I use @{ } for example ).  How can I get this link to display and be clickable?

command line resources

$
0
0

Hi

One of the main reasons i don't use visual studio code more, is because of all the command line stuff,like for creating new projects, solutions etc.

Does anyone have any good resources for command line stuff i can bookmark or print for referencing.


Can i use database first approach with entity framework inside asp.net core

$
0
0

I want to start a new asp.net core MVC web project, but i am but sure if i can follow the database first approach? by creating the database inside my sql server >> then map the database inside my application using entity framework (as we used to do in asp.net mvc-5)? Thanks

IServiceCollection does not contain a definition for AddDefaultIdentity

$
0
0

Any idea why am I getting this error?   Error Message --> "IServiceCollection does not contain a definition for AddDefaultIdentity"

public class Program
{
  public async static void Main(string[] args)
  {
    await Host.CreateDefaultBuilder(args)
    .ConfigureWebHostDefaults(webBuilder => {
      webBuilder.UseContentRoot(Directory.GetCurrentDirectory());
      webBuilder.UseKestrel();
      webBuilder.UseAzureAppServices();
      webBuilder.UseStartup<Startup>();
    })
    .Build()
    .RunAsync();
  }
}

<div>    public class Startup</div> <div>    {</div> <div>        public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment)</div> <div>        {</div> <div>            Configuration = configuration;</div> <div> </div> <div>            HostEnvironment = hostEnvironment;</div> <div> </div> <div>            //ConfigurationBuilder builder = new ConfigurationBuilder();</div> <div>           //Configuration = builder.Build();</div> <div>        }</div> <div> </div> <div>        public IConfiguration Configuration { get; }</div> <div>        protected IApplicationBuilder ApplicationBuilder { get; private set; }</div> <div>        public IHostEnvironment HostEnvironment { get; }</div> <div> </div> <div>        // This method gets called by the runtime. Use this method to add services to the container.</div><div>        public void ConfigureServices(IServiceCollection services)</div> <div>        {</div> <div>            //            services.AddRazorPages();</div> <div> </div> <div>            // This is cookie authentication service.</div> <div>            // [ Old Version #3 ]</div> <div>            //services.AddIdentity<ApplicationUser, IdentityRole<Guid>>(options => {</div> <div>            //    // [ Old version #1 ]</div> <div>            //    //options.Cookies.ApplicationCookie.LoginPath = new PathString("/Home/Index");</div> <div>            //    //options.Cookies.ApplicationCookie.SlidingExpiration = true;</div> <div>           //    //options.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromMinutes(this.Configuration.GetValue<int?>("Authentication:SlidingExpirationTime").Value);</div> <div>            //    //options.Cookies.ApplicationCookie.AccessDeniedPath = new PathString("/Home/AccessDenied");</div> <div>            //    // [ Old version #2 ]</div> <div>            //    //options.Password.RequireUppercase = false;</div> <div>            //    //options.Password.RequireLowercase = false;</div> <div>            //    //options.Password.RequireNonAlphanumeric = false;</div> <div>            //    //options.Password.RequireDigit = false;</div> <div>            //    //options.Password.RequiredLength = 7;</div> <div>            //})</div> <div>            // [ Old Version #3 ]</div> <div>            //.AddEntityFrameworkStores<ApplicationContext, Guid>()</div> <div>            //.AddDefaultTokenProviders();</div><div> </div> <div>            // [ Old Version #3 - replacement ]</div> <div>            services.AddDefaultIdentity<ApplicationUser>()  // "ApplicationUser" is named incorrectly, it should be "IdentityUser" instead, as per Microsoft documentation.</div> <div>                .AddRoles<IdentityRole<Guid>>()</div> <div>                .AddEntityFrameworkStores<ApplicationContext, Guid>()  // FYI - AddEntityFrameworkStores() deal with role that derives from IdentityRole, as per documentation.</div> <div>                                                                       //.AddDefaultUI()</div> <div>                .AddDefaultTokenProviders();</div> <div> </div><div>            // [ Old version #1 - replacement ]</div> <div>            services.ConfigureApplicationCookie(options =></div> <div>            {</div> <div>                options.LoginPath = new PathString("/Home/Index");</div><div>                options.SlidingExpiration = true;</div> <div>                options.ExpireTimeSpan = TimeSpan.FromMinutes(this.Configuration.GetValue<int?>("Authentication:SlidingExpirationTime").Value);</div> <div>               options.AccessDeniedPath = new PathString("/Home/AccessDenied");</div> <div>            });</div> <div> </div> <div>            // [ Old version #2 - replacement ]</div> <div>            services.Configure<IdentityOptions>(options =></div> <div>            {</div> <div>                options.Password.RequireUppercase = false;</div> <div>                options.Password.RequireLowercase = false;</div> <div>                options.Password.RequireNonAlphanumeric = false;</div> <div>                options.Password.RequireDigit = false;</div> <div>                options.Password.RequiredLength = 7;</div> <div>            });</div> <div> </div> <div>           services.AddMvc();</div> <div>            services.AddSession();</div> <div> </div> <div>            //services.Configure<AuthorizationOptions>(options =></div> <div>            //{</div><div>            //});</div> <div>        }</div> <div> </div> <div>        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.</div> <div>        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)</div> <div>        {</div> <div>            if (env.IsDevelopment())</div> <div>            {</div> <div>                app.UseDeveloperExceptionPage();</div><div>            }</div> <div>            else</div> <div>            {</div> <div>                app.UseExceptionHandler("/Error");</div> <div>                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.</div> <div>                app.UseHsts();</div> <div>            }</div> <div> </div> <div>            app.UseHttpsRedirection();</div><div>            app.UseStaticFiles();</div> <div>            app.UseRouting();</div> <div>            app.UseAuthorization();</div> <div> </div> <div>            app.UseEndpoints(endpoints =></div><div>            {</div> <div>                endpoints.MapRazorPages();</div> <div>            });</div> <div> </div> <div>            // Config Exception.</div> <div>            if (env.IsDevelopment())</div><div>                app.UseDeveloperExceptionPage();</div> <div>            else</div> <div>                app.UseExceptionHandler("/Home/ErrorPage.html");</div> <div> </div> <div>            app.UseStaticFiles(); // Note, we are not authenticating for static files if this is before them</div> <div>            app.UseSession();</div> <div>            app.UseAuthentication();</div> <div> </div> <div>            // MVC.</div><div>            //app.UseMvc(routes => routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"));</div> <div>        }</div> <div>    }</div> <div>}</div> <div></div> <div> <div> </div><div> <div>public class ApplicationUser : IdentityUser<Guid>, IUser</div> <div>{</div> <div>}</div> <div>public interface IUser</div> <div>{</div> <div>}</div> <div> </div><div>public class ApplicationContext : IdentityDbContext<ApplicationUser, IdentityRole<Guid>, Guid></div> <div>{</div> <div>    public ApplicationContext(DbContextOptions<ApplicationContext> options)</div> <div>       : base(options)</div> <div>    {</div> <div>    }</div> <div> </div> <div>    protected override void OnModelCreating(ModelBuilder builder)</div> <div>    {</div> <div>       base.OnModelCreating(builder);</div> <div>    }</div> <div>}</div> <div></div> <div></div> <div> <div><Project Sdk="Microsoft.NET.Sdk.Web"></div> <div> </div> <div> <PropertyGroup></div> <div>    <TargetFramework>netcoreapp3.1</TargetFramework></div> <div>  </PropertyGroup></div> <div> </div> <div>  <ItemGroup></div> <div>    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="3.1.3" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="1.0.2" /></div><div>    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.2" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="1.1.3" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" /></div> <div>    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.3" /></div> <div>    <PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.1.3" /></div> <div>    <PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" /></div><div>    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.3" /></div> <div> </div> <div>    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" /></div> <div>   <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.3" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /></div> <div>    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" /></div> <div> </div><div>    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="1.1.3" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" /></div> <div>   <PackageReference Include="Newtonsoft.Json" Version="12.0.2" /></div> <div>    <PackageReference Include="Microsoft.AspNetCore.AzureAppServicesIntegration" Version="1.0.2" /></div> <div>  </ItemGroup></div> <div> </div><div></Project></div> </div> </div> <div></div> </div>

Model navigation property returns null value in my asp.net core project.

$
0
0

Hi

I have some entities like Patients with some relations to another entities. My problem is that, in Details view, the navigation properties (which points to other tables) does not display anything! apparently it returns null.

after a lot of search, some people says i should change some configation options in my dbContext (see this link), but i could not find Configuration property!

some people says Lazy loading is not supported by ef core, i should include it manually in my linq query (see this link), but also i could not find Include in my dbContext!!

Here is my Patients class :

public partial class Patients
{
        [Key]
        public Guid PatientRowID { get; set; }
        [Required]
        [StringLength(50)]
        public string PatientCaseID { get; set; }
        [StringLength(50)]
        public string PatientFname { get; set; }
        [StringLength(50)]
        public string PatientLname { get; set; }
	public int? SexID { get; set; }
	[ForeignKey(nameof(SexID))]
        [InverseProperty("Patients")]
        public virtual Sex Sex { get; set; }
}

And here is my another table (Sex) :

public partial class Sex
{
        public Sex()
        {
            Patients = new HashSet<Patients>();
            Persons = new HashSet<Persons>();
        }

        [Key]
        public int SexID { get; set; }
        [StringLength(50)]
        public string SexName { get; set; }

        [InverseProperty("Sex")]
        public virtual ICollection<Patients> Patients { get; set; }
        [InverseProperty("Sex")]
        public virtual ICollection<Persons> Persons { get; set; }
}

And here is my action method :

public IActionResult Details(string id)
        {
            if (string.IsNullOrEmpty(id))
                return BadRequest();

            Guid gid = Guid.Parse(id);
            var patient = _dbContext.Patients.Where(p => p.PatientRowID == gid).FirstOrDefault();
            if (patient == null)
                return NotFound();

            return View(patient);
        }

And here is my Details view code :

<div><dl class="row"><dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.PatientCaseID)</dt><dd class = "col-sm-10">
            @Html.DisplayFor(model => model.PatientCaseID)</dd><dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.PatientFname)</dt><dd class = "col-sm-10">
            @Html.DisplayFor(model => model.PatientFname)</dd><dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.PatientLname)</dt><dd class = "col-sm-10">
            @Html.DisplayFor(model => model.PatientLname)</dd><dt class = "col-sm-2">
            @Html.DisplayNameFor(model => model.SexID)</dt><dd class = "col-sm-10">
            @Html.DisplayFor(model => model.Sex.SexName) // display nothing!</dd></dl></div>

Can anybody help me where is my problem & how to solve it?

Thanks in advance

I Have problem in ICollection ASP CORE

$
0
0

Good morning, I have a question about something I am trying to develop, the project is in ASP CORE 3.1 MVC. I have 2 identities one to one and the other (which is the one with problems) from one to many. What happens is that I am adding a company (Company Model) and those responsible for this company (Company Responsable Model) which are the following:

publicpartialclassEmpresa{publicintEmpresaId{get;set;}publicstringNombreEmpresa{get;set;}publicstringNumeroDistribuidor{get;set;}publicstringUbicacion{get;set;}publicstringRazonSocial{get;set;}publicstringDomicilio{get;set;}publicstringTelefono{get;set;}publicstringCorreo{get;set;}publicintCantidadEmpleados{get;set;}publicstringFechaAlta{get;set;}publicstringHoraAlta{get;set;}publicstringFechaModificacion{get;set;}publicstringHoraModificacion{get;set;}publicstringUsuarioAlta{get;set;}publicstringUsuarioModificacion{get;set;}publicbool?Estado{get;set;}publicvirtualNaturalezaEmpresaNaturalezaEmpresa{get;set;}publicICollection<ResponsableEmpresa>ResponsableEmpresas{get;set;}}}

Model ResponsableEmpresa:

publicintResponsableEmpresaId{get;set;}publicstringPuesto{get;set;}publicstringNombre{get;set;}publicstringApellidoMaterno{get;set;}publicstringApellidoPaterno{get;set;}publicstringCorreo{get;set;}publicstringTelefono{get;set;}[ForeignKey("Empresa")]publicintEmpresaId{get;set;}publicvirtualEmpresaEmpresa{get;set;}

Now, what I try is that in the view I can add the data of the company and separate those responsible, which would be the following view:

@modelEmpresa<h1 class="text-center">Datos generales de la empresa o grupo</h1><form asp-action="Guardar" asp-controller="Empresa" method="post"><div class="form-group col"><label>Nombre de la empresa:</label><input type="text" asp-for="NombreEmpresa"class="form-control"/><span asp-validation-for="NombreEmpresa"class="text-danger"></span></div><div class="form-group col"><label>Número de distribuidor:</label><input type="text" asp-for="NumeroDistribuidor"class="form-control"/><span asp-validation-for="NumeroDistribuidor"class="text-danger"></span></div><div class="form-group col"><label>Ubicación:</label><input type="text" asp-for="Ubicacion"class="form-control"/><span asp-validation-for="Ubicacion"class="text-danger"></span></div><div class="form-group col"><label>Razón Social:</label><input type="text" asp-for="RazonSocial"class="form-control"/><span asp-validation-for="RazonSocial"class="text-danger"></span></div><div class="form-group col"><label>Domicilio:</label><input type="text" asp-for="Domicilio"class="form-control"/><span asp-validation-for="Domicilio"class="text-danger"></span></div><div class="form-group col"><label>Telefono:</label><input type="tel" asp-for="Telefono"class="form-control"/><span asp-validation-for="Telefono"class="text-danger"></span></div><div class="form-group col"><label>Correo:</label><input type="email" asp-for="Correo"class="form-control"/><span asp-validation-for="Correo"class="text-danger"></span></div><div class="form-group col"><label>Cantidad de empleados:</label><input type="number" asp-for="CantidadEmpleados"class="form-control"/><span asp-validation-for="CantidadEmpleados"class="text-danger"></span></div><div class="form-group col"><label>Cantidad de empleados:</label><input asp-for="ResponsableEmpresas.Add(@responsableEmpresa)"class="form-control"/></div>@*<h1 class="text-center">ResponsableEmpresa</h1><p><br /><br /></p><table id="myTable"class="table table-bordered text-center"><thead><tr><td scop="col">Puesto</td><td scop="col">Nombre</td><td scop="col">ApellidoMaterno</td><td scop="col">ApellidoPaterno</td><td scop="col">Correo</td><td scop="col">Telefono</td></tr></thead><tbody><tr></tr></tbody></table><br><script>function myFunction(){var table = document.getElementById("myTable");
                table.contentEditable =true;var row = table.insertRow(2);var cell1 = row.insertCell(0);var cell2 = row.insertCell(1);var cell3 = row.insertCell(2);var cell4 = row.insertCell(3);var cell5 = row.insertCell(4);var cell6 = row.insertCell(5);
                cell1.innerHTML ="Ingresar Puesto";
                cell2.innerHTML ="Ingresar Nombre";
                cell3.innerHTML ="Ingresar Apellido Materno";
                cell4.innerHTML ="Ingresar Apellido Paterno";
                cell5.innerHTML ="Ingresar Correo ";
                cell6.innerHTML ="Ingresar Teléfono";}function myDeleteFunction(){
                document.getElementById("myTable").deleteRow(2);}function showTableData(){//gets tablevar oTable = document.getElementById('myTable');//gets rows of tablevar rowLength = oTable.rows.length;//loops through rowsfor(i =0; i < rowLength; i++){//gets cells of current rowvar oCells = oTable.rows.item(i).cells;//gets amount of cells of current rowvar cellLength = oCells.length;//loops through each cell in current rowfor(var j =0; j < cellLength; j++){// get your cell info herevar cellVal = oCells.item(j).innerHTML;if(cellVal.toString()!="Puesto"&& cellVal.toString()!="Nombre"&& cellVal.toString()!="Nombre"&& cellVal.toString()!="Apellido Materno"&& cellVal.toString()!="Apellido Paterno"&& cellVal.toString()!="Correo"&& cellVal.toString()!="Telefono"){
                            alert(cellVal);}}}}</script>*@<div class="row float-right" style="margin: 10px 5px 5px 5px"><a><input type="button" onclick="myFunction()"class="btn btn-info float-right"value="Insertar"/></a></div><div class="row float-right" style="margin: 10px 5px 5px 5px"><a><input type="button" onclick="myDeleteFunction()"class="btn btn-danger float-right"value="Borrar"/></a></div><div class="row float-right" style="margin: 10px 5px 5px 5px"><a><input type="button" onclick="showTableData()"class="btn btn-danger float-right"value="Leer"/></a></div><div class="row"><button type="submit"class="btn btn-primary float-right">Guardar</button></div></form>

The idea is that a number of managers can be added, but I cannot find a way to add it that when returning to the controller brings the information of Company Responsible .

Basically the idea is to pass an array from the view to the controller, but I have the problem handling the ICollection

Thanks a lot!

Sort title by alphabetical order

$
0
0

I'm not sure where to sort the title at, would that be at the view level or in the repository?

i tried setting it in the repository but that doesn't seem to work

 public IEnumerable<DocumentEntity> FindPoliciesDocuments()
        {
            return DbContext
                .Set<DocEntity>()
                .Include(d => d.EgendaFile)
                .Where(d => d.EgendaDocumentTypeEntity.Id == (int)EgendaDocumentType.Policies)
                .Where(d => d.IsDeleted == false || d.IsDeleted == null).AsEnumerable()
                .OrderByDescending(d => d.Title);
        }

View which sorts the date but not the title which is what I want it to sort by.

<div class="tab-container"><table id="documentsTable_@Model.Source"
               class="table table-striped table-bordered display responsive nowrap" style="width: 100%"><thead><tr>
                    @{
                        if (!@Model.IsUserView)
                        {<th class="all">Action</th>
                        }
                        else
                        {<th class="all th-hide-column"></th>
                        }
                    }<th class="all">Title</th><th class="all">Date</th></tr></thead><tbody>
                @foreach (var document in Model.Documents)
                {<tr id="row_@document.Id">
                    @{
                        if (!@Model.IsUserView)
                        {<td><a data-toggle="modal" data-id=@document.Id
                                   data-documentType="@Model.Source"
                                   data-target="#delete-document-modal"
                                   class="btn btn-danger delete-document"><i class="fa fa-trash fa-fw"
                                       title="Delete" style="color: white"></i></a><a asp-controller="Document"
                                   asp-action="EditDocument"
                                   asp-route-id="@document.Id"
                                   asp-route-documentType="@Model.Source"
                                   class="btn btn-info"><i class="fa fa-pencil fa-fw"
                                       title="Edit"
                                       style="color: white"></i></a><a id="view-packet-item-file"
                                   class="btn btn-secondary"
                                   target="_blank"
                                   asp-area=""
                                   asp-controller="File"
                                   asp-action="Download"
                                   asp-route-documentId="@document.Id"
                                   asp-route-source="@Model.Source"><i class="fa fa-file-pdf-o fa-fw" aria-hidden="true" title="View" style="color: black"></i></a></td><td>@document.Title</td>
                        }
                        else
                        {<td class="td-hide-column"></td><td>
                                @{

                                    if (@document.EgendaFile == null)
                                    { }
                                }
                                <a id="view-packet-item-file"
                                   asp-area=""
                                   asp-controller="File"
                                   asp-action="DownloadFile"
                                   asp-route-fileId="@document.EgendaFile?.Id"
                                   target="_blank">
                                    @document.Title</a></td>
                        }
                    }
                    @{
                        var sortingDate = DateTime.MaxValue.ToLongDateString();
                        if (document.Date != null)
                        {
                            sortingDate = ((DateTime) document.Date).ToString("yyyyMMdd");
                        }<td data-order="@sortingDate">@document.Date.ToString("d")</td>
                    }</tr>
                }</tbody></table></div>

I Have problem in ICollection ASP CORE

$
0
0

Good morning, I have a question about something I am trying to develop, the project is in ASP CORE 3.1 MVC. I have 2 identities one to one and the other (which is the one with problems) from one to many. What happens is that I am adding a company (Company Model) and those responsible for this company (Company Responsable Model) which are the following:

publicpartialclassEmpresa{publicintEmpresaId{get;set;}publicstringNombreEmpresa{get;set;}publicstringNumeroDistribuidor{get;set;}publicstringUbicacion{get;set;}publicstringRazonSocial{get;set;}publicstringDomicilio{get;set;}publicstringTelefono{get;set;}publicstringCorreo{get;set;}publicintCantidadEmpleados{get;set;}publicstringFechaAlta{get;set;}publicstringHoraAlta{get;set;}publicstringFechaModificacion{get;set;}publicstringHoraModificacion{get;set;}publicstringUsuarioAlta{get;set;}publicstringUsuarioModificacion{get;set;}publicbool?Estado{get;set;}publicvirtualNaturalezaEmpresaNaturalezaEmpresa{get;set;}publicICollection<ResponsableEmpresa>ResponsableEmpresas{get;set;}}}

Model ResponsableEmpresa:

publicintResponsableEmpresaId{get;set;}publicstringPuesto{get;set;}publicstringNombre{get;set;}publicstringApellidoMaterno{get;set;}publicstringApellidoPaterno{get;set;}publicstringCorreo{get;set;}publicstringTelefono{get;set;}[ForeignKey("Empresa")]publicintEmpresaId{get;set;}publicvirtualEmpresaEmpresa{get;set;}

Now, what I try is that in the view I can add the data of the company and separate those responsible, which would be the following view:

@modelEmpresa<h1 class="text-center">Datos generales de la empresa o grupo</h1><form asp-action="Guardar" asp-controller="Empresa" method="post"><div class="form-group col"><label>Nombre de la empresa:</label><input type="text" asp-for="NombreEmpresa"class="form-control"/><span asp-validation-for="NombreEmpresa"class="text-danger"></span></div><div class="form-group col"><label>Número de distribuidor:</label><input type="text" asp-for="NumeroDistribuidor"class="form-control"/><span asp-validation-for="NumeroDistribuidor"class="text-danger"></span></div><div class="form-group col"><label>Ubicación:</label><input type="text" asp-for="Ubicacion"class="form-control"/><span asp-validation-for="Ubicacion"class="text-danger"></span></div><div class="form-group col"><label>Razón Social:</label><input type="text" asp-for="RazonSocial"class="form-control"/><span asp-validation-for="RazonSocial"class="text-danger"></span></div><div class="form-group col"><label>Domicilio:</label><input type="text" asp-for="Domicilio"class="form-control"/><span asp-validation-for="Domicilio"class="text-danger"></span></div><div class="form-group col"><label>Telefono:</label><input type="tel" asp-for="Telefono"class="form-control"/><span asp-validation-for="Telefono"class="text-danger"></span></div><div class="form-group col"><label>Correo:</label><input type="email" asp-for="Correo"class="form-control"/><span asp-validation-for="Correo"class="text-danger"></span></div><div class="form-group col"><label>Cantidad de empleados:</label><input type="number" asp-for="CantidadEmpleados"class="form-control"/><span asp-validation-for="CantidadEmpleados"class="text-danger"></span></div><div class="form-group col"><label>Cantidad de empleados:</label><input asp-for="ResponsableEmpresas.Add(@responsableEmpresa)"class="form-control"/></div>@*<h1 class="text-center">ResponsableEmpresa</h1><p><br /><br /></p><table id="myTable"class="table table-bordered text-center"><thead><tr><td scop="col">Puesto</td><td scop="col">Nombre</td><td scop="col">ApellidoMaterno</td><td scop="col">ApellidoPaterno</td><td scop="col">Correo</td><td scop="col">Telefono</td></tr></thead><tbody><tr></tr></tbody></table><br><script>function myFunction(){var table = document.getElementById("myTable");
                table.contentEditable =true;var row = table.insertRow(2);var cell1 = row.insertCell(0);var cell2 = row.insertCell(1);var cell3 = row.insertCell(2);var cell4 = row.insertCell(3);var cell5 = row.insertCell(4);var cell6 = row.insertCell(5);
                cell1.innerHTML ="Ingresar Puesto";
                cell2.innerHTML ="Ingresar Nombre";
                cell3.innerHTML ="Ingresar Apellido Materno";
                cell4.innerHTML ="Ingresar Apellido Paterno";
                cell5.innerHTML ="Ingresar Correo ";
                cell6.innerHTML ="Ingresar Teléfono";}function myDeleteFunction(){
                document.getElementById("myTable").deleteRow(2);}function showTableData(){//gets tablevar oTable = document.getElementById('myTable');//gets rows of tablevar rowLength = oTable.rows.length;//loops through rowsfor(i =0; i < rowLength; i++){//gets cells of current rowvar oCells = oTable.rows.item(i).cells;//gets amount of cells of current rowvar cellLength = oCells.length;//loops through each cell in current rowfor(var j =0; j < cellLength; j++){// get your cell info herevar cellVal = oCells.item(j).innerHTML;if(cellVal.toString()!="Puesto"&& cellVal.toString()!="Nombre"&& cellVal.toString()!="Nombre"&& cellVal.toString()!="Apellido Materno"&& cellVal.toString()!="Apellido Paterno"&& cellVal.toString()!="Correo"&& cellVal.toString()!="Telefono"){
                            alert(cellVal);}}}}</script>*@<div class="row float-right" style="margin: 10px 5px 5px 5px"><a><input type="button" onclick="myFunction()"class="btn btn-info float-right"value="Insertar"/></a></div><div class="row float-right" style="margin: 10px 5px 5px 5px"><a><input type="button" onclick="myDeleteFunction()"class="btn btn-danger float-right"value="Borrar"/></a></div><div class="row float-right" style="margin: 10px 5px 5px 5px"><a><input type="button" onclick="showTableData()"class="btn btn-danger float-right"value="Leer"/></a></div><div class="row"><button type="submit"class="btn btn-primary float-right">Guardar</button></div></form>

The idea is that a number of managers can be added, but I cannot find a way to add it that when returning to the controller brings the information of Company Responsible .

Basically the idea is to pass an array from the view to the controller, but I have the problem handling the ICollection

Thanks a lot!

Issue in Connected Service with Service dll


AutoMapper.AutoMapperMappingException: 'Error mapping types.'

$
0
0

When I am mapping using mapper  between the model the error is being showed AutoMapper.AutoMapperMappingException: 'Error mapping types.'

I have the following model

  public class Country
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        [Required]
        [MaxLength(50, ErrorMessage = "Country must be up to 50 characters in length")]
        public string CountryName { get; set; }
       public  ICollection<Author> Authors { get; set; }
    }


 public class CountryDto
    {
        public int Id { get; set; }
        public string CountryName { get; set; }
        public  ICollection<AuthorDto> Authors { get; set; }
    }

public class Author
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Required]
        [MaxLength(100, ErrorMessage ="First Name cannot be more than 100 characters")]
        public string FirstName { get; set; }

        [Required]
        [MaxLength(200, ErrorMessage = "Last Name cannot be more than 200 characters")]
        public string LastName { get; set; }
        public  Country Country { get; set; }
        [NotMapped]
        public  ICollection<BookAuthor> BookAuthors { get; set; }
    }

    public class AuthorDto
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

startup.cs
public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<BookStoreDbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddControllers();
            services.AddScoped<ICountryRepository, CountryRepository>();           
            services.AddAutoMapper(typeof(Mapping));
        }

API Controller
 public IActionResult GetCountries()
        {
            var objList = _countryRepository.GetCountries();
            var mappedEntities = _mapper.Map<CountryDto[]>(objList);

            

            if (!ModelState.IsValid)
                return BadRequest(ModelState);

           

            return Ok(mappedEntities);
        }

Repository class

 public Country[] GetCountries()
        {
           // return _db.Countries.Include(a=> a.Authors).OrderBy(c => c.CountryName).ToList();
            IQueryable<Country> query = _db.Countries
                                   .Include(a => a.Authors);

            

            return  query.ToArray();
        }

Mapping.cs

 public class Mapping : Profile
    {
        public Mapping()
        {
            CreateMap<Country, CountryDto>()
                .ReverseMap()
                 .ForMember(a => a.Authors, a => a.Ignore()); 
        }
    }

When I map   the error is coming is as follows

AutoMapper.AutoMapperMappingException: 'Error mapping types.'

Azure Keyvault fails to initialize under Kali Linux

$
0
0

Hi devs,

A week ago I decided to make the switch, I made Windows my secondary OS, and Linux - the main one. I love Linux, but I am experiencing an issue. I started learning ASP.NET Core maybe like half an year ago. I created a small forum app with Visual Studio on ASP NET Core 3.1. It also uses azure key vault. It worked perfectly under Windows, but under Linux it doesn't work as expected.

Summary of the problem I am having:

When I try to connect to Azure key vault under Windows it works, because of VS, but under Linux it doesn't. It throws exception, that it couldn't get a token. I am familiar that under Linux it uses Azure CLI(I have it installed and I am logged in). The shell command for getting a vault token also works. But when i run my code with dotnet run it just doesn't work. For IDE I am using Rider, but that's not important.

Error I am receiving:

Unhandled exception. Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException: Parameters: Connection String: RunAs=App;, Resource: https://vault.azure.net, Authority: https://login.windows.net/4a06d40c-e447-42be-baef-dd0421ed10bd. Exception Message: Tried to get token using Managed Service Identity. Unable to connect to the Managed Service Identity (MSI) endpoint. Please check that you are running on an Azure resource that has MSI setup.
at Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProvider.GetAuthResultAsyncImpl(String resource, String authority, CancellationToken cancellationToken)
at Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProvider.<get_KeyVaultTokenCallback>b__8_0(String authority, String resource, String scope)
at Microsoft.Azure.KeyVault.KeyVaultCredential.PostAuthenticate(HttpResponseMessage response)
at Microsoft.Azure.KeyVault.KeyVaultCredential.ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.KeyVault.KeyVaultClient.GetSecretsWithHttpMessagesAsync(String vaultBaseUrl, Nullable`1 maxresults, Dictionary`2 customHeaders, CancellationToken cancellationToken)
at Microsoft.Azure.KeyVault.KeyVaultClientExtensions.GetSecretsAsync(IKeyVaultClient operations, String vaultBaseUrl, Nullable`1 maxresults, CancellationToken cancellationToken)
at Microsoft.Extensions.Configuration.AzureKeyVault.AzureKeyVaultConfigurationProvider.LoadAsync()
at Microsoft.Extensions.Configuration.AzureKeyVault.AzureKeyVaultConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at ForumSystem.Web.Program.Main(String[] args) in /home/bruteforce/RiderProjects/ForumSystem-Web/src/Web/ForumSystem.Web/Program.cs:line 16

Process finished with exit code 6.

My code:

namespace ForumSystem.Web
{
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Azure.KeyVault;
    using Microsoft.Azure.Services.AppAuthentication;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.Configuration.AzureKeyVault;
    using Microsoft.Extensions.Hosting;

    public static class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureAppConfiguration(
                (ctx, builder) =>
            {
                var keyVaultEndpoint = GetKeyVaultEndpoint();
                if (!string.IsNullOrEmpty(keyVaultEndpoint))
                {
                    var azureServiceTokenProvider = new AzureServiceTokenProvider("RunAs=App;");
                    var keyVaultClient = new KeyVaultClient(
                        new KeyVaultClient.AuthenticationCallback(
                            azureServiceTokenProvider.KeyVaultTokenCallback));
                    builder.AddAzureKeyVault(
                    keyVaultEndpoint, keyVaultClient, new DefaultKeyVaultSecretManager());
                }
            })
                .ConfigureWebHostDefaults(
                    webBuilder =>
                    {
                        webBuilder.UseStartup<Startup>();
                    });

        private static string GetKeyVaultEndpoint() => "https://myKeyVault.vault.azure.net/";
    }
}


The code I am using is copy pasted from docs and I added the RunAs=App connection string.

What I tried:

I assured that the Azure CLI is installed, logged into the account and that I am running the latest stable version of the CLI and .NET Core 3.1. I tried reinstalling Linux. Also I tried running the code with and without the connection string in the AzureServiceTokenPorvider. I just recieve a similar error in which I am told that it tried the 3 different ways and on the third(Azure CLI) it just says that the token couldn't be acquired. Of course I also tried reinstalling .NET Core and Azure CLI several times with no success.

I will be happy to provide any additional info if needed :)

How do I query a database only once?

$
0
0

I have a drop down that's populated from a database table and its corresponding model. Works great!

However, every time I return to the controller, I have to read the table again.  This seems inefficient at best.  I tried to overcome this by creating a static object, but every time a View is rendered, the object is disposed and an error is thrown by the controller.  How do I overcome this?

Here is my failed code:

// List of bagtypes. Only want to get these once
public static DbSet<Bagtypes> bagtypes {get; set;} = null;

... Other Controller code

[HttpGet]
public async Task<IActionResult> Edit(int? id, bool? copy)
{

// other edit stuff here


if (bagtypes == null) // Only do this the first time through...

{

bagtypes = _db.Types;

}

bvm.TypeOfBag = bagtypes;

return View(bvm);

}

Dynamic LINQ in Asp Core 3.1

$
0
0

Hi all,

I'm trying to implement dynamic OrderBy using Dynamic LINQ in an Asp Core 3.1 project, here's what I have:

orderedList = filters.SortDirection.ToLower(CultureInfo.CurrentCulture) == "asc"
                    ? orderedList.OrderBy(filters.SortBy).ToList()
                    : orderedList.OrderByDescending(filters.SortBy).ToList();

I note that on the Nuget page (https://www.nuget.org/packages/System.Linq.Dynamic.Core/) it specifies Asp Core 2.1, does anyone know if this can or cannot be used in 3.1 and if not is there an alternative way of achieving this in 3.1?

ASP.NET CORE VS 2019 NuGet "jquery.UI.Combined" where are the files?

$
0
0

ASP.NET CORE VS 2019 NuGet "jquery.UI.Combined" where are the files?

I installed the NuGet jquery.UI.Combined but nothing appears in the wwwroot. I also Added jquery ui with the "Add Client Side Library" tool in VS and it added this to my libman.json:
,
{
"library": "jqueryui@1.12.1",
"destination": "wwwroot/lib/jqueryui/"
}

But there is no jqueryui folder in the lib folder.

Thanks! (Confused in the Enterprise)
Matt

Viewing all 9386 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>