示例#1
0
        // GET: Ad/Create
        // [Internationalization]
        public ActionResult Create()
        {
            _dbContext = new ApplicationDbContext();
            UserAdService userAdService = new UserAdService(_dbContext);
            var           userAdList    = new List <UserAdVM>();

            var manager     = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(_dbContext));
            var currentUser = manager.FindById(User.Identity.GetUserId());

            if (currentUser != null)
            {
                userAdList = userAdService.GetAllUserAds(currentUser.UserName);
            }

            return(View(userAdList));
        }
示例#2
0
        public ActionResult MyAds()
        {
            try
            {
                _dbContext = new ApplicationDbContext();

                // Get the current logged in user id
                string currentUserId = User.Identity.GetUserId();

                UserAdService   userAdService   = new UserAdService(_dbContext);
                CategoryService categoryService = new CategoryService(_dbContext);
                var             userAds         = userAdService.GetAllUserAds(currentUserId);

                ViewBag.UserAds = userAds;

                return(View());
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.InnerException + ex.Message;
                return(View("Error"));
            }
        }