Example #1
0
        public async Task <ConfigurationResponse> GetListOfConfigurationAsync()
        {
            DC.ConfigurationResponse configurationResponse1 = new DC.ConfigurationResponse();
            try
            {
                Model.ConfigurationResponse configurationResponse = await _laptopDAL.GetListOfConfigurationAsync();

                configurationResponse1 = _mapper.Map <DC.ConfigurationResponse>(configurationResponse);
            }
            catch (Exception)
            {
            }
            return(configurationResponse1);
        }
Example #2
0
 public async Task <MODEL.ConfigurationResponse> GetListOfConfigurationAsync()
 {
     MODEL.ConfigurationResponse configurationResponse = new MODEL.ConfigurationResponse();
     try
     {
         List <MODEL.Configuration> list = new List <MODEL.Configuration>();
         List <Ram>   rams   = new List <Ram>();
         List <Hdd>   hdds   = new List <Hdd>();
         List <Color> colors = new List <Color>();
         using (var firstConnection = new SqliteConnection(DbConnection.connectionString))
         {
             firstConnection.Open();
             var selectCommand = firstConnection.CreateCommand();
             selectCommand.CommandText =
                 @"
                 SELECT *
                 FROM Ram
             ";
             SqliteDataReader adr = selectCommand.ExecuteReader();
             while (adr.Read())
             {
                 MODEL.Ram ram = new MODEL.Ram();
                 ram.Id    = adr.GetInt32(0);
                 ram.Type  = adr.GetString(1);
                 ram.Price = adr.GetString(2);
                 rams.Add(ram);
             }
             adr.Close();
             selectCommand.CommandText =
                 @"
                 SELECT *
                 FROM Hdd
             ";
             adr = selectCommand.ExecuteReader();
             while (adr.Read())
             {
                 MODEL.Hdd hdd = new MODEL.Hdd();
                 hdd.Id    = adr.GetInt32(0);
                 hdd.Type  = adr.GetString(1);
                 hdd.Price = adr.GetString(2);
                 hdds.Add(hdd);
             }
             adr.Close();
             selectCommand.CommandText =
                 @"
                 SELECT *
                 FROM Color
             ";
             adr = selectCommand.ExecuteReader();
             while (adr.Read())
             {
                 MODEL.Color color = new MODEL.Color();
                 color.Id    = adr.GetInt32(0);
                 color.Type  = adr.GetString(1);
                 color.Price = adr.GetString(2);
                 colors.Add(color);
             }
         }
         configurationResponse.Rams   = rams;
         configurationResponse.Hdds   = hdds;
         configurationResponse.Colors = colors;
     }
     catch (Exception)
     {
     }
     return(await Task.FromResult(configurationResponse));
 }