示例#1
0
        public async Task <IActionResult> Index()
        {
            ViewBag.Oglasi = await _oglasiServis.SviOglasi();

            ViewBag.Kategorije = await _oglasiServis.SveKategorije();

            return(View());
        }
示例#2
0
        public async Task <IActionResult> Index(Pretraga pretraga)
        {
            var kategorije = await _oglasiServis.SveKategorije();

            var potkategorije = await _oglasiServis.SvePotkategorije();

            var oglasipotkategorije = await _oglasiServis.SviOglasiPotkategorije();

            //var oglasi = await _oglasiServis.SviOglasi();
            foreach (var kategorija in kategorije)
            {
                foreach (var potkategorija in potkategorije)
                {
                    if (kategorija.Id == potkategorija.KategorijeId)
                    {
                        kategorija.Potkategorije.Add(potkategorija);
                    }
                    foreach (var oglaspotkategorija in oglasipotkategorije)
                    {
                        if (potkategorija.Id == oglaspotkategorija.PotkategorijeId)
                        {
                            potkategorija.OglasiPotkagorije.Add(oglaspotkategorija);
                        }
                    }
                }
            }
            ViewBag.Kategorije = kategorije;
            return(View(pretraga));
        }
示例#3
0
        public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Username, Email = model.Email
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=532713
                    // Send an email with this link
                    //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
                    //var callbackUrl = Url.Action(nameof(ConfirmEmail), "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
                    //await _emailSender.SendEmailAsync(model.Email, "Confirm your account",
                    //    $"Please confirm your account by clicking this link: <a href='{callbackUrl}'>link</a>");
                    await _signInManager.SignInAsync(user, isPersistent : false);

                    _logger.LogInformation(3, "User created a new account with password.");
                    return(RedirectToAction("UserHome"));
                }
                AddErrors(result);
            }

            ViewBag.Kategorije = await _oglasiServis.SveKategorije();

            // If we got this far, something failed, redisplay form
            return(View());
        }
示例#4
0
        public async Task <IActionResult> Index()
        {
            ViewBag.Gradovi = await _oglasiServis.SviGradovi();

            var oglasi = await _oglasiServis.SviOglasi();

            var kategorije = await _oglasiServis.SveKategorije();

            foreach (var grad in ViewBag.Gradovi)
            {
                foreach (var oglas in oglasi)
                {
                    if (oglas.Grad.Id == grad.Id)
                    {
                        grad.Oglasi.Add(oglas);
                    }
                }
            }
            ViewBag.Kategorije = kategorije;
            return(View());
        }