Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HomeController : Controller
- {
- //
- // GET: /Home/
- public ActionResult Index()
- {
- AnasayfaViewModel avm = new AnasayfaViewModel();
- try
- {
- Category CategoryBL = new Category();
- Campaign CampaignBL=new Campaign();
- Product ProductBL = new Product();
- avm.Kategoriler = CategoryBL.GetCategories();
- avm.Kampanyalar = CampaignBL.GetCampaing();
- avm.EnSonUrunler = ProductBL.GetLatestProducts(10);//son 10 ürün
- avm.Success = true; //şu ana kadar bir exception oluşmadı.
- }
- catch (Exception ex) //Burarada Exception class'indan türetilen kendi exception class'imizi kullanarak kolaylıkla log'lama da yapabiliriz
- {
- avm.Success = false; //view tarafında durumu kontrol edip sayfada işlem yapmıyoruz
- avm.Message = ex.Message; // kullanıcıya hatayı bildiriyoruz, istersek kendi mesajımızı da yazabiliriz.
- }
- return View(avm);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement