Beispiel #1
0
 public ActionResult AddPosts(PostModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = new Post
         {
             Name        = model.Name,
             Description = model.Description
         };
         db.Posts.Add(entity);
         db.SaveChanges();
         return(Redirect("/posts"));
     }
     return(View(model));
 }
Beispiel #2
0
 public ActionResult Registration(AccountModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = new User
         {
             FirstName = model.FirstName,
             LastName  = model.LastName,
             Email     = model.Email,
             BirthDate = model.BirthDate,
             Password  = Cryptography.SHA256(model.Password)
         };
         db.Users.Add(entity);
         db.SaveChanges();
         return(RedirectToAction("login", "Account"));
     }
     return(View());
 }
Beispiel #3
0
 //增加
 public bool Add(T_Article a)
 {
     article.T_Article.Add(a);
     return(article.SaveChanges() > 0);
 }
Beispiel #4
0
 //增加
 public bool Add(T_User u)
 {
     user.T_User.Add(u);
     return(user.SaveChanges() > 0);
 }
Beispiel #5
0
 public bool Add(T_Article a)
 {
     publish.T_Article.Add(a);
     return(publish.SaveChanges() > 0);
 }