Hi,
how can I update column value before SaveChanges(); when ActionResult httpost run
for this column:
Database.Tablolar.Kullanicilar.CreatedDate = DateTime.Now
(Sorry for my easy question, I am new here :) for mvc)
[HttpPost] public ActionResult Register(Kullanicilar kullanicilar) { if (ModelState.IsValid) { _context.Kullanicilar.Add(kullanicilar); _context.SaveChanges(); ModelState.Clear(); ViewBag.Message = kullanicilar.Adi + " " + kullanicilar.Soyadi + " kaydınız tamamlandı."; } return View(); }
Table
CREATE TABLE [dbo].[Kullanicilar] ( [Id] INT IDENTITY (1, 1) NOT NULL, [Adi] NVARCHAR (50) NOT NULL, [CariKodu] NVARCHAR (40) NULL, [Cep] NVARCHAR (15) NOT NULL, [CreatedDate] DATETIME2 (7) NOT NULL, [CreatedUserId] INT NOT NULL, [Eposta] NVARCHAR (MAX) NOT NULL, [Ip] NVARCHAR (15) NULL, [PicturedId] INT NOT NULL, [Session] NVARCHAR (MAX) NULL, [SifreDogrulama] NVARCHAR (MAX) NOT NULL, [Sifresi] NVARCHAR (MAX) NOT NULL, [Soyadi] NVARCHAR (50) NOT NULL, [UpdatedDate] DATETIME2 (7) NOT NULL, [UpdatedUserId] INT NOT NULL );