示例#1
0
        public DC_UserEntity GetUserEntityDetails(DC_UserEntity UE)
        {
            object result = null;

            ServiceConnection.MDMSvcProxy.PostData(ConfigurationManager.AppSettings["Admin_GetUserEntityDetails"], UE, typeof(MDMSVC.DC_UserEntity), typeof(MDMSVC.DC_UserEntity), out result);
            return(result as DC_UserEntity);
        }
        private bool UpdateEntityTagging(ApplicationUser user, string status)
        {
            try
            {
                if (user != null)
                {
                    DropDownList ddlEntityType = (DropDownList)frmUserdetail.FindControl("ddlEntityType");
                    DropDownList ddlEntity     = (DropDownList)frmUserdetail.FindControl("ddlEntity");
                    DropDownList ddlManager    = (DropDownList)frmUserdetail.FindControl("ddlManager");


                    DC_UserEntity _obj = new DC_UserEntity();
                    _obj.UserID        = Guid.Parse(user.Id);
                    _obj.EntityTypeID  = Convert.ToInt32(ddlEntityType.SelectedValue);
                    _obj.ManagerID     = Convert.ToString(ddlManager.SelectedValue);
                    _obj.ApplicationId = Guid.Parse(ddlApplilcation.SelectedValue);
                    if (ddlEntity.SelectedValue != string.Empty)
                    {
                        _obj.EntityID = Guid.Parse(ddlEntity.SelectedValue);
                    }
                    else
                    {
                        _obj.EntityID = Guid.Empty;
                    }
                    if (status == "add")
                    {
                        _obj.Create_User = System.Web.HttpContext.Current.User.Identity.Name;
                        _obj.Create_Date = DateTime.Now;
                    }
                    else if (status == "update")
                    {
                        _obj.Edit_User = System.Web.HttpContext.Current.User.Identity.Name;
                        _obj.Edit_Date = DateTime.Now;
                    }
                    var result = _objAdminSVCs.AddUpdateUserEntity(_obj);
                    if (result != null)
                    {
                        if (result.StatusCode == ReadOnlyMessageStatusCode.Success)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            { throw; }
        }
        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);
                }
            }
        }