Exemple #1
0
        public ActionResult Edit(ApplicationUserViewModel _user)
        {
            var user = userManager.Users.Where(u => u.Id == _user.Id).FirstOrDefault();

            if (ModelState.IsValid)
            {
                try
                {
                    user.UserName             = _user.FirstName;
                    user.FirstName            = _user.FirstName;
                    user.LastName             = _user.LastName;
                    user.Birthday             = _user.Birthday;
                    user.Email                = _user.Email;
                    user.EmailConfirmed       = true;
                    user.NormalizedEmail      = _user.Email.ToUpper();
                    user.NormalizedUserName   = _user.FirstName.ToUpper();
                    user.PhoneNumberConfirmed = true;
                    user.Image                = _user.Image != null?ImageConverter.GetBytes(_user.Image) : user.Image;

                    userManager.UpdateAsync(user).Wait();
                    signInManager.SignInAsync(user, isPersistent: true).Wait();
                    context.SaveChangesAsync().Wait();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(NotFound());
                }
                return(RedirectToAction("List"));
            }
            return(View(_user));
        }
        public async Task <int> AddUserTransactions(Transactions transactions, string user)
        {
            _ctx.Transactions.Add(transactions);
            var result = await _ctx.SaveChangesAsync();

            return(result);
        }