コード例 #1
0
        public ActionResult UnDelete(string id)
        {
            ServiceAccount serviceAccount = new ServiceAccount();

            serviceAccount = serviceAccountRepository.GetServiceAccount(id);

            //Check Exists
            if (serviceAccount == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check AccessRights
            if (!rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ServiceAccountVM serviceAccountVM = new ServiceAccountVM();

            serviceAccountVM.ServiceAccount = serviceAccount;

            return(View(serviceAccountVM));
        }
コード例 #2
0
        //Create ServiceAccount
        public void Add(ServiceAccountVM serviceAccountVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];
            string computerName  = logRepository.GetComputerName();

            //Generate a unique account Id
            serviceAccountVM.ServiceAccount.ServiceAccountId = CWTStringHelpers.GenerateDateBasedId();

            db.spDesktopDataAdmin_InsertServiceAccount_v1(
                serviceAccountVM.ServiceAccount.ServiceAccountId,
                serviceAccountVM.ServiceAccount.ServiceAccountName,
                serviceAccountVM.ServiceAccount.LastName,
                serviceAccountVM.ServiceAccount.FirstName,
                serviceAccountVM.ServiceAccount.Email,
                serviceAccountVM.ServiceAccount.IsActiveFlag,
                serviceAccountVM.ServiceAccount.CubaBookingAllowanceIndicator,
                serviceAccountVM.ServiceAccount.MilitaryAndGovernmentUserFlag,
                serviceAccountVM.ServiceAccount.RoboticUserFlag,
                serviceAccountVM.ServiceAccount.CWTManager,
                serviceAccountVM.ServiceAccount.ThirdPartyUserType,
                serviceAccountVM.ServiceAccount.InternalRemark,
                adminUserGuid,
                Settings.ApplicationName(),
                Settings.ApplicationVersion(),
                computerName
                );
        }
コード例 #3
0
        //UpdateDeletedStatus ServiceAccount
        public void UpdateDeletedStatus(ServiceAccountVM serviceAccountVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_UpdateServiceAccountDeletedStatus_v1(
                serviceAccountVM.ServiceAccount.ServiceAccountId,
                serviceAccountVM.ServiceAccount.DeletedFlag,
                adminUserGuid,
                serviceAccountVM.ServiceAccount.VersionNumber
                );
        }
コード例 #4
0
        public ActionResult Create(ServiceAccountVM serviceAccountVM)
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Access"] = "WriteAccess";
            }

            //Check Access
            if (!rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Update  Model from Form
            try
            {
                TryUpdateModel <ServiceAccountVM>(serviceAccountVM, "GDSServiceAccountVM");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            try
            {
                serviceAccountRepository.Add(serviceAccountVM);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            return(RedirectToAction("ListUnDeleted"));
        }
コード例 #5
0
        public ActionResult UnDelete(ServiceAccountVM serviceAccountVM, FormCollection collection)
        {
            //Check Access
            if (!rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Get Item From Database
            ServiceAccount serviceAccount = new ServiceAccount();

            serviceAccount = serviceAccountRepository.GetServiceAccount(serviceAccountVM.ServiceAccount.ServiceAccountId);

            //Check Exists
            if (serviceAccount == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Delete Item
            try
            {
                serviceAccountVM.ServiceAccount.DeletedFlag = false;
                serviceAccountRepository.UpdateDeletedStatus(serviceAccountVM);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ThirdPartyUser.mvc/Delete/" + serviceAccount.ServiceAccountId;
                    return(View("VersionError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            return(RedirectToAction("ListDeleted"));
        }
コード例 #6
0
        // GET: /Edit
        public ActionResult Edit(string id)
        {
            ServiceAccount serviceAccount = new ServiceAccount();

            serviceAccount = serviceAccountRepository.GetServiceAccount(id);

            //Check Exists
            if (serviceAccount == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            serviceAccountRepository.EditForDisplay(serviceAccount);

            ServiceAccountVM serviceAccountVM = new ServiceAccountVM();

            //CubaPseudoCityOrOfficeFlag
            //Only a user with the Compliance Administrator for Global can check or uncheck this box
            ViewData["ComplianceAdministratorAccess"] = "";
            if (rolesRepository.HasWriteAccessToServiceAccountCubaBookingAllowanceIndicator())
            {
                ViewData["ComplianceAdministratorAccess"] = "WriteAccess";
            }

            //GovernmentPseudoCityOrOfficeFlag
            //Only a user with the GDS Government Administrator role for Global can check or uncheck this box
            ViewData["GDSGovernmentAdministratorAccess"] = "";
            if (rolesRepository.HasWriteAccessToServiceAccountMilitaryAndGovernmentUserFlag())
            {
                ViewData["GDSGovernmentAdministratorAccess"] = "WriteAccess";
            }

            //thirdPartyUserRepository.EditForDisplay(serviceAccount);
            serviceAccountVM.ServiceAccount = serviceAccount;

            return(View(serviceAccountVM));
        }
コード例 #7
0
        public ActionResult Create()
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Access"] = "WriteAccess";
            }

            ServiceAccountVM serviceAccountVM = new ServiceAccountVM();

            ServiceAccount serviceAccount = new ServiceAccount();

            serviceAccount.RoboticUserFlag    = true;
            serviceAccount.ThirdPartyUserType = "Internal";
            serviceAccount.IsActiveFlag       = true;
            serviceAccountVM.ServiceAccount   = serviceAccount;

            //CubaPseudoCityOrOfficeFlag
            //Only a user with the Compliance Administrator for Global can check or uncheck this box
            ViewData["ComplianceAdministratorAccess"] = "";
            if (rolesRepository.HasWriteAccessToServiceAccountCubaBookingAllowanceIndicator())
            {
                ViewData["ComplianceAdministratorAccess"] = "WriteAccess";
            }

            //GovernmentPseudoCityOrOfficeFlag
            //Only a user with the GDS Government Administrator role for Global can check or uncheck this box
            ViewData["GDSGovernmentAdministratorAccess"] = "";
            if (rolesRepository.HasWriteAccessToServiceAccountMilitaryAndGovernmentUserFlag())
            {
                ViewData["GDSGovernmentAdministratorAccess"] = "WriteAccess";
            }

            return(View(serviceAccountVM));
        }
コード例 #8
0
        //Edit ServiceAccount
        public void Update(ServiceAccountVM serviceAccountVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];
            string computerName  = logRepository.GetComputerName();

            db.spDesktopDataAdmin_UpdateServiceAccount_v1(
                serviceAccountVM.ServiceAccount.ServiceAccountId,
                serviceAccountVM.ServiceAccount.ServiceAccountName,
                serviceAccountVM.ServiceAccount.LastName,
                serviceAccountVM.ServiceAccount.FirstName,
                serviceAccountVM.ServiceAccount.Email,
                serviceAccountVM.ServiceAccount.IsActiveFlag,
                serviceAccountVM.ServiceAccount.CubaBookingAllowanceIndicatorNonNullable,
                serviceAccountVM.ServiceAccount.MilitaryAndGovernmentUserFlagNonNullable,
                serviceAccountVM.ServiceAccount.RoboticUserFlag,
                serviceAccountVM.ServiceAccount.CWTManager,
                serviceAccountVM.ServiceAccount.InternalRemark,
                adminUserGuid,
                serviceAccountVM.ServiceAccount.VersionNumber,
                Settings.ApplicationName(),
                Settings.ApplicationVersion(),
                computerName
                );
        }
コード例 #9
0
        public ActionResult Edit(ServiceAccountVM serviceAccountVM)
        {
            //Set Access Rights
            if (!rolesRepository.HasWriteAccessToServiceAccounts())
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Only a user with the correct roles can change these options
            if (!rolesRepository.HasWriteAccessToThirdPartyUserCubaBookingAllowanceIndicator() || !rolesRepository.HasWriteAccessToThirdPartyUserMilitaryAndGovernmentUserFlag())
            {
                ServiceAccount serviceAccount = new ServiceAccount();
                serviceAccount = serviceAccountRepository.GetServiceAccount(serviceAccountVM.ServiceAccount.ServiceAccountId);

                //Check Exists
                if (serviceAccount == null)
                {
                    ViewData["ActionMethod"] = "EditGet";
                    return(View("RecordDoesNotExistError"));
                }

                serviceAccountRepository.EditForDisplay(serviceAccount);

                //CubaPseudoCityOrOfficeFlag
                //Only a user with the Compliance Administrator for Global can check or uncheck this box
                if (!rolesRepository.HasWriteAccessToThirdPartyUserCubaBookingAllowanceIndicator())
                {
                    serviceAccountVM.ServiceAccount.CubaBookingAllowanceIndicatorNonNullable = serviceAccount.CubaBookingAllowanceIndicatorNonNullable;
                }

                //GovernmentPseudoCityOrOfficeFlag
                //Only a user with the GDS Government Administrator role for Global can check or uncheck this box
                if (!rolesRepository.HasWriteAccessToThirdPartyUserMilitaryAndGovernmentUserFlag())
                {
                    serviceAccountVM.ServiceAccount.MilitaryAndGovernmentUserFlagNonNullable = serviceAccount.MilitaryAndGovernmentUserFlagNonNullable;
                }
            }
            //Update  Model from Form
            try
            {
                TryUpdateModel <ServiceAccount>(serviceAccountVM.ServiceAccount, "ServiceAccount");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            try
            {
                serviceAccountRepository.Update(serviceAccountVM);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            string redirectAction = (serviceAccountVM.ServiceAccount.DeletedFlag == true) ? "ListDeleted" : "ListUnDeleted";

            return(RedirectToAction(redirectAction));
        }