private void BindEntityType()
        {
            AdminSVCs    _obj          = new AdminSVCs();
            DropDownList ddlEntityType = (DropDownList)frmUserdetail.FindControl("ddlEntityType");

            ddlEntityType.DataSource     = _obj.GetEntityType();
            ddlEntityType.DataValueField = "EnityTypeID";
            ddlEntityType.DataTextField  = "EntityTypeName";
            ddlEntityType.DataBind();
        }
        private void FillEntityDDL()
        {
            AdminSVCs    _obj          = new AdminSVCs();
            DropDownList ddlEntity     = (DropDownList)frmUserdetail.FindControl("ddlEntity");
            DropDownList ddlEntityType = (DropDownList)frmUserdetail.FindControl("ddlEntityType");


            DC_EntityDetails _ed = new DC_EntityDetails();

            _ed.EntityTypeID = Convert.ToInt32(ddlEntityType.SelectedValue);
            var reslut = _obj.GetEntity(_ed);

            ddlEntity.DataSource     = reslut;
            ddlEntity.DataValueField = "EntityID";
            ddlEntity.DataTextField  = "EntityName";
            ddlEntity.DataBind();
            ddlEntity.Items.Insert(0, new ListItem {
                Selected = true, Text = "-Select-", Value = "0"
            });
        }
        protected void grdListOfUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            MDMSVC.DC_Message _msg = new DC_Message();


            if (e.CommandName == "Select")
            {
                dvMsg.Style.Add("display", "none");
                frmUserdetail.ChangeMode(FormViewMode.Edit);
                Guid userId = Guid.Parse(e.CommandArgument.ToString());
                using (var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())))
                {
                    var            user         = userManager.FindById(Convert.ToString(userId));
                    IList <string> lstroleNames = userManager.GetRoles(Convert.ToString(userId));

                    Users_Contract userC = new Users_Contract();
                    userC.Email   = user.Email;
                    userC.Manager = Guid.Empty;
                    List <Users_Contract> uc = new List <Users_Contract>();
                    uc.Add(userC);

                    //Set FormView to update

                    frmUserdetail.DataSource = uc;
                    frmUserdetail.DataBind();
                    BindManager();

                    TextBox      txtEmail      = (TextBox)frmUserdetail.FindControl("txtEmail");
                    DropDownList ddlManager    = (DropDownList)frmUserdetail.FindControl("ddlManager");
                    DropDownList ddlEntityType = (DropDownList)frmUserdetail.FindControl("ddlEntityType");
                    DropDownList ddlEntity     = (DropDownList)frmUserdetail.FindControl("ddlEntity");

                    txtEmail.ReadOnly = true;
                    txtEmail.Text     = user.Email;
                    //Get extra user details like managerid,entitytypeid,entityid
                    BindEntityType();
                    DC_UserEntity _userdetails = new DC_UserEntity();
                    _userdetails.UserID = Guid.Parse(user.Id);
                    AdminSVCs _obj   = new AdminSVCs();
                    var       result = _obj.GetUserEntityDetails(_userdetails);
                    if (result != null)
                    {
                        ddlManager.SelectedValue    = Convert.ToString(result.ManagerID);
                        ddlEntityType.SelectedValue = Convert.ToString(result.EntityTypeID);
                        if (result.EntityTypeID == 1)
                        {
                            ddlEntity.Items.Clear();
                            ddlEntity.Enabled = false;
                        }
                        else
                        {
                            FillEntityDDL();
                            ddlEntity.SelectedValue = Convert.ToString(result.EntityID);
                        }
                    }

                    //Set role grid
                    BindRole();
                    foreach (GridViewRow row in grdRoles.Rows)
                    {
                        if (row.RowType == DataControlRowType.DataRow)
                        {
                            string strRole = Convert.ToString(row.Cells[1].Text);
                            if (lstroleNames.Contains(strRole))
                            {
                                CheckBox chkRow = (CheckBox)(row.Cells[2].FindControl("chkAddRole"));
                                chkRow.Checked = true;
                            }
                        }
                    }
                }
            }
            else if (e.CommandName.ToString() == "SoftDelete")
            {
                Guid userId = Guid.Parse(e.CommandArgument.ToString());
                _msg = _objAdminSVCs.UserSoftDelete(new MDMSVC.DC_UserDetails()
                {
                    Userid    = Convert.ToString(userId),
                    IsActive  = false,
                    Edit_Date = DateTime.Now,
                    Edit_User = System.Web.HttpContext.Current.User.Identity.Name
                });
                if (Convert.ToInt32(_msg.StatusCode) == Convert.ToInt32(BootstrapAlertType.Success))
                {
                    intPageIndex = (String.IsNullOrEmpty(grdListOfUsers.PageIndex.ToString()) ? 0 : grdListOfUsers.PageIndex);
                    RefreshControls();
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "User has been inactive successfully", BootstrapAlertType.Success);
                }
                else
                {
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, _msg.StatusMessage, (BootstrapAlertType)_msg.StatusCode);
                }
            }
            else if (e.CommandName.ToString() == "UnDelete")
            {
                Guid userId = Guid.Parse(e.CommandArgument.ToString());
                _msg = _objAdminSVCs.UserSoftDelete(new MDMSVC.DC_UserDetails()
                {
                    Userid    = Convert.ToString(userId),
                    IsActive  = true,
                    Edit_Date = DateTime.Now,
                    Edit_User = System.Web.HttpContext.Current.User.Identity.Name
                });
                if (Convert.ToInt32(_msg.StatusCode) == Convert.ToInt32(BootstrapAlertType.Success))
                {
                    intPageIndex = (String.IsNullOrEmpty(grdListOfUsers.PageIndex.ToString()) ? 0 : grdListOfUsers.PageIndex);
                    RefreshControls();
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "User has been retrived successfully", BootstrapAlertType.Success);
                }
                else
                {
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, _msg.StatusMessage, (BootstrapAlertType)_msg.StatusCode);
                }
            }
        }