コード例 #1
0
        public ActionResult AddEditCRCUser(long?userId)
        {
            var viewModel = new AddEditCRCUserViewModel();

            if (userId.HasValue)
            {
                var drUser = CRCDataAccess.GetCRCUser(userId.Value);
                drUser.MapTo(viewModel);

                viewModel.EnabledInd = !(drUser["DisabledDate"] is DateTime);

                var adminInd     = drUser["AdministratorInd"].ToString().Equals("Y", StringComparison.OrdinalIgnoreCase);
                var userRoleName = adminInd ? "admin" : "station";
                viewModel.UserRole = viewModel.UserRolesList.First(li => li.Value.IndexOf(userRoleName, StringComparison.OrdinalIgnoreCase) >= 0).Value;
            }

            return(View(viewModel));
        }