/// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private bool UserIsAdmin()
    {
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _userId;
        objUserInfo.TributeId = _tributeId;
        objUserInfo.TypeId = _photoId;
        objUserInfo.TypeName = TYPE_NAME;

        if (_userId != 0)
        {
            if (IsUserAdmin(objUserInfo))
            {
                objUserInfo.IsAdmin = true;
                isAdmin = true;
            }
            else if (IsUserOwner(objUserInfo))
            {
                objUserInfo.IsOwner = true;
                isAdmin = false;
            }
        }
        else
        {
            objUserInfo.IsAdmin = false;
            objUserInfo.IsOwner = false;
            isAdmin = false;
        }
        StateManager objStateManager = StateManager.Instance;
        objStateManager.Add("UserAdminOwnerInfo_ManagePhoto", objUserInfo, StateManager.State.Session);
        return isAdmin;
    }
    /// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private void UserIsAdminOrOwner()
    {
        if (objTribute != null)
        {
            if (objTribute.TributeId > 0)
            {
                _tributeId = objTribute.TributeId;
            }
        }
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _userId;
        objUserInfo.TributeId = _tributeId;
        if (_mode == PAGE_MODE_ADD_PHOTOS)
            objUserInfo.TypeName = TYPE_NAME_ADD_PHOTOS;
        else
            objUserInfo.TypeName = TYPE_NAME_CREATE_ALBUM;

        if (IsUserAdmin(objUserInfo))
            objUserInfo.IsAdmin = true;
        else
            objUserInfo.IsAdmin = false;

        isUserAdmin = objUserInfo.IsAdmin;

        StateManager objStateManager = StateManager.Instance;
        objStateManager.Add("UserAdminOwnerInfo_AddPhotoAlbum", objUserInfo, StateManager.State.Session);
        Session["PhotoAlbumobjUserInfo"] = objUserInfo;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private bool UserIsAdminOrOwner()
    {
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _userId;
        objUserInfo.TributeId = _tributeId;
        objUserInfo.TypeId = photoAlbumId;
        objUserInfo.TypeName = TYPE_NAME;

        if (_userId != 0)
        {
            bool isUserAdmin = IsUserAdmin(objUserInfo);
            bool isUserOwner = IsUserOwner(objUserInfo);

            objUserInfo.IsAdmin = isUserAdmin;
            objUserInfo.IsOwner = isUserOwner;
            isAdmin = isUserAdmin;
        }
        else
        {
            objUserInfo.IsAdmin = false;
            isAdmin = false;
        }
        StateManager objStateManager = StateManager.Instance;
        objStateManager.Add("UserAdminInfo_PhotoAlbum", objUserInfo, StateManager.State.Session);
        return isAdmin;
    }
        public void IsUserOwnerTest()
        {
            UserInfoManager target = new UserInfoManager(); // TODO: Initialize to an appropriate value
            //UserAdminOwnerInfo objUserInfo = null; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
            int UserId = InsertDummyUser("tj_op");
            objUserInfo.UserId = UserId;

            //Find Tributes for User ID
            int tributeId = 0;
            GetMyTributes _objtribute = new GetMyTributes();
            _objtribute.UserId = UserId;
            object[] _param = { _objtribute, 0, 1, 1 };
            if (_objtribute.CustomError == null)
            {
                List<GetMyTributes> Mytributes = new List<GetMyTributes>();
                Mytributes = target.GetMyTributes(_param);
                Assert.AreEqual(true, Mytributes.Count > 0);
                tributeId = Mytributes[0].TributeId;
            }
            objUserInfo.TributeId = tributeId;

            //FINd Photo Album ID for Tribute id
            object[] objParam = { tributeId };
            DataSet dsPhotoAlbumList = GetDataSet("usp_GetPhotoAlbumListInTribute", objParam);
            List<PhotoAlbum> objListOfPhotoAlbum = new List<PhotoAlbum>();
            //to fill records in the Photo Gallery list
            if (dsPhotoAlbumList.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in dsPhotoAlbumList.Tables[0].Rows)
                {
                    PhotoAlbum objAlbum = new PhotoAlbum();
                    objAlbum.PhotoAlbumId = int.Parse(dr["PhotoAlbumId"].ToString());

                    objListOfPhotoAlbum.Add(objAlbum);
                    objAlbum = null;
                }
            }
            int PhotoAlbumId = 0;
            if (objListOfPhotoAlbum.Count > 0)
            {
                PhotoAlbumId = objListOfPhotoAlbum[0].PhotoAlbumId;
            }

            //Get Photo id in PhotoAlbumId/////////////
            List<Photos> objListPhotos = new List<Photos>();
            try
            {

                object[] objParam1 = {PhotoAlbumId,
                                            1,
                                            1,
                                            "ASC"
                                        };
                DataSet dsPhotos = GetDataSet("usp_GetPhotos", objParam1);
                int totalRecords = 0;
                //objGetPhotos.SortOrder
                if (dsPhotos.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = dsPhotos.Tables[0].Rows[0];
                    totalRecords = int.Parse(dr["TotalRecords"].ToString());
                }
                //to fill records in the Photo list
                if (dsPhotos.Tables[1].Rows.Count > 0)
                {
                    foreach (DataRow dr in dsPhotos.Tables[1].Rows)
                    {
                        Photos objPhoto = new Photos();
                        objPhoto.PhotoId = int.Parse(dr["UserPhotoId"].ToString());
                        objPhoto.PhotoAlbumId = int.Parse(dr["PhotoAlbumId"].ToString());
                        objPhoto.PhotoImage = dr["PhotoImage"].ToString();
                        objPhoto.CommentCount = int.Parse(dr["CommentCount"].ToString());
                        objPhoto.CreatedDate = DateTime.Parse(dr["CreatedDate"].ToString());
                        objPhoto.TotalRecords = totalRecords;

                        objListPhotos.Add(objPhoto);
                        objPhoto = null;
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }

            //////////////////////////////////////////

            objUserInfo.TypeId = objListPhotos[0].PhotoId;
            objUserInfo.TypeName = "ManagePhoto";

            actual = target.IsUserOwner(objUserInfo);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private bool UserIsAdmin()
    {
        bool isAdmin;
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _userId;
        objUserInfo.TributeId = _tributeId;
        if (Equals(mode, "edit"))
            objUserInfo.TypeName = EDIT_TYPE_NAME;
        else
            objUserInfo.TypeName = ADD_TYPE_NAME;

        if (_userId != 0)
            isAdmin = IsUserAdmin(objUserInfo);
        else
            isAdmin = false;

        objUserInfo.IsAdmin = isAdmin;
        StateManager objStateManager = StateManager.Instance;
        objStateManager.Add("UserAdminInfo_ManageNote", objUserInfo, StateManager.State.Session);
        return isAdmin;
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Method to check if user is Owner of type(Photo, Video etc.)
 /// </summary>
 /// <param name="objUserInfo">UserAdminOwnerInfo entity containing UserId, TypeId and TypeName</param>
 /// <returns>True/False</returns>
 public bool IsUserOwner(UserAdminOwnerInfo objUserInfo)
 {
     UserInfoManager objUser = new UserInfoManager();
     return bool.Parse(objUser.IsUserOwner(objUserInfo).ToString());
 }
    /// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private void UserIsAdminOrOwner(string mode)
    {
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        StateManager objStateManager = StateManager.Instance;
        if (mode == "edit")
        {
            objUserInfo = (UserAdminOwnerInfo)objStateManager.Get("UserAdminOwnerInfo", StateManager.State.Session);
            objUserInfo.Mode = "edit";
        }
        else
        {
            objUserInfo.UserId = _userId;
            objUserInfo.TributeId = _tributeId; //TO DO: to be picked dynamically
            objUserInfo.TypeId = _videoId;
            if (_videoType == "videotribute")
                objUserInfo.TypeName = TYPE_NAME_TRIBUTE;
            else
                objUserInfo.TypeName = TYPE_NAME;
            objUserInfo.Mode = "view";
            bool isUserAdmin = IsUserAdmin(objUserInfo);
            bool isUserOwner = IsUserOwner(objUserInfo);

            if (isUserAdmin)
            {
                objUserInfo.IsAdmin = isUserAdmin;
                objUserInfo.IsOwner = false;
                isAdmin = true;
            }
            else if (isUserOwner)
            {
                objUserInfo.IsAdmin = false;
                objUserInfo.IsOwner = isUserOwner;
                isAdmin = false;
            }
        }
        objStateManager.Add("UserAdminOwnerInfo_ManageVideo", objUserInfo, StateManager.State.Session);
    }
    /// <summary>
    /// Find that user is admin or not and add the value in view state
    /// </summary>
    private void UserIsAdmin()
    {
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _UserId;
        objUserInfo.TributeId = _TributeId;
        _IsAdmin = IsUserAdmin(objUserInfo);

        // Add the admin value in View State
        object[] objVal = { _IsAdmin };
        ViewState.Add("Event_Admin", objVal);

        txtEmailAddresses.Text = "";
        repAddressList.DataSource = null;
        repAddressList.DataBind();

        lbtnLogin.Attributes.Add("onclick", "SetValidationGroup('LoginGroup')");
        lbtnAddContact.Attributes.Add("onclick", "SetValidationGroup('EmailGroup')");
    }
Ejemplo n.º 9
0
 /// <summary>
 /// Method to check if user is Owner of Type(Video, Photo etc.)
 /// Added By: Gaurav Puri
 /// </summary>
 /// <param name="objUserInfo">UserAdminOwnerInfo entity containing UserId, TypeId and TypeName</param>
 /// <returns>True/False</returns>
 public bool IsUserOwner(UserAdminOwnerInfo objUserInfo)
 {
     UserInfoResource objUser = new UserInfoResource();
     object[] param = { objUserInfo };
     return objUser.IsUserOwner(param);
 }
    /// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private bool UserIsAdmin()
    {
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _userId;
        objUserInfo.TributeId = _tributeId;
        objUserInfo.TypeName = "PhotoGallery";

        if (_userId != 0)
        {
            if (IsUserAdmin(objUserInfo))
            {
                objUserInfo.IsAdmin = true;
                isAdmin = true;
            }
        }
        else
        {
            objUserInfo.IsAdmin = false;
            isAdmin = false;
        }
        StateManager objStateManager = StateManager.Instance;
        objStateManager.Add("UserAdminInfo_PhotoGallery", objUserInfo, StateManager.State.Session);
        return isAdmin;
    }
    /// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private void UserIsAdminOrOwner()
    {
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _userId;
        objUserInfo.TributeId = _tributeId; // _userTributeId;
        objUserInfo.TypeName = "VideoGallery";

        if (IsUserAdmin(objUserInfo))
            objUserInfo.IsAdmin = true;
        else
            objUserInfo.IsAdmin = false;

        StateManager objStateManager = StateManager.Instance;
        objStateManager.Add("UserAdminOwnerInfo_VideoGallery", objUserInfo, StateManager.State.Session);
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Method to get user is admin or owner
    /// </summary>
    private void UserIsAdmin()
    {
        UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
        objUserInfo.UserId = _userId;
        objUserInfo.TributeId = _tributeId;

        objUserInfo.TypeName = _typeName; // "GuestBook";

        if (_userId != 0)
        {
            if (IsUserAdmin(objUserInfo))
            {
                objUserInfo.IsAdmin = true;
                isAdmin = true;
            }
        }
        else
        {
            objUserInfo.IsAdmin = false;
            isAdmin = false;
        }
        StateManager objStateManager = StateManager.Instance;
        objStateManager.Add("UserAdminInfo_GuestBook", objUserInfo, StateManager.State.Session);
    }