protected void ListViewDataBind()
        {
            var profile = new UsersProfiles {
                UserID = UserID
            };

            lvAllProfile.DataSource = profile.GetAllItemsByUserID();
            lvAllProfile.DataBind();
            foreach (ListViewDataItem items in lvAllProfile.Items)
            {
                var lbProfileDefaultLinck = (LinkButton)items.FindControl("lbDefault");
                var lblIsDefault          = (Label)items.FindControl("lblIsDefault");

                var hlProfileChangeLink = (HyperLink)items.FindControl("hlChange");
                var hfStatus            = (HiddenField)items.FindControl("hfStatus");
                var lbDelete            = (LinkButton)items.FindControl("lbDelete");

                if (lblIsDefault.Text == "✔")
                {
                    lbProfileDefaultLinck.Visible = false;
                }

                //еслистатус не "Активен"-запрещаемредактировать профиль
                if (hfStatus.Value == "1" || hfStatus.Value == "3")
                {
                    hlProfileChangeLink.Visible = false;
                    lbDelete.Visible            = false;
                }
            }
        }
Exemple #2
0
        public void GetProfilesJSON()
        {
            if (ApiMethods.IsApiAuthRequest())
            {
                var js           = new JavaScriptSerializer();
                var userIdString = HttpContext.Current.Request.Headers["userid"];
                if (String.IsNullOrEmpty(userIdString))
                {
                    ApiMethods.ReturnNotAuth();
                }
                var profiles = new UsersProfiles {
                    UserID = Convert.ToInt32(userIdString)
                };
                var allProfilesDS = profiles.GetAllItemsByUserID();
                var allCityList   = new List <AllProfileResult>();
                foreach (DataRow row in allProfilesDS.Tables[0].Rows)
                {
                    string fioOrCompanyName;
                    if (String.IsNullOrEmpty(row["CompanyName"].ToString()))
                    {
                        fioOrCompanyName = row["FirstName"] + " " + row["LastName"];
                    }
                    else
                    {
                        fioOrCompanyName = row["CompanyName"].ToString();
                    }

                    var iDPlusType = row["TypeID"].ToString() + row["ID"];

                    allCityList.Add(new AllProfileResult {
                        Name = fioOrCompanyName, ID = iDPlusType
                    });
                }
                Context.Response.ContentType = "application/json; charset=UTF-8";
                var responceBody = js.Serialize(allCityList);
                Context.Response.Write(responceBody);
                ApiMethods.LoggingRequest("GetProfilesJSON",
                                          "UserProileAPI",
                                          "UserAPI",
                                          null,
                                          responceBody.Length,
                                          Convert.ToInt32(HttpContext.Current.Request.Params["userid"]),
                                          HttpContext.Current.Request.Params["apikey"]);
            }
            else
            {
                ApiMethods.ReturnNotAuth();
            }
        }