-1
Let’s assume that I want to register an item in my database.knowing my item name and price. But I also want when registering the item should also register the date.How do I do this? I’m still new to Asp.net Mvc
MODEL
public class TABLE
{
[Key]
public int IdApp { get; set; }
public string AppName { get; set; }
public DateTime Data { get; set; }
public int Size { get; set; }
public double Price { get; set; }
public byte[] FotoByte { get; set; }
[NotMapped]
[Required(ErrorMessage = "O Campo da foto está Vazio")]
public HttpPostedFileBase foto { get; set; }
}
VIEW
@model Store.Models.CadastroApp.TABLE
@{
ViewBag.Title = "RecordApp";
}
<link href="~/Content/css/RecordApp/index.css" rel="stylesheet" />
<div class="container">
<div class="container">
<div class="jumbotron">
<h2>App Register</h2><br />
<div class="">
@Html.TextBoxFor(x=>x.AppName, new {@class="form-control",@placeholder="informa o nome do App" })<br />
@Html.TextBoxFor(x=>x.Price,new { @class = "form-control",@placeholder="informa o preço"})<br />
@Html.TextBoxFor(x => x.foto, new { type = "file" })
@Html.ValidationMessageFor(x => x.foto)
</div>
</div>
</div>
</div>
Yes I want it to register me right to date at the time of registration. The way you explained is kind of spindle,because in the case I’m using Entity.
– Gladiador
Then in this case, in the Actionresult that will perform the registration you assign TABLE. Data = = Datetime.Now; before executing the save method.
– Alexsandro Souza
Thanks @Alexsandro.was helpful in your reply
– Gladiador