Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("KomentarId,VoziloId,KorisnikId,Korisnik,Opis")] Komentar komentar)
        {
            if (id != komentar.KomentarId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.Update(komentar);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KomentarExists(komentar.KomentarId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VoziloId"] = new SelectList(db.Vozila, "VoziloId", "Kilometraza", komentar.VoziloId);
            return(View(komentar));
        }
        public async Task <IActionResult> Edit(string id, [Bind("Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount,Adresa,Grad,Ime,Prezime,Telefon")] AspNetUser aspNetUser)
        {
            if (id != aspNetUser.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.Update(aspNetUser);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AspNetUserExists(aspNetUser.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(View("Details", id));
            }
            return(View(aspNetUser));
        }
        public async Task <IActionResult> Edit(int id, [Bind("VoziloId,MarkaId,ModelId,TipVozilaId,KorisnikId,Kubikaza,Snaga,Kilometraza,Pogon,Menjac,BrojBrzina,Cena,Slika,SlikaTip,Opis")] Vozilo vozilo, IFormFile odabranaSlika)
        {
            if (id != vozilo.VoziloId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        await odabranaSlika.CopyToAsync(ms);

                        vozilo.Slika = ms.ToArray();
                    }
                    vozilo.SlikaTip = odabranaSlika.ContentType;
                    db.Update(vozilo);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VoziloExists(vozilo.VoziloId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            ViewData["MarkaId"]     = new SelectList(db.Marke, "MarkaId", "Naziv", vozilo.MarkaId);
            ViewData["ModelId"]     = new SelectList(db.Models, "ModelId", "Naziv", vozilo.ModelId);
            ViewData["TipVozilaId"] = new SelectList(db.TipoviVozila, "TipVozilaId", "Naziv", vozilo.TipVozilaId);
            return(View(vozilo));
        }