コード例 #1
0
        public IActionResult UpdateUser(string id, [FromBody] User userParam)
        {
            var kod = _userRep.UpdateUser(id, userParam);

            if (!kod)
            {
                return(BadRequest(new { message = "Kullanıcı güncellenemedi.Update" }));
            }
            else
            {
                return(Ok(new { message = "Kullanıcı güncellendi!" }));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserName,IsActive")] CUsers users)
        {
            if (id != users.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string result = await _userRep.AnyUser‍Update(users);

                    if (result != "True")
                    {
                        await _userRep.UpdateUser(users);

                        await _userRep.Save();

                        Success();
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", " اين نام كاربري قبلاً در سيستم ثبت شده است");
                        return(View(users));
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CUsersExists(users.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }