Esempio n. 1
0
      public IEnumerable <WebApplication5.Models.File> Take(int index, int count)
      {
          using (AdventureWorks2019Context db = new AdventureWorks2019Context())
          {
              // получаем объекты из бд и выводим на консоль
              var images = db.Files.Skip(index).Take(count);

              return(images.ToArray());
          }
      }
Esempio n. 2
0
        public void GlobalSetup()
        {
            _conn = new SqlConnection(_connstring);
            _conn.Open();

            var contextOptions = new DbContextOptionsBuilder <AdventureWorks2019Context>()
                                 .UseSqlServer(_connstring)
                                 .Options;

            _dbcontext = new AdventureWorks2019Context(contextOptions);
        }
Esempio n. 3
0
      public IEnumerable <Address> Get200()
      {
          var rng = new Random();

          using (AdventureWorks2019Context db = new AdventureWorks2019Context())
          {
              // получаем объекты из бд и выводим на консоль
              var adresses = db.Addresses.Take(200);

              return(adresses.ToArray());
          }
      }
Esempio n. 4
0
      public async Task <IActionResult> UploadFile(IFormFileCollection _files)
      {
          foreach (IFormFile _file in _files)
          {
              if (_file != null)
              {
                  Models.File file = new Models.File()
                  {
                  };
                  using (AdventureWorks2019Context db = new AdventureWorks2019Context())
                  {
                      db.Files.Add(file);
                      await db.SaveChangesAsync();
                  }

                  string path = "/Files/" + file.Id + System.IO.Path.GetExtension(_file.FileName);



                  using (var fileStream = new FileStream(_applicationEnvironment.WebRootPath + path, FileMode.Create))
                  {
                      await _file.CopyToAsync(fileStream);

                      using (AdventureWorks2019Context db = new AdventureWorks2019Context())
                      {
                          file.Name = _file.FileName;
                          file.Path = path;
                          db.Files.Update(file);
                          await _file.CopyToAsync(fileStream);

                          await db.SaveChangesAsync();
                      }
                  }
              }
          }
          return(Redirect("/fetch-data"));
      }
Esempio n. 5
0
 public ProductController(AdventureWorks2019Context context, ILogger <ProductController> logger)
 {
     _context = context;
     _logger  = logger;
 }
Esempio n. 6
0
 public AdventureWorksRepository(AdventureWorks2019Context context)
 {
     _context = context;
 }
Esempio n. 7
0
 public CurrenciesController(AdventureWorks2019Context context)
 {
     _context = context;
 }
 public EmployeeController(AdventureWorks2019Context context)
 {
     _context = context;
 }
 public ProductController(AdventureWorks2019Context context)
 {
     _context = context;
 }
 public PersonController(AdventureWorks2019Context context)
 {
     _context = context;
 }
Esempio n. 11
0
 public CustomerController(AdventureWorks2019Context context)
 {
     _context = context;
 }