This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<br /> | |
<strong>Container Info: </strong> <br /> @ViewBag.ContainerName | |
<br /><br /> | |
<strong>List of Blobs:</strong> | |
<table> | |
@if (ViewBag.Blobs.Count > 0) | |
{ | |
@foreach (var item in @ViewBag.Blobs) | |
{ | |
<tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public async Task<IActionResult> UploadFiles(IList<IFormFile> files) | |
{ | |
long size = 0; | |
try | |
{ | |
foreach (var file in files) | |
{ | |
var filename = ContentDispositionHeaderValue | |
.Parse(file.ContentDisposition) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IActionResult Index() | |
{ | |
ViewBag.ContainerName = "Name: " + cloudblobcontainer.Name; | |
GetBlobs(); | |
return View(); | |
} | |
private void GetBlobs() | |
{ | |
ViewBag.Blobs = cloudblobcontainer.ListBlobs().ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public HomeController(IHostingEnvironment env) | |
{ | |
storageCredentials = new StorageCredentials("account-name", "keyvalue"); | |
cloudStorage = new CloudStorageAccount(storageCredentials, true); | |
cloudBlob = cloudStorage.CreateCloudBlobClient(); | |
cloudblobcontainer = cloudBlob.GetContainerReference("movies"); | |
this.hostingEnv = env; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private StorageCredentials storageCredentials; | |
private CloudStorageAccount cloudStorage; | |
private CloudBlobClient cloudBlob; | |
private CloudBlobContainer cloudblobcontainer; | |
private IHostingEnvironment hostingEnv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
private PersonDBContext context; | |
public HomeController(PersonDBContext context) | |
{ | |
this.context = context; | |
} | |
public IActionResult Index() | |
{ | |
var data = context.Person.ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"ConnectionStrings": { | |
"Data": { | |
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-SampleMVCEF-6bca4509-df99-46ec-bf2a-01ca5568da0e;Trusted_Connection=True;MultipleActiveResultSets=true", | |
"SampleConnection": "Server=(localdb)\\mssqllocaldb;Database=PersonDB;Integrated Security=true;Trusted_Connection=True;MultipleActiveResultSets=true" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonDBContext : DbContext | |
{ | |
public PersonDBContext(DbContextOptions<PersonDBContext> options) : base(options) | |
{ | |
} | |
public DbSet<Person> Person { get; set; } | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ | |
base.OnConfiguring(optionsBuilder); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public int Age { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddDbContext<PersonDBContext>(options => | |
options.UseSqlServer(Configuration.GetConnectionString("Data:SampleConnection"))); |