How to Register a date in my Database using ASP.NET MVC [closed]

-1

Let's suppose I want to register an item in my database. Knowing my item name and price. But I want to also when registering the item should also register the date. How do I do this? I am 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>
    
asked by anonymous 19.07.2017 / 20:59

1 answer

2

Do you want the date of registration? If it is this you can do right in your INSERT , keep the Data property as you already have to return the data.

SQL Server - INSERT INTO TABELA (Data) Values (GETDATE());
Oracle - INSERT INTO TABELA (Data) Values (SYSDATE());
MySQL - INSERT INTO TABELA (Data) Values (NOW());
    
19.07.2017 / 22:32