示例#1
0
        public void Add(WebHookSession session)
        {
            var model      = WebHookSessionModel.FromRepositoryType(session);
            var sql        = @"
                INSERT INTO WebHookSessionModels
                (
                  Computer_Id,
                  LastPing,
                  Token
                )
                VALUES
                (
                  @Computer_Id,
                  @LastPing,
                  @Token
                )

                SELECT CAST(IDENT_CURRENT('WebHookSessionModels') as int)
            ";
            var parameters = new
            {
                model.Computer_Id,
                model.LastPing,
                model.Token,
            };

            var id = _connection.QuerySingle <int>(sql, parameters);

            session.SetId(id);
        }
示例#2
0
        public WebHookSession ToRepositoryType(IRepositoryModelCache cache, IComputerRepository computerRepository)
        {
            var result = new WebHookSession(
                computer: ComputerModel.ToRepositoryType(cache, Computer_Id, computerRepository),
                id: Id,
                lastPing: LastPing,
                token: Token
                );

            cache?.Set(result.Id, result);

            return(result);
        }
示例#3
0
        public static WebHookSessionModel FromRepositoryType(WebHookSession repositoryModel)
        {
            if (repositoryModel == null)
            {
                return(null);
            }

            var result = new WebHookSessionModel
            {
                Computer_Id = repositoryModel.Computer.Id,
                Id          = repositoryModel.Id,
                LastPing    = repositoryModel.LastPing,
                Token       = repositoryModel.Token,
            };

            return(result);
        }
示例#4
0
 public void Add(WebHookSession session)
 {
     _webHookSessionRepository.Add(session);
 }