Пример #1
0
        public async Task <IActionResult> ExecuteEncrpytion([FromBody] List <TblVocattributes> lstAttributes)
        {
            var model = new AttributesDTO();

            model.tblVocattributes = lstAttributes;
            model.UserName         = User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value;
            var result = await _cimsRepository.ExecuteEncrpytion(model);

            return(StatusCode(result.StatusCode, result.Response));
        }
Пример #2
0
        public async Task <ResponseDTO> ExecuteEncrpytion(AttributesDTO model)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    foreach (var item in model.tblVocattributes)
                    {
                        var label = await db.TblVocattributes.Where(x => x.AttributeCode == item.AttributeCode).AsNoTracking().FirstOrDefaultAsync();

                        var attributeEncryption = new TblEncryption();
                        attributeEncryption.AttributeCode    = item.AttributeCode;
                        attributeEncryption.AttributeLabel   = label.AttributeLabel;
                        attributeEncryption.CreatedBy        = model.UserName;
                        attributeEncryption.CreateDate       = DateTime.Now;
                        attributeEncryption.ParentCode       = item.ModuleParent;
                        attributeEncryption.EncryptionStatus = true;
                        attributeEncryption.UpdateDate       = DateTime.Now;
                        db.TblEncryption.Add(attributeEncryption);
                    }
                    await db.SaveChangesAsync();

                    scope.Complete();
                    return(new ResponseDTO()
                    {
                        StatusCode = 200, Response = CimsConstant.MS0013
                    });
                }
                catch (Exception ex)
                {
                    return(new ResponseDTO()
                    {
                        StatusCode = 400, Response = ex.Message
                    });
                }
            }
        }