Beispiel #1
0
 public ActionResult Create(TutorialsModel tutorialsModel)
 {
     if (ModelState.IsValid)
     {
         tutorialsModel.TutorialsID = Guid.NewGuid().ToString();
         tutorialsModel.CreateAt    = DateTime.Now;
         tutorialsModel.UpdateAt    = DateTime.Now;
         string userID = HttpContext.Session["UserID"] as string;
         tutorialsModel.UserID = userID;
         Tutorials tutorials = tutorialsModel.ToEntity();
         tutorialsCRUD.Create(tutorials);
         return(RedirectToAction("Index"));
     }
     return(View(tutorialsModel));
 }
Beispiel #2
0
        public void TutorialsCreate()
        {
            TutorialsService tutorialsCRUD = new TutorialsService();
            Tutorials        tutorials     = new Tutorials();

            tutorials.TutorialsID = Guid.NewGuid().ToString();
            tutorials.Title       = "测试";
            tutorials.Content     = ReadFile("aa.txt");
            tutorials.CreateAt    = DateTime.Now;
            tutorials.Disc        = "Disc 测试";
            tutorials.Notes       = "Notes 测试";
            User user = new User();

            user.UserID    = "1f1c4189-3792-4a91-8d08-c0d04e18a0ae";
            tutorials.user = user;
            tutorialsCRUD.Create(tutorials);
            Assert.IsNotNull(tutorialsCRUD.GetTutorialsById(tutorials.TutorialsID));
        }