예제 #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,UserName,Password,PasswordSalt,IsActive,CreateDate")] Users users)
        {
            if (id != users.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(users);
                    await _context.SaveChangesAsync();

                    _cache.Remove(_userListCacheKey);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersExists(users.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
예제 #2
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("Id,AreaName,AreaCaption,ControllerName,ControllerCaption,ActionName,ActionCaption,ActionType")] Permissions permissions)
        {
            //if (id != permissions.Id)
            //{
            //    return NotFound();
            //}

            var fadActionResult = new FadActionResult {
                IsSuccess = true
            };

            if (ModelState.IsValid)
            {
                try
                {
                    //int orginalId = Convert.ToInt32(EncyrptionUtility.Decrypt(id));
                    permissions.Id = id;

                    _context.Update(permissions);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    fadActionResult.IsSuccess = false;

                    return(Json(fadActionResult));

                    if (!PermissionsExists(permissions.Id))
                    {
                        return(Json(fadActionResult));
                    }
                    else
                    {
                        throw;
                    }
                }
                fadActionResult.Message = "با موفقیت بروزرسانی شد";
                return(Json(fadActionResult));
            }

            fadActionResult.IsSuccess = false;
            fadActionResult.Message   = "اطلاعات ارسالی صحیح نمی باشد";
            return(Json(fadActionResult));
        }