Exemplo n.º 1
0
        public async Task <IActionResult> UpdateProfilImage(ProfilDetaljnoVM model, IFormFile SlikaURL)
        {
            int             id   = int.Parse(_signInManager.GetUserId(User));
            ApplicationUser user = _context.Users.Find(id);

            user.Slika = SlikaURL.FileName;
            var filePath = Path.Combine(_he.WebRootPath + "\\images\\Profilne", SlikaURL.FileName);

            SlikaURL.CopyTo(new FileStream(filePath, FileMode.Create));

            _context.SaveChanges();
            _context.Dispose();

            var values = new RouteValueDictionary();

            values.Add("msg", "ok");
            return(RedirectToAction(nameof(Index), values));
        }
Exemplo n.º 2
0
        public IActionResult Index(string msg)
        {
            int id = int.Parse(_signInManager.GetUserId(User));
            ProfilDetaljnoVM model = _context.Users.Where(x => x.Id == id).Select(x => new ProfilDetaljnoVM
            {
                Adresa        = x.Adresa,
                BrTelefona    = x.PhoneNumber,
                DatumRodjenja = x.DatumRodjenja,
                Email         = x.Email,
                Grad          = x.Grad.Naziv,
                Ime           = x.Ime,
                Username      = x.UserName,
                JMBG          = x.JMBG,
                Prezime       = x.Prezime,
                Slika         = x.Slika,
                Spol          = x.Spol
            }).FirstOrDefault();

            if (msg != null)
            {
                model.Notification = msg;
            }
            if (model.Slika == null)
            {
                model.Slika = Path.Combine("\\images\\Profilne\\65U.svg");
            }
            else
            {
                model.Slika = Path.Combine("\\images\\Profilne", model.Slika);
            }

            List <SelectListItem> listagradova = new List <SelectListItem>();

            listagradova.AddRange(_context.Grad.Select(x => new SelectListItem()
            {
                Value = x.GradID.ToString(),
                Text  = x.Naziv
            }));

            model.Gradovi = listagradova;
            return(View(model));
        }
Exemplo n.º 3
0
        public IActionResult UpdateProfil(ProfilDetaljnoVM model)
        {
            int             id = int.Parse(_signInManager.GetUserId(User));
            ApplicationUser ap = db.Users.Find(id);

            ap.Adresa        = model.Adresa;
            ap.Email         = model.Email;
            ap.UserName      = model.Username;
            ap.PhoneNumber   = model.BrTelefona;
            ap.Ime           = model.Ime;
            ap.Prezime       = model.Prezime;
            ap.Spol          = model.Spol;
            ap.DatumRodjenja = model.DatumRodjenja;
            ap.JMBG          = model.JMBG;
            ap.GradID        = model.GradID;

            db.SaveChanges();
            db.Dispose();


            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 4
0
        public IActionResult ProfilUrediSnimi(ProfilDetaljnoVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(Index)));
            }

            int id   = int.Parse(_signInManager.GetUserId(User));
            var user = _context.Users.Find(id);

            user.Adresa        = model.Adresa;
            user.Email         = model.Email;
            user.UserName      = model.Username;
            user.PhoneNumber   = model.BrTelefona;
            user.Ime           = model.Ime;
            user.Prezime       = model.Prezime;
            user.Spol          = model.Spol;
            user.DatumRodjenja = model.DatumRodjenja;
            user.JMBG          = model.JMBG;
            user.GradID        = model.GradID;

            _context.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }