コード例 #1
0
        private async Task DeleteItem(string parent, string name)
        {
            var item = await GetItemAsync(parent, name);

            _appDbContext.Variables.Remove(item);
            await _appDbContext.SaveChangesAsync();
        }
コード例 #2
0
        public async Task AddAsync(EndpointRuleEntity endpointRuleEntity)
        {
            if (String.IsNullOrWhiteSpace(endpointRuleEntity.Name))
            {
                endpointRuleEntity.Name = await GenerateRuleName();
            }

            if (endpointRuleEntity.Order == 0)
            {
                endpointRuleEntity.Order = _appDbContext.EndpointRules.Max(r => r.Order) + 10;
            }

            await _appDbContext.EndpointRules.AddAsync(endpointRuleEntity);

            await _appDbContext.SaveChangesAsync();

            EventDispatcher.DispatchCreatedEvent("EndpointRule", endpointRuleEntity);
        }
コード例 #3
0
ファイル: UnitOfWork.cs プロジェクト: dangdat0906/DoAn
 public async Task SaveChange()
 {
     await _dbContext.SaveChangesAsync();
 }
コード例 #4
0
ファイル: LoginUser.cs プロジェクト: Tsual/PSKcore
        public async Task TryLoginAsync(UserNotFoundReceipt e, IPSKcore service)
        {
            using (APPDbContext db = new APPDbContext())
            {
                bool b_UserVertifyEvent        = false;
                bool b_UserPwdVertifyFailEvent = false;
                bool b_UserNotFoundEvent       = false;

                await Task.Run(() =>
                {
                    string pwd_hash_aes = AssetsController.EncryptwithAppaesobj(PWD_hash);

                    var iuserlist = from t in db.Users
                                    where t.pid == PID
                                    select t;
                    if (iuserlist.Count() == 0)
                    {
                        switch (e)
                        {
                        case UserNotFoundReceipt.Create:
                            User dbuser = new User()
                            {
                                pid = PID,
                                pwd = pwd_hash_aes
                            };
                            db.Entry(dbuser).State = Microsoft.EntityFrameworkCore.EntityState.Added;
                            db.SaveChangesAsync();
                            break;

                        case UserNotFoundReceipt.None:
                            b_UserNotFoundEvent = true;
                            return;
                        }
                    }
                    else
                    {
                        var vertifyuser = iuserlist.ToList()[0];
                        if (vertifyuser.pid != PID || vertifyuser.pwd != pwd_hash_aes)
                        {
                            b_UserPwdVertifyFailEvent = true;
                        }
                    }
                    int UID = (from t in db.Users
                               where PID == t.pid && pwd_hash_aes == t.pwd
                               select t).ToList()[0].ID;

                    var rlist = from t in db.Recordings
                                where t.uid == UID
                                select t;

                    service.Regist(new CurrentUser(rlist, PID, PWD_hash, UID, service));
                    b_UserVertifyEvent = true;
                });



                if (b_UserPwdVertifyFailEvent)
                {
                    UserPwdVertifyFailEvent?.Invoke(this);
                }
                if (b_UserVertifyEvent)
                {
                    UserVertifyEvent?.Invoke(this);
                }
                if (b_UserNotFoundEvent)
                {
                    UserNotFoundEvent?.Invoke(this);
                }
            }
        }
コード例 #5
0
        public async Task Add(TypeDefinition td)
        {
            await _appDbContext.TypeDefinitions.AddAsync(td);

            await _appDbContext.SaveChangesAsync();
        }