public int Create(ApplicationSettingViewModel model)
        {
            AppSettings obj = new AppSettings
            {
                ProductId = model.ProductId,
                EnablePasswordRetrieval              = model.EnablePasswordRetrieval,
                EnablePasswordReset                  = model.EnablePasswordReset,
                RequiresQuestionAndAnswer            = model.RequiresQuestionAndAnswer,
                RequiresUniqueEmail                  = model.RequiresUniqueEmail,
                MaxInvalidPasswordAttempts           = model.MaxInvalidPasswordAttempts,
                MinRequiredPasswordLength            = model.MinRequiredPasswordLength,
                MinRequiredNonalphanumericCharacters = model.MinRequiredNonalphanumericCharacters,
                PasswordAttemptWindow                = model.PasswordAttemptWindow,
                AppDateFormat = model.AppDateFormat,
                SMTPServer    = model.SMTPServer,
                SMTPPort      = model.SMTPPort,
                SMTPUsername  = model.SMTPUsername,
                SMTPPassword  = model.SMTPPassword,
                EnableExpirePasswordWhenUserNotLoginFromDays = model.EnableExpirePasswordWhenUserNotLoginFromDays,
                EnableAutoExpirePassword = model.EnableAutoExpirePassword,
                AutoPasswordExpiryInDays = model.AutoPasswordExpiryInDays,
                ShowPassowrdExpireNotificationBeforeDays = model.ShowPassowrdExpireNotificationBeforeDays,
                Paggination = model.Paggination,
            };

            _ent.AddToAppSettings(obj);
            _ent.SaveChanges();
            return(obj.ProductId);
        }
        public ApplicationSettingViewModel Edit(ApplicationSettingViewModel model, out ActionResponse _ores)
        {
            int  ProductId = model.HFProductId;
            bool flag;

            flag = CheckProductId(model.HFProductId);
            if (flag == true)
            {
                model.ProductId     = model.HFProductId;
                model.ProductId     = Create(model);
                _res.ActionMessage  = String.Format(Resources.Message.SuccessfullyCreated, "Application Setting");
                _res.ErrNumber      = 0;
                _res.ErrSource      = "DataBase";
                _res.ErrType        = "App";
                _res.ResponseStatus = true;
            }
            else
            {
                model.ProductId = ProductId;
                model           = Update(model, out _res);
                model.Flag      = true;
            }
            model.ProductId = model.HFProductId;
            _ores           = _res;
            return(model);
        }
Esempio n. 3
0
 public ActionResult Edit(ApplicationSettingViewModel model)
 {
     model = _rep.Edit(model, out _res);
     model.ddlProductList      = new SelectList(_rep.GetProductList(), "ProductId", "ProductName", 0);
     Session["ActionResponse"] = _res;
     //return PartialView("SettingPartial", model);
     return(View("Index", model));
 }
        public ApplicationSettingViewModel Update(ApplicationSettingViewModel model, out ActionResponse _ores)
        {
            if (model.ProductId != null)
            {
                AppSettings obj = _ent.AppSettings.Where(u => u.ProductId == model.ProductId).FirstOrDefault();
                if (obj != null)
                {
                    obj.ProductId = model.ProductId;
                    obj.EnablePasswordRetrieval              = model.EnablePasswordRetrieval;
                    obj.EnablePasswordReset                  = model.EnablePasswordReset;
                    obj.RequiresQuestionAndAnswer            = model.RequiresQuestionAndAnswer;
                    obj.RequiresUniqueEmail                  = model.RequiresUniqueEmail;
                    obj.MaxInvalidPasswordAttempts           = model.MaxInvalidPasswordAttempts;
                    obj.MinRequiredPasswordLength            = model.MinRequiredPasswordLength;
                    obj.MinRequiredNonalphanumericCharacters = model.MinRequiredNonalphanumericCharacters;
                    obj.PasswordAttemptWindow                = model.PasswordAttemptWindow;
                    obj.AppDateFormat = model.AppDateFormat;
                    obj.SMTPServer    = model.SMTPServer;
                    obj.SMTPPort      = model.SMTPPort;
                    obj.SMTPUsername  = model.SMTPUsername;
                    obj.SMTPPassword  = model.SMTPPassword;
                    obj.EnableExpirePasswordWhenUserNotLoginFromDays = model.EnableExpirePasswordWhenUserNotLoginFromDays;
                    obj.EnableAutoExpirePassword = model.EnableAutoExpirePassword;
                    obj.AutoPasswordExpiryInDays = model.AutoPasswordExpiryInDays;
                    obj.ShowPassowrdExpireNotificationBeforeDays = model.ShowPassowrdExpireNotificationBeforeDays;
                    obj.Paggination = model.Paggination;

                    _ent.ApplyCurrentValues(obj.EntityKey.EntitySetName, obj);
                    _ent.SaveChanges();
                    _res.ActionMessage  = String.Format(Resources.Message.SuccessfullyUpdated, "Application Setting");
                    _res.ErrNumber      = 0;
                    _res.ErrSource      = "DataBase";
                    _res.ErrType        = "App";
                    _res.ResponseStatus = true;
                }
                else
                {
                    _res.ActionMessage  = String.Format(Resources.Message.InvalidOperation, "Application Setting");
                    _res.ErrNumber      = 1005;
                    _res.ErrSource      = "DataBase";
                    _res.ErrType        = "App";
                    _res.ResponseStatus = true;
                }
            }
            else
            {
                _res.ActionMessage  = String.Format(Resources.Message.InvalidOperation, "Application Setting");
                _res.ErrNumber      = 1005;
                _res.ErrSource      = "DataBase";
                _res.ErrType        = "App";
                _res.ResponseStatus = true;
            }
            _ores = _res;
            return(model);
            /////
        }
Esempio n. 5
0
        public void ApplicationSettingViewModelWillSerialize()
        {
            ApplicationSettingViewModel vm = new ApplicationSettingViewModel(
                new ApplicationSetting()
            {
                Name = "Test", Display = "Test", Value = 5
            },
                _calculator
                );

            string hash = _calculator.Calculate(vm);

            Assert.IsTrue(!String.IsNullOrEmpty(hash));
        }
Esempio n. 6
0
        public AEMG SetupMainWindow()
        {
            //reset working directory
            Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //set culture
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            var dataIO     = new DataIO();
            var autoMapper = new SimpleAutoMapper();
            var messageBox = new MessageBoxService();
            var repository = new AERepository();
            var mtpManager = new MTPManager();
            var saverepo   = new AESavedSetupRepository();

            var actionProvider  = new ActionProvider(autoMapper, messageBox);
            var aeActionFactory = new AEActionFactory(actionProvider);

            var DependencyDict = new Dictionary <Type, object>()
            {
                { typeof(SimpleAutoMapper), autoMapper },
                { typeof(MessageBoxService), messageBox },
                { typeof(ViewModelClipboard), new ViewModelClipboard() },
            };

            var viewModelFactory = new ViewModelFactory(DependencyDict);
            var appSettingVM     = new ApplicationSettingViewModel(actionProvider, viewModelFactory);

            SetupWindowInit(appSettingVM, out IWindowInitlizer windowinit);

            (new ScriptGenerateBootstrap()).SetUp(out IActionToScriptFactory actionToScriptFactory, out IEmulatorToScriptFactory emulatorToScriptFactory);

            var scriptApply       = new ScriptApplyBootStrap(messageBox, mtpManager).GetScriptApplyFactory();
            var scanner           = new MacroScanner(dataIO, aeActionFactory);
            var macroManager      = new AEMacroManager(scanner);
            var macroManagerVM    = new AEMacroManagerViewModel(scanner, messageBox, macroManager, windowinit);
            var aESettingVM       = new AESettingViewModel(new AESetting(), mtpManager);
            var aeScriptGenerator = new AEScriptGenerator(scriptApply, aESettingVM, messageBox, autoMapper, emulatorToScriptFactory, actionToScriptFactory, dataIO, actionProvider);
            var autoUpdater       = new AutoUpdater(messageBox);
            var actionList        = new AEActionListViewModel(macroManager, repository, messageBox);
            var savemanager       = new AEMacroSaveManagerViewModel(saverepo, macroManager);

            return(new AEMG
            {
                DataContext = new AEMGViewModel(macroManagerVM, actionList, aESettingVM, aeScriptGenerator, messageBox, autoUpdater, savemanager, macroManager)
            });
        }
Esempio n. 7
0
        public async Task <IAppSettingResponse> InsertAppSettingAsync(ApplicationSettingViewModel model)
        {
            try
            {
                var entries = _mapper.Map <ApplicationSetting>(model);
                _appDbContext.ApplicationSettings.AddRange(entries);
                await _appDbContext.SaveChangesAsync();

                var appSettings = await _appDbContext.ApplicationSettings.ToListAsync();

                return(new AppSettingResponse(_mapper.Map <List <ApplicationSettingViewModel> >(appSettings)));
            }
            catch (Exception e)
            {
                return(new AppSettingResponse(e));
            }
        }
Esempio n. 8
0
        private void SetupWindowInit(ApplicationSettingViewModel settingVM, out IWindowInitlizer windowinit)
        {
            windowinit = new WindowInit();
            Setting window = null;

            settingVM.SettingSaved += (sender, e) =>
            {
                window?.Close();
            };

            windowinit.SettingWindowOpen += (sender, e) =>
            {
                settingVM.LoadSetting();
                window             = new Setting();
                window.DataContext = settingVM;

                window.ShowDialog();
            };
        }
Esempio n. 9
0
        public ActionResult Index(ApplicationSettingViewModel model, int?ProductId)
        {
            if (Request.IsAjaxRequest())
            {
                if (ProductId == null)
                {
                    ProductId = 0;
                }
                _model                    = _rep.Get(ProductId, out _res);
                _model.HFProductId        = ProductId.Value;
                Session["ActionResponse"] = _res;
                return(PartialView("SettingPartial", _model));
            }
            model = _rep.Edit(model, out _res);
            model.ddlProductList = new SelectList(_rep.GetProductList(), "ProductId", "ProductName", 0);

            Session["ActionResponse"] = _res;
            return(View(model));
        }
        public async Task <IAppSettingResponse> UpdateAppSettingAsync(ApplicationSettingViewModel appSetting)
        {
            try
            {
                var data = await _appDbContext.ApplicationSettings.FirstOrDefaultAsync(k => k.Key == appSetting.Key);

                if (data == null)
                {
                    return(new AppSettingResponse("Not Found", HttpStatusCode.NotFound));
                }

                data.Value = appSetting.Value;
                await _appDbContext.SaveChangesAsync();

                return(new AppSettingResponse(_mapper.Map <ApplicationSettingViewModel>(data)));
            }
            catch (Exception e)
            {
                return(new AppSettingResponse(e));
            }
        }
        public async Task <IActionResult> UpdateAppSetting(ApplicationSettingViewModel appSetting)
        {
            var result = await _service.UpdateAppSettingAsync(appSetting);

            return(Ok(result));
        }
        public async Task <IActionResult> InsertAppSettingAsync([FromBody] ApplicationSettingViewModel models)
        {
            var result = await _service.InsertAppSettingAsync(models);

            return(Ok(result));
        }
Esempio n. 13
0
 public AppSettingResponse(ApplicationSettingViewModel appSetting) : this(true, string.Empty, appSetting)
 {
 }
Esempio n. 14
0
 private AppSettingResponse(bool success, string message, ApplicationSettingViewModel appSetting) : base(success, message)
 {
     ApplicationSetting = appSetting;
 }
Esempio n. 15
0
        //
        // GET: /ApplicationSetting/Edit/5

        public ActionResult Edit(int?id)
        {
            _model = _rep.Get(id, out _res);
            Session["ActionResponse"] = _res;
            return(View(_model));
        }