public async Task<ActionResult> Edit(UserDetailsViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new ApplicationDbContext())
                {
                    MyUser user = db.Users.Find(model.UserId);

                    user.Id = model.UserId;
                    user.UserName = model.UserName;
                    user.Email = model.EmailAddress;
                    user.EmailConfirmed = model.EmailAddressConfirmed;
                    user.AccessFailedCount = model.AccessFailedCount;
                    user.LockoutEnabled = model.LockoutEnabled;
                    user.LockoutEndDateUtc = model.LockoutEndDate;

                    user.UserDetails.FirstName = model.FirstName;
                    user.UserDetails.LastName = model.LastName;
                    user.UserDetails.Age = model.Age;
                    user.UserDetails.Address = model.Address;
                    user.UserDetails.City = model.City;
                    user.UserDetails.Country = model.Country;

                    MyUserRole currentRole = db.Users.FirstOrDefault(m => m.Id == model.UserId)
                        .Roles.FirstOrDefault();

                    db.Users.FirstOrDefault(m => m.Id == model.UserId)
                        .Roles.Remove(currentRole);
                    db.Users.FirstOrDefault(m => m.Id == model.UserId)
                        .Roles.Add(new MyUserRole { RoleId = int.Parse(model.Role), UserId = model.UserId });

                    db.Entry(user).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    ApplicationUserManager userManager = new ApplicationUserManager(new MyUserStore(new ApplicationDbContext()));

                    // Dodati da se novi password salje ;)

                    await userManager.RemovePasswordAsync(model.UserId);
                    await userManager.AddPasswordAsync(model.UserId, model.Password);
                }
                return RedirectToAction("Index", new { Message = UserMessageId.ChangeUser });
            }

            ViewBag.Roles = new SelectList(db.Roles.AsEnumerable().ToList(),
                "Id", "Name", db.Roles.FirstOrDefault(m => m.Id.ToString() == model.Role));

            ViewBag.Id = new SelectList(db.UserDetails, "Id", "Role", model.Role);
            return View(model);
        }
        // GET: ControlPanel/Users/Details/5
        public async Task<ActionResult> Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            MyUser myUser = await db.Users.FirstOrDefaultAsync(m => m.Id == id);
            if (myUser == null)
            {
                return HttpNotFound();
            }

            var model = new UserDetailsViewModel
            {
                UserId = myUser.Id,
                Role = "",
                UserName = myUser.UserName,
                Password = "",
                EmailAddress = myUser.Email,
                EmailAddressConfirmed = myUser.EmailConfirmed,
                AccessFailedCount = myUser.AccessFailedCount,
                LockoutEnabled = myUser.LockoutEnabled,
                LockoutEndDate = myUser.LockoutEndDateUtc,
                FirstName = myUser.UserDetails.FirstName != null ? myUser.UserDetails.FirstName : "--",
                LastName = myUser.UserDetails.LastName != null ? myUser.UserDetails.LastName : "--",
                Age = myUser.UserDetails.Age,
                Address = myUser.UserDetails.Address != null ? myUser.UserDetails.Address : "--",
                City = myUser.UserDetails.City != null ? myUser.UserDetails.City : "--",
                Country = myUser.UserDetails.Country != null ? myUser.UserDetails.Country : "--"
            };

            return View(model);
        }
        // GET: ControlPanel/Users/Edit/5
        public async Task<ActionResult> Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            MyUser myUser = await db.Users.FirstOrDefaultAsync(m => m.Id == id);
            if (myUser == null)
            {
                return HttpNotFound();
            }
            // ViewBag.Id = new SelectList(db.UserDetails, "UserId", "FirstName", myUser.Id);
            
            var model = new UserDetailsViewModel
            {
                UserId = myUser.Id,
                Role = db.Roles.FirstOrDefault(m => m.Users.FirstOrDefault(n => n.UserId == myUser.Id).RoleId == m.Id).Id.ToString(),
                UserName = myUser.UserName,
                Password = "",
                EmailAddress = myUser.Email,
                EmailAddressConfirmed = myUser.EmailConfirmed,
                AccessFailedCount = myUser.AccessFailedCount,
                LockoutEnabled = myUser.LockoutEnabled,
                LockoutEndDate = myUser.LockoutEndDateUtc,
                FirstName = myUser.UserDetails.FirstName,
                LastName = myUser.UserDetails.LastName,
                Age = myUser.UserDetails.Age,
                Address = myUser.UserDetails.Address,
                City = myUser.UserDetails.City,
                Country = myUser.UserDetails.Country
            };

            ViewBag.Roles = new SelectList(db.Roles.AsEnumerable().ToList(),
                "Id", "Name", db.Roles.FirstOrDefault(m => m.Id.ToString() == model.Role));

            return View(model);
        }