Пример #1
0
        public void DeleteEmployee()
        {
            int      id = 4;
            Employee updatedEmployee = EmployeesRepository.EmployeesList.FirstOrDefault(emp => emp.Id == id);

            EmployeeRepo.DeleteEmployee(updatedEmployee.Id);
            var EmployeeUpdated = EmployeesRepository.EmployeesList.FirstOrDefault(emp => emp.Id == id);

            Assert.IsNull(EmployeesRepository.EmployeesList.FirstOrDefault(emp => emp.Id == id));
        }
Пример #2
0
        public HttpResponseMessage Delete(Employee e)
        {
            var employee = EmployeesRepository.DeleteEmployee(e);
            HttpResponseMessage responce = Request.CreateResponse(HttpStatusCode.OK, employee);

            return(responce);
        }
Пример #3
0
        public HttpResponseMessage Delete(int id)
        {
            var employees = EmployeesRepository.DeleteEmployee(id);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(response);
        }
Пример #4
0
        protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "view")
            {
                int         index  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row    = gvUsers.Rows[index];
                int         userid = row.Cells[0].Text.ToInt();
                Session.Add("useridForAdminDetails", userid);

                if (userid % 2 == 0)
                {
                    //karmand
                    setEmpRegSeenTrue(userid);
                    Response.Redirect("/Admin/ManageUsers/EmployeeInfo");
                }
                else
                {
                    setUserRegSeenTrue(userid);
                    Response.Redirect("/Admin/ManageUsers/UserInfo");
                }
            }
            if (e.CommandName == "delet")
            {
                int         index  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row    = gvUsers.Rows[index];
                int         userid = row.Cells[0].Text.ToInt();
                Session.Add("useridForAdminDetails", userid);

                if (userid % 2 == 0)
                {
                    //karmandep.DeleteEmployee(userid)ur.DeleteUser(userid)
                    EmployeesRepository ep = new EmployeesRepository();
                    if (ep.DeleteEmployee(userid))
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف انجام شد')", true);//لینک بشه
                        fillGV();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی پیش آمد ، لطفا دوباره امتحان کنید اگر حل نشد با پشتیبانی تماس بگیرید ');", true);
                    }
                    //Response.Redirect("/Admin/ManageUsers/EmployeeInfo");
                }
                else
                {
                    UsersRepository ur = new UsersRepository();

                    if (ur.DeleteUser(userid))
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف انجام شد')", true);//لینک بشه
                        fillGV();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی پیش آمد ، لطفا دوباره امتحان کنید اگر حل نشد با پشتیبانی تماس بگیرید ');", true);
                    }
                    // Response.Redirect("/Admin/ManageUsers/UserInfo");
                }
            }
        }
 public ActionResult Delete(int id)
 {
     repository.DeleteEmployee(id);
     return(RedirectToAction("GetAllRecords"));
 }