コード例 #1
0
        public async Task <bool> ChangeCardNumber(Guid personModelId, string CardNumber)
        {
            if (personModelId.Equals(Guid.Empty))
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(CardNumber))
            {
                return(false);
            }
            try
            {
                if (!_context.Persons.Any(p => p.Id == personModelId))
                {
                    return(false);
                }
                if (!_context.CardModels.Any(c => c.CardNumber == CardNumber))
                {
                    return(false);
                }
                var usr = _context.Persons.First(p => p.Id == personModelId);
                usr.CardNumber = _context.CardModels.First(c => c.CardNumber == CardNumber);
                var encryptedRelation = await _securLib.EncryptEntityRelation(usr, usr.AutorizationLevel);

                usr.SafeAuthModel.Control = await _securLib.EncriptLine(encryptedRelation);

                _context.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                StaticEventHandler.Log(System.Diagnostics.TraceLevel.Error, "error during IsAutorized od person", MethodBase.GetCurrentMethod(), ex);
                return(false);
            }
        }
コード例 #2
0
 public Guid Create(NodeCreateModel node)
 {
     try
     {
         var savenode = JToken.FromObject(node).ToObject <NodeModel>();
         savenode.Id        = Guid.NewGuid();
         savenode.CreatedAt = DateTime.UtcNow;
         _context.Nodes.Add(savenode);
         _context.SaveChanges();
         return(savenode.Id);
     }
     catch (Exception ex)
     {
         StaticEventHandler.Log(System.Diagnostics.TraceLevel.Error, "error during Update", MethodBase.GetCurrentMethod(), ex);
         return(Guid.Empty);
     }
 }
コード例 #3
0
        public async Task <Guid> Create(PersonCreateModel person, AutorizationLevelCreateModel autorizationLevel)
        {
            try
            {
                if (person == null || autorizationLevel == null)
                {
                    return(Guid.Empty);
                }
                var dbPerson = await _personCreateModelToPersonModelConverter.Map(person).ConfigureAwait(false);

                _context.Persons.Add(dbPerson);
                _context.Autorizations.Add(dbPerson.AutorizationLevel);
                _context.SafeAuthModels.Add(dbPerson.SafeAuthModel);
                _context.SaveChanges();
                return(dbPerson.Id);
            }
            catch (Exception ex)
            {
                StaticEventHandler.Log(System.Diagnostics.TraceLevel.Error, "error during IsAutorized od person", MethodBase.GetCurrentMethod(), ex);
                return(Guid.Empty);
            }
        }