コード例 #1
0
 public CustomMembershipUser(User user)
     : base("CustomMembershipProvider", user.Email, user.Id, user.Email, string.Empty, string.Empty, true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now)
 {
     FirstName = user.Name;
     UserId = user.Id;
     UserRoleName = user.Role;
 }
コード例 #2
0
 public int SaveUser(User user)
 {
     var currentId = user.Id;
     if (user.Id == 0)
     {
         context.Users.Add(user);
         context.SaveChanges();
         currentId = (from c in context.Users
                      orderby c.Id descending
                      select c.Id).First();
     }
     else
     {
         User dbUser = context.Users.Find(user.Id);
         if (dbUser != null)
         {
             dbUser.Name = user.Name;
             dbUser.Adress = user.Adress;
             dbUser.Email = user.Email;
             dbUser.Salary = user.Salary;
             dbUser.PersNr = user.PersNr;
             dbUser.Phone = user.Phone;
             dbUser.Role = user.Role;
             dbUser.PostNr = user.PostNr;
             dbUser.PostOrt = user.PostOrt;
             dbUser.Password = user.Password;
             dbUser.Tax = user.Tax;
         }
     }
     context.SaveChanges();
     return currentId;
 }
コード例 #3
0
 public ActionResult Index(int? id)
 {
     User selectedUser = new User();
     if (id != null) {
         selectedUser = repository.Users.FirstOrDefault(u => u.Id == id);
     }
     return View(selectedUser);
 }
コード例 #4
0
 public ActionResult Create()
 {
     User user = new User();
     return PartialView(user);
 }
コード例 #5
0
 public ActionResult SaveUser(User currentUser)
 {
     var currentId = 0;
     if (ModelState.IsValid)
     {
         currentId = repository.SaveUser(currentUser);
     }
     else
     {
         //FIXA FELMEDDELANDE
     }
     return RedirectToAction(actionName: "Index", routeValues: new { id = currentId });
 }
コード例 #6
0
 public void DeleteUser(User user)
 {
     context.Users.Remove(user);
     context.SaveChanges();
 }