Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("TellerId,FirstName,LastName,userEmail,userPassword,userConfirmedPassword")] Teller teller)
        {
            if (id != teller.TellerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teller);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TellerExists(teller.TellerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teller));
        }
        public async Task <IActionResult> EditAccount(CustomerEditViewModel model)
        {
            //var user = await userManager.GetUserAsync(User);

            //            if (model.userEmail != user.Email)
            //          {
            //            return NotFound();
            //      }
            Customer customer = new Customer
            {
                FirstName  = model.FirstName,
                LastName   = model.LastName,
                StreetName = model.StreetName,
                City       = model.City,
                Parish     = model.Parish,
                Country    = model.Country,
            };

            var appuser = new AppUser
            {
                userFirstName  = model.FirstName,
                userLastName   = model.LastName,
                userStreetName = model.StreetName,
                userCity       = model.City,
                userParish     = model.Parish,
                userCountry    = model.Country
            };

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    _context.Update(appuser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(NotFound());
                }
            }
            return(View(customer));
        }
Exemple #3
0
        public async Task <IActionResult> EditAccount(int id, [Bind("UserId,FirstName,LastName,StreetName,City,Parish,Country,userEmail,userPassword,userConfirmedPassword,AccountNumber,CardNumber,AccountType,Balance")] Customer customer)
        {
            if (id != customer.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    /*
                     * var appuser = new AppUser
                     * {
                     *  userFirstName = customer.FirstName,
                     *  userLastName = customer.LastName,
                     *  userStreetName = customer.StreetName,
                     *  userCity = customer.City,
                     *  userParish = customer.Parish,
                     *  userCountry = customer.Country,
                     *  Email = customer.userEmail
                     * };
                     * var cust = await _context.Customer.FindAsync(id);
                     *
                     * //var user = await userManager.FindByEmailAsync(customer.userEmail);
                     * if (cust.userEmail == appuser.Email)
                     * {
                     *  _context.Update(appuser);
                     *
                     *  var Use = cust.userEmail.Where(r => r.Equals(customer.userEmail)).ToList()
                     *      .ForEach(c => { c.userCountry = customer.Country});
                     *
                     *      //Rows.SelectMany(r => r.Columns)
                     *
                     * //.Where(c => c.Email.ToLower().Equals(customer.userEmail));
                     *  foreach (var col in Use)
                     *  {
                     *      //col.IsUpdated = true;
                     *      col
                     *  }
                     *
                     * }*/

                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }