I am a new developer and I am running into a problem where I want to assign an existing integer (on the domain) a value that is coming in from a user input from the web. How do I do this? Below is the code from my App solution.
Current error message: Cannot implicitly convert type 'int' to 'AppDomain.MainFrame.Entities'
model snippet: (WebFrame.cs)
namespace AppWeb.Models
{ public class WebFrame { ... public int Urgency {get; set;} ... } }
contoller snippet: (WebFrameController.cs) - WHERE I NEED HELP. I tried a few different thing but all resulted in the same error.
namespace AppWeb.Controllers
{
public class WebFrameController : Controller
{
...
[HttpPost]
public ActionResult Index(HttpP开发者_高级运维ostedFileBase FileIn, WebFrame webFrameWork)
{
...
if (webFrame.Urgency != 0)
{
//>>> *** THIS IS WHERE I NEED HELP, I'VE TRIED A FEW THINGS TO NO AVAIL, INCLUDING HARDCODING NEEDDONEINDAYS =1*** <<<
//TODO:Assign Urgency from MVC Web App user input to Need Done In Days Value (= NeedDoneInDays) in Domain
Entities NeedDoneInDays = new Entities();
NeedDoneInDays = webFrame.Urgency;
//NeedDoneInDays = 1;
//NeedDoneInDays = Urgency;
}
.... does some processing to get to Log if necessary.
}
...
}
}
Page that has functions that will accept the Urgency Value.
AppDomain.MainFrame.Entities.Reporting.cs.
namespace AppDomain.MainFrame.Entities
{
public class Reporting
{
public static void LogToMainLogAndProcess(System.Web.HttpRequest hReq, System.DateTime StartTime, string projectType, int NeedDoneInDays)
{
//does some processing... logging and storing...
}
public static void LogAndReport(System.Web.HttpRequest hReq, string Department, System.DateTime StartTime, string projectType, int NeedDoneInDays)
{
//does some processing... logging and storing...
}
}
}
Thanks in advance for your help!
You are trying to assign an integer value webFrame.urgency to an object of type Entities, this doesn't make sense, hence the error. Is it that the Entities object has a property for urgency which is an integer ?
精彩评论