TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Brunno Obristo
NA
29
3.8k
Get CreateDate and UpdateDate in mvc consuming a webapi
Jul 3 2019 12:16 PM
(Controller)
[ResponseType(
typeof
(
void
))]
public
IHttpActionResult PutVENDEDOR(
int
id, VENDEDOR vENDEDOR)
{
if
(!ModelState.IsValid)
{
return
BadRequest(ModelState);
}
if
(id != vENDEDOR.ID_VENDEDOR)
{
return
BadRequest();
}
db.Entry(vENDEDOR).State = EntityState.Modified;
try
{
//vENDEDOR.DT_ATUALIZA = DateTime.Now.ToString();
db.SaveChanges();
}
catch
(DbUpdateConcurrencyException)
{
if
(!VENDEDORExists(id))
{
return
NotFound();
}
else
{
throw
;
}
}
return
StatusCode(HttpStatusCode.NoContent);
}
// POST: api/Vendedor
[ResponseType(
typeof
(VENDEDOR))]
public
IHttpActionResult PostVENDEDOR(VENDEDOR vENDEDOR)
{
if
(!ModelState.IsValid)
{
return
BadRequest(ModelState);
}
//vENDEDOR.DT_INSERCAO = DateTime.Now.ToString();
db.VENDEDOR.Add(vENDEDOR);
try
{
db.SaveChanges();
}
catch
(DbUpdateException)
{
if
(VENDEDORExists(vENDEDOR.ID_VENDEDOR))
{
return
Conflict();
}
else
{
throw
;
}
}
return
CreatedAtRoute(
"DefaultApi"
,
new
{ id = vENDEDOR.ID_VENDEDOR }, vENDEDOR);
}
(Class)
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString =
"{0:dd/MM/yyyy HH:mm}"
, ApplyFormatInEditMode =
true
)]
public
DateTime DT_INSERCAO {
get
;
set
; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString =
"{0:dd/MM/yyyy HH:mm}"
, ApplyFormatInEditMode =
true
)]
public
DateTime DT_ATUALIZA {
get
;
set
; }
The problem is, when i update a register, the insert date becomes null
Reply
Answers (
1
)
Batch file is not running properly
process from VB.Net to C with output read in the VB Net