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")); }
public async Task <bool> InsertMasterKeyAsync(MasterDataKey key) { using (_unitOfWork) { _masterDataKeyRepository.Add(key); return(await _unitOfWork.CommitTransactionAsync()); } }
public async Task <bool> InsertMasterKeyAsync(MasterDataKey key) { using (_unitOfWork) { await _unitOfWork.Repository <MasterDataKey>().AddAsync(key); _unitOfWork.CommitTransaction(); return(true); } }
public async Task <bool> UpdateMasterKeyAsync(string orginalPartitionKey, MasterDataKey key) { using (_unitOfWork) { MasterDataKey masterKey = await _masterDataKeyRepository.FindAsync(key.RowKey); masterKey.IsActive = key.IsActive; masterKey.IsDeleted = key.IsDeleted; masterKey.Name = key.Name; _masterDataKeyRepository.Update(masterKey); return(await _unitOfWork.CommitTransactionAsync()); } }
public async Task <bool> UpdateMasterKeyAsync(string orginalPartitionKey, MasterDataKey key) { using (_unitOfWork) { var masterKey = await _unitOfWork.Repository <MasterDataKey>().FindAsync(orginalPartitionKey, key.RowKey); masterKey.IsActive = key.IsActive; masterKey.IsDeleted = key.IsDeleted; masterKey.Name = key.Name; await _unitOfWork.Repository <MasterDataKey>().UpdateAsync(masterKey); _unitOfWork.CommitTransaction(); return(true); } }