asp.net-mvc

How do I merge two seperate '.ToList()"?

こ雲淡風輕ζ 提交于 2021-02-11 13:40:59
问题 There are several posts where people are asking how to merge generic lists. However, in my case I have two seperate linq statements where I am returning two separate database results .ToList() var appleList = (from al in db.Apples where al.Id == id select al).ToList(); var bananaList = (from bl in db.Bananas where bl.Id == id select bl).ToList(); I tried merging these list like so: appleList.Concat(bananaList); but this causes the following error: 'List' does not contain a definition for

How to convert formcollection to model ins ASP.NET MVC

一个人想着一个人 提交于 2021-02-11 13:32:08
问题 I have a model class called ClientPackage and in my controller action method i receive a FormCollection from an ajax post call that i would like to convert it to the model class ClientPackage. public class ClientPackage { public int DemandeId { get; set; } public string NumeroRequette { get; set; } public string NumeroModification { get; set; } public int CasId { get; set; } public string NumeroDossier { get; set; } public string NomPatient { get; set; } public string PrenomPatient { get; set

How to convert formcollection to model ins ASP.NET MVC

吃可爱长大的小学妹 提交于 2021-02-11 13:30:50
问题 I have a model class called ClientPackage and in my controller action method i receive a FormCollection from an ajax post call that i would like to convert it to the model class ClientPackage. public class ClientPackage { public int DemandeId { get; set; } public string NumeroRequette { get; set; } public string NumeroModification { get; set; } public int CasId { get; set; } public string NumeroDossier { get; set; } public string NomPatient { get; set; } public string PrenomPatient { get; set

jqGrid Lose data on submit

前提是你 提交于 2021-02-11 13:26:49
问题 I'm working on a CRUD application in ASP.net C #. My problem is that when I click the Submit button and ModelState.IsValid = false, the data in the grid is lost. Does anyone know how to fix this? I have a form in html and razor, I could not leave all the work to an ajax request, so what I did was add the onsubmit event to the form with the function "sendingContacts", This function gets the grid information in a JSON string and then I assign it in a hidden field in the form, so my controller

Populate DropDownListFor: HtmlHelper does not contain a definition for 'DropDownListFor'

≡放荡痞女 提交于 2021-02-11 12:36:11
问题 I have an ever-changing list of Industries that I'd like a user to select from when creating a new Survey. I could accomplish this with either a ViewModel or ViewBag (I think). I'm attempting to do it with ViewBag. Getting the DropDownListFor error: CS1928 HtmlHelper<Survey> does not contain a definition for DropDownListFor and the best extension method overload SelectExtensions.DropDownListFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, IEnumerable

Retrieve a string from database and compare with date

与世无争的帅哥 提交于 2021-02-11 12:05:17
问题 I have a field in database stored as string and i need to convert it back to datetime and then compare if it equals to date. Below is the current implementation I have presently. var date = DateTime.UtcNow ; var zone = TimeZoneInfo.FindSystemTimeZoneById("W. Central Africa Standard Time"); DateTime currentTime = TimeZoneInfo.ConvertTimeFromUtc(date, zone); var loanDate = currentTime.Date.ToString("dd/MM/yyyy").Replace("-", "/"); if (DateTime.ParseExact(firstRepay, "dd/MM/yyyy", CultureInfo

Asp.net mvc compiler error when trying to invoke View Component from view page

让人想犯罪 __ 提交于 2021-02-11 12:03:17
问题 I am trying to create my first View Component in my MVC project but have come to a halt. When I try to invoke my View Component from the razor view page I get an error that states: "The name 'await' does not exist in the current context". Code I use to call the View Component: @await Component.InvokeAsync("Example") View Component class: namespace MyWebApp.ViewComponents { public class ExampleViewComponent : ViewComponent { public IViewComponentResult Invoke() { var user = Account.GetCurrent(

Using Azure B2C with MVC, .NET Core 3.1

馋奶兔 提交于 2021-02-11 09:10:19
问题 Could anyone provide some insight or new links on using Azure B2C with MVC, .NET Core 3.1. Most examples are based on Core 2.2 https://docs.microsoft.com/en-us/samples/azure-samples/active-directory-b2c-dotnetcore-webapp/an-aspnet-core-web-app-with-azure-ad-b2c/ However, it seems more than a few things are done differently with 3.1. The error I encounter in 2.2 is: System.ArgumentNullException: Value cannot be null. (Parameter 'uriString') at System.Uri..ctor(String uriString) at Microsoft

Using Azure B2C with MVC, .NET Core 3.1

岁酱吖の 提交于 2021-02-11 09:07:42
问题 Could anyone provide some insight or new links on using Azure B2C with MVC, .NET Core 3.1. Most examples are based on Core 2.2 https://docs.microsoft.com/en-us/samples/azure-samples/active-directory-b2c-dotnetcore-webapp/an-aspnet-core-web-app-with-azure-ad-b2c/ However, it seems more than a few things are done differently with 3.1. The error I encounter in 2.2 is: System.ArgumentNullException: Value cannot be null. (Parameter 'uriString') at System.Uri..ctor(String uriString) at Microsoft

Using Azure B2C with MVC, .NET Core 3.1

試著忘記壹切 提交于 2021-02-11 09:06:28
问题 Could anyone provide some insight or new links on using Azure B2C with MVC, .NET Core 3.1. Most examples are based on Core 2.2 https://docs.microsoft.com/en-us/samples/azure-samples/active-directory-b2c-dotnetcore-webapp/an-aspnet-core-web-app-with-azure-ad-b2c/ However, it seems more than a few things are done differently with 3.1. The error I encounter in 2.2 is: System.ArgumentNullException: Value cannot be null. (Parameter 'uriString') at System.Uri..ctor(String uriString) at Microsoft