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;
 }
Esempio n. 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;
 }
Esempio n. 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);
 }
Esempio n. 4
0
 public ActionResult Create()
 {
     User user = new User();
     return PartialView(user);
 }
Esempio n. 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 });
 }
Esempio n. 6
0
 public void DeleteUser(User user)
 {
     context.Users.Remove(user);
     context.SaveChanges();
 }