Kayıtlar

Mart, 2019 tarihine ait yayınlar gösteriliyor

Asp.Net Core 2.2 Web Api Client ile CRUD İşlemleri 3

Resim
Yazımızın son kısmına geldik. Şimdi View sayfalarını oluşturalım. Category/Index için View oluşturalım. @model ICollection <AspNetCoreWebApi.Client.Models. Category > @{     ViewData[ "Title" ] = "Index" ; } < div class ="contentBody">     < h1 > Kategoriler </ h1 >     < div id ="table">         < table class ="table ">             < thead class ="thead-dark">                 < tr >                     < th scope ="col"> İsim </ th >                     < th scope ="col"> Durum </ th >                     < th scope ="col"> Düzenle </ th >                      < th scope ="col"> Sil </ th >                 </ tr >             </ thead >

Asp.Net Core 2.2 Web Api Client ile CRUD İşlemleri 2

Oluşturduğumuz ClientManager Controller da nasıl uygulayacağız görelim. İlk önce ProductController düzenleyelim.   public   class   ProductController   :  Controller     {          private   readonly   IProductClientManager  _productClientManager;          private   readonly   ICategoryClientManager  _categoryClientManager;          public  ProductController( IProductClientManager  productClientManager,                                                                                         ICategoryClientManager  categoryClientManager)         {             _productClientManager = productClientManager;             _categoryClientManager = categoryClientManager;             _productClientManager.Url( "https://localhost:44386/api/" ,  "Product" );             _categoryClientManager.Url( "https://localhost:44386/api/" ,  "Category" );         }

Asp.Net Core 2.2 Web Api Client ile CRUD İşlemleri 1

Resim
Kaldığımız yerden devam. Bir önceki yazımda Asp.Net Core 2.2 ile Web Api oluşturmuştuk. Şimdi bu oluşturduğumuz servisi nasıl kullanırız onu göreceğiz. Solution da yeni bir proje ekliyoruz. Asp.NetCoreWepApi.Client isminde empty bir proje oluşturuyoruz. Temel klasörler olan Controllers, Models, Views klasörlerini birde Client işlemleri için ClientManager isimli klasör oluşturalım.

Asp.Net Core ile Proje Çalıştırıldığında Otomatik Veri Tabanı Oluşturma

Merhaba arkadaşlar, Asp.Net projemiz çalıştırıldığında veri tabanımız yok ise nasıl kendiliğinden oluşturulacak ondan bahsedeceğim. Bunun için Asp.Net Core projesinde Startup.cs dosyamıza aşağıdaki kod bloklarını eklememiz gerekiyor. private void InitializeDatabase ( IApplicationBuilder app) {       using ( var scope = app.ApplicationServices.GetService< IServiceScopeFactory >                                               ().CreateScope())             {  scope.ServiceProvider.GetRequiredService< CoreDbContext >().Database.Migrate();             } }

Sıfırdan Asp.Net Core 2.2 Web Api CRUD İşlemleri

Resim
Merhaba arkadaşlar, bugün Visual Studio ortamında Asp.Net Core 2.2 ile Web Api uygulaması yapacağız. Şimdi boş bir Asp.Net Core 2.2 projesi oluşturalım.