예제 #1
0
        public IActionResult OnPostRegister()
        {
            var id = Request.Form["id"][0];

            GetEntry(id, true);

            var caption = Request.Form["caption"][0];
            var text    = Request.Form["text"][0];

            Entry.Caption = caption;
            Entry.Text    = text;

            BlogEntry.SaveOne(Entry);

            return(Redirect("~/"));
        }
예제 #2
0
 void GetEntry(string id, bool create = false)
 {
     if (string.IsNullOrEmpty(id))
     {
         //create new
         var dt = DateTime.Now;
         Entry = new BlogEntry();
         if (create)
         {
             Entry.Id = dt.ToString("yyyy-MM-dd HH-mm-ss");
             BlogEntry.SaveOne(Entry);
         }
     }
     else
     {
         //edit
         Entry = BlogEntry.ReadOne(id);
     }
 }