public AccountController(AspFinalDbContext context, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager)
 {
     _context       = context;
     _userManager   = userManager;
     _signInManager = signInManager;
 }
 public BlogController(AspFinalDbContext context, IHostingEnvironment env)
 {
     _context = context;
     _env     = env;
 }
        public void OnException(ExceptionContext filterContext)
        {
            var area = "";//todo....

            var controller = (filterContext.RouteData.Values["controller"] ?? "").ToString();
            var action     = (filterContext.RouteData.Values["action"] ?? "").ToString();

            //səbəbkar erroru tapmaq
            while (filterContext.Exception.InnerException != null)
            {
                filterContext.Exception = filterContext.Exception.InnerException;
            }

            var model = new HandleErrorInfo(filterContext.Exception, controller, action);

            try
            {
                using (var db = new AspFinalDbContext())
                {
                    var entity = new ErrorHistory();
                    if (!string.IsNullOrWhiteSpace(area))
                    {
                        entity.AreaName = area;
                    }
                    if (!string.IsNullOrWhiteSpace(controller))
                    {
                        entity.ControllerName = controller;
                    }
                    if (!string.IsNullOrWhiteSpace(action))
                    {
                        entity.ActionName = action;
                    }

                    if (filterContext.Exception is HttpException)
                    {
                        entity.ErrorCode = (filterContext.Exception as HttpException).GetHttpCode();
                    }
                    else if (filterContext.Exception is SqlException)
                    {
                        entity.ErrorCode    = (filterContext.Exception as SqlException).Number;
                        entity.ErrorMessage = filterContext.Exception.Message;
                    }
                    else
                    {
                        entity.ErrorMessage = filterContext.Exception.Message;
                    }
                    logger.Fatal(entity.ErrorMessage);
                    entity.CreatedDate = DateTime.Now;
                    db.ErrorHistories.Add(entity);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                //logger.Fatal(ex)
            }

            filterContext.Result = new ViewResult
            {
                ViewName = "~/Views/Home/ErrorHistory.cshtml",

                //MasterName = "~/Views/Shared/_Layout.cshtml",
                ViewData = new ViewDataDictionary <HandleErrorInfo>(model),
                TempData = filterContext.Controller.TempData
            };

            filterContext.ExceptionHandled = true;
        }
Exemple #4
0
 public BlogController(AspFinalDbContext context)
 {
     _context = context;
 }
 public AdvertisementController(AspFinalDbContext context)
 {
     _context = context;
 }
 public AdvertisementController(AspFinalDbContext context, IHostingEnvironment env)
 {
     _context = context;
     _env     = env;
 }
 public HomeController(AspFinalDbContext context, RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager)
 {
     _context     = context;
     _userManager = userManager;
     _roleManager = roleManager;
 }
Exemple #8
0
 public AjaxController(AspFinalDbContext context)
 {
     _context = context;
 }