Ejemplo n.º 1
0
        public async Task <IActionResult> MasterKeys(MasterKeysViewModel masterKeysView)
        {
            if (ModelState.IsValid == false)
            {
                return(View(masterKeysView));
            }

            masterKeysView.MasterKeys = HttpContext.Session.GetSession <List <MasterDataKeyViewModel> >("MasterKeys");

            MasterDataKey masterKey = _mapper.Map <MasterDataKey>(masterKeysView.MasterKeyInContext);

            if (masterKeysView.IsEdit)
            {
                // Update Master Key
                await _masterData.UpdateMasterKeyAsync(
                    masterKeysView.MasterKeyInContext.PartitionKey,
                    masterKey);
            }
            else
            {
                // Insert Master Key
                masterKey.RowKey       = Guid.NewGuid().ToString();
                masterKey.PartitionKey = masterKey.Name;
                await _masterData.InsertMasterKeyAsync(masterKey);
            }

            //Cache redis
            await _masterDataCache.CreateMasterDataCacheAsync();

            return(RedirectToAction("MasterKeys"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> MasterKeys(MasterKeysViewModel model)
        {
            model.MasterKeys = HttpContext.Session.GetSession <List <MasterDataKeyViewModel> >("MasterKeys");
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var masterKey = _mapper.Map <MasterDataKeyViewModel, MasterDataKey>(model.MasterKeyInContext);

            if (model.IsEdit)
            {
                // Update Master Key
                await _masterData.UpdateMasterKeyAsync(model.MasterKeyInContext.
                                                       PartitionKey, masterKey);
            }
            else
            {
                // Insert Master Key
                masterKey.RowKey       = Guid.NewGuid().ToString();
                masterKey.PartitionKey = masterKey.Name;
                await _masterData.InsertMasterKeyAsync(masterKey);
            }

            return(RedirectToAction("MasterKeys"));
        }