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; }
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; }
public ActionResult Index(int? id) { User selectedUser = new User(); if (id != null) { selectedUser = repository.Users.FirstOrDefault(u => u.Id == id); } return View(selectedUser); }
public ActionResult Create() { User user = new User(); return PartialView(user); }
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 }); }
public void DeleteUser(User user) { context.Users.Remove(user); context.SaveChanges(); }