コード例 #1
0
        public ActionResult Edit(AppUserEditView model)
        {
            if (ModelState.IsValid)
            {
                if (Request.Form["submitbutton"] != null)
                {
                    AppUserHelpers.UpdateAppUserFromAppUserEditView(db, model);
                    return(RedirectToAction(model.CallingAction, model.CallingController));
                }

                return(RedirectToAction("Edit"));
            }

            Branch userBranch = BranchHelpers.GetCurrentBranchForUser(AppUserHelpers.GetGuidFromUserGetAppUserId(User.Identity.GetAppUserId()));

            //DropDowns
            ViewBag.BranchList       = ControlHelpers.AllBranchesForCompanyListDropDown(userBranch.CompanyId, userBranch.BranchId);
            ViewBag.UserRoleList     = ControlHelpers.UserRoleEnumListDropDown();
            ViewBag.EntityStatusList = ControlHelpers.EntityStatusEnumListDropDown();

            //Counters
            if (model.UserFriendListView == null)
            {
                model.UserFriendListView = new List <FriendView>();
            }
            if (model.UserBranchFriendListView == null)
            {
                model.UserBranchFriendListView = new List <FriendView>();
            }
            if (model.UserCompanyFriendListView == null)
            {
                model.UserCompanyFriendListView = new List <FriendView>();
            }

            ViewBag.UserFriendCount        = model.UserFriendListView.Count();
            ViewBag.UserBranchFriendCount  = model.UserBranchFriendListView.Count();
            ViewBag.UserCompanyFriendCount = model.UserCompanyFriendListView.Count();

            if (model.UserBlockListView == null)
            {
                model.UserBlockListView = new List <BlockView>();
            }
            if (model.UserBranchBlockListView == null)
            {
                model.UserBranchBlockListView = new List <BlockView>();
            }
            if (model.UserCompanyBlockListView == null)
            {
                model.UserCompanyBlockListView = new List <BlockView>();
            }

            ViewBag.UserBlockCount        = model.UserBlockListView.Count();
            ViewBag.UserBranchBlockCount  = model.UserBranchBlockListView.Count();
            ViewBag.UserCompanyBlockCount = model.UserCompanyBlockListView.Count();

            //rebuild group model
            model.GroupListViewsForUserOnly = GroupViewHelpers.GetGroupEditViewForForUserOnly(db, model.AppUserId);

            return(View(model));
        }