public async Task <int> Crud_Environment(EnvironmentsModel model)
 {
     using (var _dbContext = new DataBaseContext()) {
         object[] parameters = new object[] { model.Id, model.Environment, model.HostName, model.EndPointKey, model.Username, model.Password, model.IsActive, model.Score };
         return(await _dbContext.ExecuteNonQueryAsync("sp_CRUD_Environment", parameters));
     }
 }
        public async Task <List <EnvironmentsModel> > GetEnvironments()
        {
            List <EnvironmentsModel> _environments = new List <EnvironmentsModel>();

            try
            {
                using (var _dbContext = new DataBaseContext())
                {
                    object[] parameters = new object[] { };
                    var      _dReader   = await _dbContext.ExecuteReaderAsync("sp_GetEnvironments", parameters);

                    while (_dReader.Read())
                    {
                        var environments = new EnvironmentsModel();
                        environments.Id          = Convert.ToInt32(_dReader[0]);
                        environments.Environment = _dReader[1].ToString();
                        environments.HostName    = _dReader[2].ToString();
                        environments.EndPointKey = _dReader[3].ToString();
                        environments.Username    = _dReader[4].ToString();
                        environments.Password    = _dReader[5].ToString();
                        environments.IsActive    = Convert.ToInt32(_dReader[6]);
                        environments.Score       = _dReader[7].ToString();
                        _environments.Add(environments);
                    }
                }
            }
            catch (Exception)
            {
                _environments = new List <EnvironmentsModel>();
            }
            return(_environments);
        }
Esempio n. 3
0
        private void SerializeBoxEnvironmentFile(EnvironmentsModel environments)
        {
            var path       = GetBoxEnvironmentFilePath();
            var serializer = new JsonSerializer();

            using (StreamWriter file = File.CreateText(path))
            {
                serializer.Serialize(file, environments);
            }
        }
Esempio n. 4
0
        private string CreateOrReturnBoxEnvironmentFile()
        {
            var boxHome = _boxHome.GetBoxHomeDirectoryPath();
            var path    = Path.Combine(boxHome, _boxHomeEnvironmentsFileName);

            if (!File.Exists(path))
            {
                File.Create(path).Dispose();
                var emptyEnv = new EnvironmentsModel();
                SerializeBoxEnvironmentFile(emptyEnv);
                return(path);
            }
            else
            {
                return(path);
            }
        }
        public async Task <IHttpActionResult> crud_environment(EnvironmentsModel model)
        {
            var result = await services.Crud_Environment(model);

            return(Ok(result));
        }