예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryID,CategoryCode,CategoryName")] Category category)
        {
            if (id != category.CategoryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.CategoryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("UserID,FirstName,LastName,UserLogin,Email,Phone,ReceiveEmails")] User user, string userRoles)
        {
            if (id != user.UserID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    user.UserLogin = user.UserLogin.ToUpper();
                    _context.Update(user);
                    await _context.SaveChangesAsync();

                    // add user roles
                    UpdateUserRoles(user, userRoles);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.UserID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ModelState is not valid
            return(RedirectToAction(nameof(Edit)));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("FundID,FundCode,FundDescription")] Fund fund)
        {
            if (id != fund.FundID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fund);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FundExists(fund.FundID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fund));
        }