Пример #1
0
        public ActionResult AddEditCRCUser(AddEditCRCUserViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var adminInd      = viewModel.UserRole.IndexOf("admin", StringComparison.OrdinalIgnoreCase) >= 0;
                var crcManagerInd = adminInd && viewModel.CrcManagerInd;

                viewModel.UserId = CRCDataAccess.SaveCRCUser(
                    viewModel.UserId,
                    viewModel.Email,
                    viewModel.SalutationId,
                    viewModel.FirstName,
                    viewModel.MiddleName,
                    viewModel.LastName,
                    viewModel.Suffix,
                    viewModel.JobTitle,
                    viewModel.AddressLine1,
                    viewModel.AddressLine2,
                    viewModel.City,
                    viewModel.StateId,
                    viewModel.County,
                    viewModel.Country,
                    viewModel.ZipCode,
                    viewModel.Phone,
                    viewModel.Fax,
                    adminInd,
                    crcManagerInd,
                    viewModel.EnabledInd ? (DateTime?)null : DateTime.UtcNow,
                    viewModel.EnabledInd ? (long?)null : CRCUser.UserId,
                    CRCUser.UserId);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(viewModel));
            }
        }