コード例 #1
0
        public async Task <ActionResult> Registration(RegistrationModel model)
        {
            if (ModelState.IsValid)
            {
                if (ChatAppModelExistsName(model.korisnik_korisnicko_ime) == false)
                {
                    ChatAppModel user = new ChatAppModel
                    {
                        korisnik_korisnicko_ime = model.korisnik_korisnicko_ime,
                        korisnik_email          = model.korisnik_email,
                        korisnik_sifra          = model.korisnik_sifra,
                    };
                    _context.Add(user);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Login", "ChatAppModels"));
                }
                else
                {
                    model.ErrorMessage = "Korisnicko ime: " + model.korisnik_korisnicko_ime + " je zauzeto";
                    return(View(model));
                }
            }

            else
            {
                return(View());
            }
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("korisnikID,korisnik_ime,korisnik_korisnicko_ime,korisnik_sifra,korisnik_email,korisnik_logo,korisnik_status")] ChatAppModel chatAppModel)
        {
            if (id != chatAppModel.korisnikID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(chatAppModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChatAppModelExists(chatAppModel.korisnikID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(chatAppModel));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("korisnikID,korisnik_ime,korisnik_korisnicko_ime,korisnik_sifra,korisnik_email,korisnik_logo,korisnik_status")] ChatAppModel chatAppModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chatAppModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(chatAppModel));
        }