public virtual ActionResult Edit(string id, UserEditModel u)
        {
			var x = Users.Get(id);
            ViewData["id"] = id;
            ViewData["users"] = UserSummaryCache;
            ViewData["groups"] = GroupSummaryCache;
            Ascend.Core.User.ValidateEmail(x, u.Email, Users, ModelState);
            Ascend.Core.User.ValidateLogin(x, u.Login, Users, ModelState);
			if (!ModelState.IsValid)
			{
				return View(u);
			}
            try
            {
                u.Apply(x, Accounting);
				Users.Save(x);
                return this.RedirectToAction(c => c.Index());
            }
            catch (Exception ex)
            {
				Notifier.Notify(ex);
                return View(u);
            }
        }
        public static UserEditModel FromDomain(User u, UserActivitySummary logins, IAccountingService accounting)
        {
            var x = new UserEditModel
                       {
                            Manager = u.Manager,
                            Group = u.Group,
                            ManagedGroups = u.ManagedGroups,
                            State = u.State,
                            DateBirth = u.DateBirth,
                            DateHired = u.DateHired,
                            Email = u.Email,
                            Title = u.Title,
                            EmployeeId = u.EmployeeId,
                            FirstName = u.FirstName,
                            LastName = u.LastName,
                            HomeAddress = u.HomeAddress,
                            WorkAddress = u.WorkAddress,
                            HomePhone = u.HomePhone,
                            WorkPhone = u.WorkPhone,
                            MobilePhone = u.MobilePhone,
                            Custom = u.Custom,
                            Permissions = (u.Permissions ?? new UserPermissions()),
                            

                            // display only fields
                            Login = u.Login,
                            DateAcceptedTermsOfService = u.DateAcceptedTermsOfService,
                            DateRegistered = u.DateRegistered,
                            DateActivated = u.DateActivated,
                            DateSuspended = u.DateSuspended,
                            DateTerminated = u.DateTerminated,
                      };
            x.AddBudgets(u, accounting);
            x.AddActivity(logins);
            return x;
        }