Beispiel #1
0
        public ActionResult DeleteUser(int uid)
        {
            JsonViewResult jsonViewResult = new JsonViewResult()
            {
                Success = false
            };
            int userJokesCount = jokeLogic.JokesCount(uid);
            var userinfo       = userLogic.GetUserInfo(uid);

            if (userinfo.IsAdmin > 0)
            {
                jsonViewResult.Success = false;
                jsonViewResult.Message = "不能删除管理员";
                return(Json(jsonViewResult, JsonRequestBehavior.AllowGet));
            }
            if (userJokesCount > 0)
            {
                jsonViewResult.Success = false;
                jsonViewResult.Message = "该会员已发表过笑话,不能删除该会员!";
            }
            else
            {
                jsonViewResult.Success = userLogic.DeleteUser(uid);
            }
            return(Json(jsonViewResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        //Delete User But not used.
        public JsonResult DeleteUser(String empid)
        {
            int Id = Convert.ToInt32(empid);

            if (UserBL.DeleteUser(Id) > 0)
            {
                return(Json(new { isError = "F", message = "Data Deleted Successfully." }));
            }
            else
            {
                return(Json(new { isError = "T", message = "Error. Could Not Delete Data" }));
            }
        }
 public IHttpActionResult Delete([FromUri] string username)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         UserBusinessLogic.DeleteUser(username);
         return(Ok("User deleted"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Beispiel #4
0
        public string DeleteUser(int Id)
        {
            string msg;

            if (UserBL.DeleteUser(Id) > 0)
            {
                msg = "Data Deleted Successfully";
            }
            else
            {
                msg = "Error. Could Not Delete Data";
            }

            return(msg);
        }
Beispiel #5
0
        public void IntegrationTest_ExpectedParameters_Ok()
        {
            UserDataAccess    userDA = new UserDataAccess();
            UserBusinessLogic userBL = new UserBusinessLogic(userDA);
            User user1 = Utils.CreateUserForTest();
            User user2 = Utils.CreateUserForTest();

            userBL.AddUser(user1);
            userBL.AddUser(user2);

            user2.Name = "Other name";
            userBL.ModifyUser(user2);

            userBL.DeleteUser(user1.Username);

            User         user2Obtained = userBL.GetUser(user2.Username);
            IList <User> usersObtained = userBL.GetUsers();

            Assert.IsTrue(!usersObtained.Contains(user1) && usersObtained.Contains(user2Obtained));
        }
Beispiel #6
0
 public ActionResult Delete(int id)
 {
     UserBusinessLogic.DeleteUser(id);
     return(RedirectToAction(""));
 }