RestSharp kullanarak fake apiden Kendi apime verileri çektim sonrasında mvc den api deki verileri restsharp ile çekmeye çalıştım fakat View de listelemeye çalışırken hata alıyorum
buradan karışık oluyor özelden projeyi de gönderebilirim yardımcı olabilecek olana
public class ProductViewModel
{ public int id { get; set; }
public string title { get; set; }
public string description { get; set; }
public int price { get; set; }
public double discountPercentage { get; set; }
public double rating { get; set; }
public int stock { get; set; }
public string brand { get; set; }
public string category { get; set; }
public string thumbnail { get; set; }
public List<string> images { get; set; } }
}
public class RootViewModel
{ public List<ProductViewModel> Products { get; set; }
public int total { get; set; } public int skip { get; set; }
public int limit { get; set; } }- public interface IWebProductClient
- { Task<ProductViewModel> GetProductById(int id);
- Task<List<ProductViewModel>> GetAllProduct();
- Task<RootViewModel> Create(RootViewModel rootViewModel);
- Task<RootViewModel> Update(RootViewModel rootViewModel);
Aldığım Hata :
Error : An unhandled exception occurred while processing the request. InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Collections.Generic.List1[DummyShop.Service.ViewModel.ProductViewModel],System.Runtime.CompilerServices.IAsyncStateMachine]', but this ViewDataDictionary instance requires a model item of type 'System.Collections.Generic.List1[DummyShop.Service.ViewModel.ProductViewModel]'.