public CreateSystemUserCommandHandler(IIntegrationEventPublisherServiceService eventcontext, IMapper mapper)
 {
     _systemUserRepository = new SystemUserRepository(new TaxatHand_StgContext());
     _eventcontext         = eventcontext;
     _mapper = mapper;
 }
예제 #2
0
 public DeleteSystemUserCommandHandler(IIntegrationEventPublisherServiceService eventcontext)
 {
     _systemUserRepository = new SystemUserRepository(new TaxatHand_StgContext());
     _eventcontext         = eventcontext;
     _context = new CosmosDBContext();
 }
예제 #3
0
 public AuthController(IConfiguration configuration, SystemUserRepository systemUserRepository)
 {
     _configuration        = configuration;
     _systemUserRepository = systemUserRepository;
 }
 public SystemUsersController(SystemUserRepository repository)
 {
     _repository = repository;
 }
예제 #5
0
 public void Setup()
 {
     _systemUserRepository = new SystemUserRepository();
 }
예제 #6
0
 public MeasurementsController(MeasurementRepository measurementRepository, MonthRepository monthRepository, SystemUserRepository systemUserRepository) : base(measurementRepository)
 {
     _monthRepository       = monthRepository;
     _systemUserRepository  = systemUserRepository;
     _measurementRepository = measurementRepository;
 }
예제 #7
0
 public InlineUrlKeysController(InlineUrlKeysRepository inlineUrlKeysRepository, SystemUserRepository systemUserRepository, BotsRepository botsRepository, IConfiguration configuration)
 {
     _inlineUrlKeysRepository = inlineUrlKeysRepository;
     _systemUserRepository    = systemUserRepository;
     _configuration           = configuration;
     _botsRepository          = botsRepository;
 }
        public ActionResult Delete(int id, int policyGroupId, int policyOtherGroupHeaderId)
        {
            PolicyOnlineOtherGroupItemLanguageVM PolicyOnlineOtherGroupItemLanguageVM = new PolicyOnlineOtherGroupItemLanguageVM();

            //Check Item Exists
            PolicyOnlineOtherGroupItemLanguage policyOnlineOtherGroupItemLanguage = new PolicyOnlineOtherGroupItemLanguage();

            policyOnlineOtherGroupItemLanguage = PolicyOnlineOtherGroupItemLanguageRepository.GetPolicyOnlineOtherGroupItemLanguage(id);
            if (policyOnlineOtherGroupItemLanguage == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check Policy Exists
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyGroupId);
            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check PolicyOtherGroupHeader Exists
            PolicyOtherGroupHeader policyOtherGroupHeader = new PolicyOtherGroupHeader();

            policyOtherGroupHeader = policyOtherGroupHeaderRepository.GetPolicyOtherGroupHeader(policyOtherGroupHeaderId);
            if (policyOtherGroupHeader == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }

            //Set Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyGroupId) || !rolesRepository.HasWriteAccessToPolicyOnlineOtherGroupItemRepository())
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //If user does not have OnlineUserFlag and the OnlineSensitiveDataFlag is set to true on the PolicyOtherGroupHeader, then mask the translation
            if (policyOtherGroupHeader.OnlineSensitiveDataFlag == true)
            {
                string adminUserGuid = System.Web.HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];
                SystemUserRepository systemUserRepository = new SystemUserRepository();
                SystemUser           systemUser           = systemUserRepository.GetUserBySystemUserGuid(adminUserGuid);
                if (systemUser != null && systemUser.OnlineUserFlag != true)
                {
                    policyOnlineOtherGroupItemLanguage.Translation = new string('*', 20);
                }
            }

            PolicyOnlineOtherGroupItemLanguageVM.PolicyOtherGroupHeader             = policyOtherGroupHeader;
            PolicyOnlineOtherGroupItemLanguageVM.PolicyOnlineOtherGroupItemLanguage = policyOnlineOtherGroupItemLanguage;
            policyGroupRepository.EditGroupForDisplay(policyGroup);
            PolicyOnlineOtherGroupItemLanguageVM.PolicyGroup = policyGroup;

            return(View(PolicyOnlineOtherGroupItemLanguageVM));
        }
        // GET: /Create
        public ActionResult Create(int id)
        {
            //Get Item From Database
            PriceTrackingSetupGroup group = new PriceTrackingSetupGroup();

            group = priceTrackingSetupGroupRepository.GetPriceTrackingSetupGroup(id);

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

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

            //Set Access Rights to Admin
            ViewData["AdminAccess"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(adminGroupName))
            {
                ViewData["AdminAccess"] = "WriteAccess";
            }

            //PriceTrackingSetupGroup
            ViewData["PriceTrackingSetupGroupId"]   = group.PriceTrackingSetupGroupId;
            ViewData["PriceTrackingSetupGroupName"] = group.PriceTrackingSetupGroupName;

            //PriceTrackingSetupGroupItemAir
            PriceTrackingSetupGroupItemAir priceTrackingSetupGroupItemAir = new PriceTrackingSetupGroupItemAir();

            priceTrackingSetupGroupItemAir.PriceTrackingSetupGroupId = id;

            //Default Flags
            priceTrackingSetupGroupItemAir.SharedSavingsFlag  = true;
            priceTrackingSetupGroupItemAir.TransactionFeeFlag = false;
            priceTrackingSetupGroupItemAir.RefundableToRefundableWithPenaltyForRefundAllowedFlag = true;
            priceTrackingSetupGroupItemAir.RefundableToNonRefundableAllowedFlag = true;
            priceTrackingSetupGroupItemAir.VoidWindowAllowedFlag = true;
            priceTrackingSetupGroupItemAir.RefundableToRefundableOutsideVoidWindowAllowedFlag       = true;
            priceTrackingSetupGroupItemAir.NonRefundableToNonRefundableOutsideVoidWindowAllowedFlag = true;
            priceTrackingSetupGroupItemAir.ExchangesAllowedFlag    = true;
            priceTrackingSetupGroupItemAir.VoidExchangeAllowedFlag = true;
            priceTrackingSetupGroupItemAir.NonRefundableToLowerNonRefundableWithDifferentChangeFeeAllowedFlag = true;
            priceTrackingSetupGroupItemAir.RefundableToLowerNonRefundableAllowedFlag = true;
            priceTrackingSetupGroupItemAir.RefundableToLowerRefundableAllowedFlag    = true;
            priceTrackingSetupGroupItemAir.NonPenaltyRefundableToLowerPenaltyRefundableAllowedFlag = true;
            priceTrackingSetupGroupItemAir.ChargeChangeFeeUpFrontForSpecificCarriersFlag           = true;
            priceTrackingSetupGroupItemAir.ChangeFeeMustBeUsedFromResidualValueFlag = true;
            priceTrackingSetupGroupItemAir.AutomaticReticketingFlag = true;

            //Pricing Model Defaults
            priceTrackingSetupGroupItemAir.SharedSavingsAmount = 30;

            //Switch Window Defaults
            priceTrackingSetupGroupItemAir.RefundableToRefundablePreDepartureDayAmount    = 5;
            priceTrackingSetupGroupItemAir.RefundableToNonRefundablePreDepartureDayAmount = 5;

            //Reason Codes
            priceTrackingSetupGroupItemAir.RealisedSavingsCode = "XX";
            priceTrackingSetupGroupItemAir.MissedSavingsCode   = "L";

            //Admin Only
            priceTrackingSetupGroupItemAir.AlphaCodeRemarkField = "Y";

            //Currency
            CurrencyRepository currencyRepository = new CurrencyRepository();
            SelectList         currencysList      = new SelectList(currencyRepository.GetAllCurrencies().ToList(), "CurrencyCode", "Name");

            ViewData["Currencies"] = currencysList;

            //Lists

            ViewData["ClientHasProvidedWrittenApprovalFlagList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.ClientHasProvidedWrittenApprovalFlag);

            ViewData["SharedSavingsList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.SharedSavingsFlag);

            ViewData["TransactionFeeList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.TransactionFeeFlag);

            ViewData["CentralFulfillmentTimeZoneRuleCodes"] = new SelectList(timeZoneRuleRepository.GetAllTimeZoneRules().ToList(), "TimeZoneRuleCode", "TimeZoneRuleCodeDesc");

            ViewData["TimeZoneRules"] = new SelectList(timeZoneRuleRepository.GetAllTimeZoneRules().ToList(), "TimeZoneRuleCode", "TimeZoneRuleCodeDesc");

            ViewData["RefundableToRefundableWithPenaltyForRefundAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.RefundableToRefundableWithPenaltyForRefundAllowedFlag);

            ViewData["RefundableToNonRefundableAllowedFlag"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.RefundableToNonRefundableAllowedFlag);

            ViewData["VoidWindowAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.VoidWindowAllowedFlag);

            ViewData["RefundableToRefundableOutsideVoidWindowAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.RefundableToRefundableOutsideVoidWindowAllowedFlag);

            ViewData["NonRefundableToNonRefundableOutsideVoidWindowAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.NonRefundableToNonRefundableOutsideVoidWindowAllowedFlag);

            ViewData["ExchangesAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.ExchangesAllowedFlag);

            ViewData["VoidExchangeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.VoidExchangeAllowedFlag);

            ViewData["ExchangePreviousExchangeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text");

            ViewData["NonRefundableToLowerNonRefundableWithDifferentChangeFeeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text",
                                                                                                                priceTrackingSetupGroupItemAir.NonRefundableToLowerNonRefundableWithDifferentChangeFeeAllowedFlag);

            ViewData["RefundableToLowerNonRefundableAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text",
                                                                                       priceTrackingSetupGroupItemAir.RefundableToLowerNonRefundableAllowedFlag);

            ViewData["RefundableToLowerRefundableAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text",
                                                                                    priceTrackingSetupGroupItemAir.RefundableToLowerRefundableAllowedFlag);

            ViewData["NonPenaltyRefundableToLowerPenaltyRefundableAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text",
                                                                                                     priceTrackingSetupGroupItemAir.NonPenaltyRefundableToLowerPenaltyRefundableAllowedFlag);

            ViewData["ChargeChangeFeeUpFrontForSpecificCarriersFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text",
                                                                                           priceTrackingSetupGroupItemAir.ChargeChangeFeeUpFrontForSpecificCarriersFlag);

            ViewData["ChangeFeeMustBeUsedFromResidualValueFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text",
                                                                                      priceTrackingSetupGroupItemAir.ChangeFeeMustBeUsedFromResidualValueFlag);

            ViewData["TrackPrivateNegotiatedFareFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text");

            ViewData["AutomaticReticketingFlagList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemAir.AutomaticReticketingFlag);

            //System User
            ViewData["SystemUser"] = "";
            string adminUserGuid = User.Identity.Name.Split(new[] { '|' })[0];
            SystemUserRepository systemUserRepository = new SystemUserRepository();
            SystemUser           systemUser           = systemUserRepository.GetUserBySystemUserGuid(adminUserGuid);

            if (systemUser != null)
            {
                string username = systemUser.FirstName + " " + systemUser.LastName;
                ViewData["SystemUser"] = string.Format("{0} - {1}", username, adminUserGuid);
            }

            return(View(priceTrackingSetupGroupItemAir));
        }
예제 #10
0
 public LoginController(SystemUserRepository systemUserRepository)
 {
     _systemUserRepository = systemUserRepository;
 }
        // GET: /Create
        public ActionResult Create(int id)
        {
            //Get Item From Database
            PriceTrackingSetupGroup group = new PriceTrackingSetupGroup();

            group = priceTrackingSetupGroupRepository.GetPriceTrackingSetupGroup(id);

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

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

            //Set Access Rights to Admin
            ViewData["AdminAccess"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(adminGroupName))
            {
                ViewData["AdminAccess"] = "WriteAccess";
            }

            //PriceTrackingSetupGroup
            ViewData["PriceTrackingSetupGroupId"]   = group.PriceTrackingSetupGroupId;
            ViewData["PriceTrackingSetupGroupName"] = group.PriceTrackingSetupGroupName;

            //PriceTrackingSetupGroupItemHotel
            PriceTrackingSetupGroupItemHotel priceTrackingSetupGroupItemHotel = new PriceTrackingSetupGroupItemHotel();

            priceTrackingSetupGroupItemHotel.PriceTrackingSetupGroupId = id;

            //Default Flags
            priceTrackingSetupGroupItemHotel.SharedSavingsFlag  = true;
            priceTrackingSetupGroupItemHotel.TransactionFeeFlag = false;

            //Pricing Model Defaults
            priceTrackingSetupGroupItemHotel.SharedSavingsAmount = 30;

            //Threshold Defaults
            priceTrackingSetupGroupItemHotel.EstimatedCWTRebookingFeeAmount = decimal.Parse("0.00");;
            priceTrackingSetupGroupItemHotel.CWTVoidRefundFeeAmount         = decimal.Parse("0.00");
            priceTrackingSetupGroupItemHotel.ThresholdAmount = decimal.Parse("0.00");

            priceTrackingSetupGroupItemHotel.CalculatedTotalThresholdAmount =
                priceTrackingSetupGroupItemHotel.EstimatedCWTRebookingFeeAmount +
                priceTrackingSetupGroupItemHotel.CWTVoidRefundFeeAmount +
                priceTrackingSetupGroupItemHotel.ThresholdAmount;

            //Hotel Amenity Values Defaults
            priceTrackingSetupGroupItemHotel.RoomTypeUpgradeAllowedFlag           = true;
            priceTrackingSetupGroupItemHotel.BeddingTypeUpgradeAllowedFlag        = true;
            priceTrackingSetupGroupItemHotel.HotelRateCodeUpgradeAllowedFlag      = true;
            priceTrackingSetupGroupItemHotel.NegotiatedUpgradeAllowedFlag         = true;
            priceTrackingSetupGroupItemHotel.CancellationPolicyUpgradeAllowedFlag = true;
            priceTrackingSetupGroupItemHotel.KingQueenUpgradeAllowedFlag          = true;

            //Rate Codes
            priceTrackingSetupGroupItemHotel.CWTRateTrackingCode1 = "CWT";
            priceTrackingSetupGroupItemHotel.CWTRateTrackingCode2 = "CWV";

            //Admin Only
            priceTrackingSetupGroupItemHotel.AlphaCodeRemarkField = "Y";

            //Currency
            CurrencyRepository currencyRepository = new CurrencyRepository();
            SelectList         currencysList      = new SelectList(currencyRepository.GetAllCurrencies().ToList(), "CurrencyCode", "Name");

            ViewData["Currencies"] = currencysList;

            //Lists

            ViewData["ClientHasProvidedWrittenApprovalFlagList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.ClientHasProvidedWrittenApprovalFlag);

            ViewData["ClientHasHotelFeesInMSAFlagList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.ClientHasHotelFeesInMSAFlag);

            ViewData["ClientUsesConfermaVirtualCardsFlagList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.ClientUsesConfermaVirtualCardsFlag);

            ViewData["CentralFulfillmentTimeZoneRuleCodes"] = new SelectList(timeZoneRuleRepository.GetAllTimeZoneRules().ToList(), "TimeZoneRuleCode", "TimeZoneRuleCodeDesc");

            ViewData["TimeZoneRules"] = new SelectList(timeZoneRuleRepository.GetAllTimeZoneRules().ToList(), "TimeZoneRuleCode", "TimeZoneRuleCodeDesc");

            ViewData["SharedSavingsList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.SharedSavingsFlag);

            ViewData["TransactionFeeList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.TransactionFeeFlag);

            ViewData["RoomTypeUpgradeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.RoomTypeUpgradeAllowedFlag);

            ViewData["BeddingTypeUpgradeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.BeddingTypeUpgradeAllowedFlag);

            ViewData["HotelRateCodeUpgradeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.HotelRateCodeUpgradeAllowedFlag);

            ViewData["CancellationPolicyUpgradeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.CancellationPolicyUpgradeAllowedFlag);

            ViewData["KingQueenUpgradeAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.KingQueenUpgradeAllowedFlag);

            ViewData["BreakfastChangesAllowedFlagList"] = new SelectList(commonRepository.GetAllowedNotAllowedList().ToList(), "Value", "Text", priceTrackingSetupGroupItemHotel.BreakfastChangesAllowedFlag);

            ViewData["EnableValueTrackingFlagList"] = new SelectList(commonRepository.GetTrueFalseList().ToList(), "Value", "Text");

            //System User
            ViewData["SystemUser"] = "";
            string adminUserGuid = User.Identity.Name.Split(new[] { '|' })[0];
            SystemUserRepository systemUserRepository = new SystemUserRepository();
            SystemUser           systemUser           = systemUserRepository.GetUserBySystemUserGuid(adminUserGuid);

            if (systemUser != null)
            {
                string username = systemUser.FirstName + " " + systemUser.LastName;
                ViewData["SystemUser"] = string.Format("{0} - {1}", username, adminUserGuid);
            }

            return(View(priceTrackingSetupGroupItemHotel));
        }
        private async Task RegisterSingleStep(StringBuilder log, SdkMessageRepository repositoryMessage, SdkMessageFilterRepository repositoryFilter, SystemUserRepository repositorySystemUser, Entities.PluginType entPluginType, Model.Backup.PluginStep step)
        {
            var entMessage = await repositoryMessage.FindMessageAsync(step.Message);

            if (entMessage == null)
            {
                log.AppendFormat("Message {0} not founded in CRM.", step.Message).AppendLine();
                return;
            }

            var refMessageFilter = await repositoryFilter.FindFilterAsync(entMessage.Id, step.PrimaryEntity, step.SecondaryEntity);

            EntityReference refSecure     = null;
            EntityReference refSystemUser = null;

            if (!string.IsNullOrEmpty(step.SecureConfiguration))
            {
                var entSecure = new Entity(Entities.SdkMessageProcessingStepSecureConfig.EntityLogicalName);
                entSecure.Attributes[Entities.SdkMessageProcessingStepSecureConfig.Schema.Attributes.secureconfig] = step.SecureConfiguration;

                entSecure.Id = await _service.CreateAsync(entSecure);

                refSecure = entSecure.ToEntityReference();
            }

            if (!string.IsNullOrEmpty(step.RunInUserContext) && step.RunInUserContext != "Calling User")
            {
                refSystemUser = repositorySystemUser.FindUser(step.RunInUserContext);
            }

            var entStep = new Entity(Entities.SdkMessageProcessingStep.EntityLogicalName)
            {
                Id = step.Id
            };

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.asyncautodelete] = step.AsyncAutoDelete.GetValueOrDefault();
            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.name]            = step.Name;
            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.description]     = step.Description;
            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.rank]            = step.ExecutionOrder;

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.stage] = new OptionSetValue((int)step.Stage);
            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.mode]  = new OptionSetValue((int)step.ExecutionMode);

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.supporteddeployment] = new OptionSetValue((int)step.SupportedDeploymentCode);

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.configuration] = step.UnsecureConfiguration;

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.filteringattributes] = string.Join(",", step.FilteringAttributes.OrderBy(s => s));

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.plugintypeid] = entPluginType.ToEntityReference();

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.eventhandler] = entPluginType.ToEntityReference();

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.sdkmessageid] = entMessage.ToEntityReference();

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.sdkmessagefilterid] = refMessageFilter;

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.sdkmessageprocessingstepsecureconfigid] = refSecure;

            entStep.Attributes[Entities.SdkMessageProcessingStep.Schema.Attributes.impersonatinguserid] = refSystemUser;

            entStep.Id = await _service.CreateAsync(entStep);

            foreach (var image in step.PluginImages)
            {
                var entImage = new Entity(Entities.SdkMessageProcessingStepImage.EntityLogicalName)
                {
                    Id = image.Id
                };

                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.sdkmessageprocessingstepid] = entStep.ToEntityReference();

                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.imagetype] = new OptionSetValue(image.ImageType.Value);

                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.name]        = image.Name;
                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.entityalias] = image.EntityAlias;

                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.customizationlevel]   = image.CustomizationLevel;
                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.relatedattributename] = image.RelatedAttributeName;
                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.messagepropertyname]  = image.MessagePropertyName;

                entImage.Attributes[Entities.SdkMessageProcessingStepImage.Schema.Attributes.attributes] = string.Join(",", image.Attributes.OrderBy(s => s));

                entImage.Id = await _service.CreateAsync(entImage);
            }

            _service.Execute(new SetStateRequest()
            {
                EntityMoniker = entStep.ToEntityReference(),

                State  = new OptionSetValue(step.StateCode.Value),
                Status = new OptionSetValue(step.StatusCode.Value),
            });
        }
        public ActionResult CommitChanges(SystemUserWizardVM systemUserChanges)
        {
            SystemUserLocation systemUserLocation = new SystemUserLocation();

            systemUserLocation = systemUserChanges.SystemUserLocation;


            WizardMessages wizardMessages = new WizardMessages();

            try
            {
                TryUpdateModel(systemUserChanges.SystemUserLocation, "SystemUserLocation");
            }
            catch
            {
                //Validation Error
                string msg = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        msg += error.ErrorMessage;
                    }
                }
                return(Json(new WizardJSONResponse
                {
                    html = ControllerExtension.RenderPartialViewToString(this, "Error", msg),
                    message = msg,
                    success = false
                }));
            }


            //Editing A SystemUser Location
            try
            {
                SystemUserLocationRepository systemUserLocationRepository = new SystemUserLocationRepository();
                SystemUserLocation           originalSystemUserLocation   = new SystemUserLocation();
                originalSystemUserLocation = systemUserLocationRepository.GetSystemUserLocation(systemUserChanges.SystemUser.SystemUserGuid);
                if (originalSystemUserLocation == null)
                {
                    systemUserLocationRepository.Add(systemUserLocation);
                    wizardMessages.AddMessage("User's Location successfully updated", true);
                }
                else
                {
                    if (originalSystemUserLocation.LocationId != systemUserChanges.SystemUserLocation.LocationId)
                    {
                        systemUserLocationRepository.Update(systemUserLocation);
                        wizardMessages.AddMessage("User's Location successfully updated", true);
                    }
                }
            }
            catch (SqlException ex)
            {
                //If there is error we will continue, but store error to return to user

                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    wizardMessages.AddMessage("User's Location was not updated. Another user has already changed this Location.", false);
                }
                else                 //Other Error
                {
                    LogRepository logRepository = new LogRepository();
                    logRepository.LogError(ex.Message);

                    wizardMessages.AddMessage("User's Location was not updated, please check Event Log for details", false);
                    wizardMessages.AddMessage("There was a problem with your request, please see the log file or contact an administrator for details", false);
                }
            }


            //Editing Default Profile Identifier
            try
            {
                SystemUserRepository systemUserRepository = new SystemUserRepository();
                SystemUser           originalSystemUser   = new SystemUser();
                originalSystemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserChanges.SystemUser.SystemUserGuid);

                if (originalSystemUser.DefaultProfileIdentifier == null)
                {
                    originalSystemUser.DefaultProfileIdentifier = false;
                }
                if (originalSystemUser.DefaultProfileIdentifier != systemUserChanges.SystemUser.DefaultProfileIdentifier)
                {
                    wizardMessages.AddMessage("User's Default Profile successfully updated", true);
                    systemUserRepository.EditDefaultProfileIdentifier(systemUserChanges.SystemUser);
                }
            }
            catch (SqlException ex)
            {
                //If there is error we will continue, but store error to return to user

                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    wizardMessages.AddMessage("User's Default Profile was not updated. Another user has already changed this.", false);
                }
                else                 //Other Error
                {
                    LogRepository logRepository = new LogRepository();
                    logRepository.LogError(ex.Message);

                    wizardMessages.AddMessage("User's Default Profile was not updated, please check Event Log for details", false);
                    wizardMessages.AddMessage("There was a problem with your request, please see the log file or contact an administrator for details", false);
                }
            }

            //Editing Restricted Flag
            try
            {
                SystemUserRepository systemUserRepository = new SystemUserRepository();
                SystemUser           originalSystemUser   = new SystemUser();
                originalSystemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserChanges.SystemUser.SystemUserGuid);

                if (originalSystemUser.RestrictedFlag == null)
                {
                    originalSystemUser.RestrictedFlag = false;
                }
                if (originalSystemUser.RestrictedFlag != systemUserChanges.SystemUser.RestrictedFlag)
                {
                    wizardMessages.AddMessage("User's Restricted Flag successfully updated", true);
                    systemUserRepository.EditRestrictedFlag(systemUserChanges.SystemUser);
                }
            }
            catch (SqlException ex)
            {
                //If there is error we will continue, but store error to return to user

                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    wizardMessages.AddMessage("User's Restricted Flag was not updated. Another user has already changed this.", false);
                }
                else                 //Other Error
                {
                    LogRepository logRepository = new LogRepository();
                    logRepository.LogError(ex.Message);

                    wizardMessages.AddMessage("User's Restricted Flag was not updated, please check Event Log for details", false);
                    wizardMessages.AddMessage("There was a problem with your request, please see the log file or contact an administrator for details", false);
                }
            }

            //Editing Cuba Booking Allowed Identifier
            try
            {
                SystemUserRepository systemUserRepository = new SystemUserRepository();
                SystemUser           originalSystemUser   = new SystemUser();
                originalSystemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserChanges.SystemUser.SystemUserGuid);

                if (originalSystemUser.CubaBookingAllowanceIndicator == null)
                {
                    originalSystemUser.CubaBookingAllowanceIndicator = false;
                }

                if (originalSystemUser.CubaBookingAllowanceIndicator != systemUserChanges.SystemUser.CubaBookingAllowanceIndicator)
                {
                    wizardMessages.AddMessage("User's Cuba Booking Allowed successfully updated", true);
                    systemUserRepository.EditCubaBookingAllowanceIndicator(systemUserChanges.SystemUser);
                }
            }
            catch (SqlException ex)
            {
                //If there is error we will continue, but store error to return to user

                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    wizardMessages.AddMessage("User's Cuba Booking Allowed was not updated. Another user has already changed this.", false);
                }
                else                 //Other Error
                {
                    LogRepository logRepository = new LogRepository();
                    logRepository.LogError(ex.Message);

                    wizardMessages.AddMessage("User's Cuba Booking Allowed was not updated, please check Event Log for details", false);
                    wizardMessages.AddMessage("There was a problem with your request, please see the log file or contact an administrator for details", false);
                }
            }


            //ExternalSystemLoginSystemUserCountries
            ExternalSystemLoginRepository externalSystemLoginRepository = new ExternalSystemLoginRepository();
            List <ExternalSystemLoginSystemUserCountry> originalExternalSystemLoginSystemUserCountries = externalSystemLoginRepository.GetBackOfficeIdentifiers(systemUserChanges.SystemUser.SystemUserGuid);

            if (originalExternalSystemLoginSystemUserCountries != null && originalExternalSystemLoginSystemUserCountries.Count == 0)
            {
                originalExternalSystemLoginSystemUserCountries = null;
            }

            if (originalExternalSystemLoginSystemUserCountries != systemUserChanges.ExternalSystemLoginSystemUserCountries)
            {
                string systemUserGuid = systemUserChanges.SystemUser.SystemUserGuid;
                try
                {
                    externalSystemLoginRepository.AddBackOfficeIdentifiers(systemUserGuid, systemUserChanges.ExternalSystemLoginSystemUserCountries);
                    wizardMessages.AddMessage("User's Back Office Identifiers successfully updated", true);
                }
                catch (SqlException ex)
                {
                    //Versioning Error
                    if (ex.Message == "SQLVersioningError")
                    {
                        wizardMessages.AddMessage("User's BackOffice Identifier was not updated. Another user has already changed this item.", false);
                    }
                    else                     //Other Error
                    {
                        LogRepository logRepository = new LogRepository();
                        logRepository.LogError(ex.Message);

                        wizardMessages.AddMessage("User's BackOffice Identifier was not updated, please check Event Log for details", false);
                        wizardMessages.AddMessage("There was a problem with your request, please see the log file or contact an administrator for details", false);
                    }
                }
            }

            //we continue to add Teams
            try
            {
                wizardMessages = systemUserWizardRepository.UpdateSystemUserTeams(systemUserChanges, wizardMessages);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                wizardMessages.AddMessage("User's Teams were not changed, please check Event Log for details", false);
                wizardMessages.AddMessage("There was a problem with your request, please see the log file or contact an administrator for details", false);
            }

            //we continue to add GDSs
            if (systemUserChanges.GDSChanged)
            {
                try
                {
                    wizardMessages = systemUserWizardRepository.UpdateSystemUserGDSs(systemUserChanges, wizardMessages);
                }
                catch (SqlException ex)
                {
                    LogRepository logRepository = new LogRepository();
                    logRepository.LogError(ex.Message);

                    wizardMessages.AddMessage("User's GDS settings were not changed, please check Event Log for details", false);
                    wizardMessages.AddMessage("There was a problem with your request, please see the log file or contact an administrator for details", false);
                }
            }
            return(Json(new
            {
                html = ControllerExtension.RenderPartialViewToString(this, "FinishedScreen", wizardMessages),
                message = "Success",
                success = true
            }));
        }