public ActionResult Edit(string userId, UserEditModel model)
        {
            var u = Users[userId];

            if (ModelState.IsValid)
            {
                model.Apply(u, Accounting);
                return(RedirectToAction("Index"));
            }

            model.AddBudgets(u, Accounting);
            return(View(model));
        }
        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);
            return(x);
        }
        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);
            return x;
        }
        public ActionResult Edit(string userId, UserEditModel model)
        {
            var u = Users[userId];
            if (ModelState.IsValid)
            {
                model.Apply(u, Accounting);
                return RedirectToAction("Index");
            }

            model.AddBudgets(u, Accounting);
            return View(model);
        }