コード例 #1
0
 public ActionResult Create(Record record)
 {
     if (ModelState.IsValid)
     {
         record.Date = DateTime.Now;
         _recordRepo.CreateRecord(record);
         return(RedirectToAction("Index"));
     }
     return(View(record));
 }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: starczi/Guestbook
        public IActionResult Submit(Record record)
        {
            Record newRecord = new Record
            {
                RecordId   = record.RecordId,
                Nick       = record.Nick,
                DatePosted = DateTime.Now,
                Country    = record.Country,
                Email      = record.Email,
                Comment    = record.Comment
            };

            if (ModelState.IsValid)
            {
                _recordRepository.CreateRecord(newRecord);
                return(RedirectToAction("Index", "Record"));
            }

            return(View("Index", record));
        }