protected void DeleteStudent_Click(object sender, EventArgs e)
        {
            UserService.IUserService client = new UserService.UserServiceClient();

            client.DeleteUser(Convert.ToInt32(TextBox8.Text));
            Label1.Text = "Student deleted successfully";
        }
示例#2
0
        public bool DeleteUser(int userId)
        {
            var model = new bool();

            using (var client = new UserService.UserServiceClient())
            {
                try
                {
                    client.Open();
                    model = client.DeleteUser(userId);
                    client.Close();
                }

                catch (FaultException <CustomException> customEx)
                {
                    log.Error(customEx.Message);
                    return(false);
                }
                catch (CommunicationException commEx)
                {
                    log.Error(commEx.Message);
                    return(false);
                }
            }
            return(model);
        }
        // GET: User/Delete/5
        public ActionResult Delete(int id)
        {
            ResponseService response = serviceClient.DeleteUser(id);

            if (response.Code == 0)
            {
                return(RedirectToAction("Index", "User"));
            }

            return(View());
        }
        public ActionResult DeleteUser(int UserId)
        {
            UserService.UserServiceClient client = new UserService.UserServiceClient();
            bool res = client.DeleteUser(UserId);

            if (res)
            {
                return(View("CreateUser"));
            }
            else
            {
                return(RedirectToAction("ListofUsers"));
            }
        }