Esempio n. 1
0
        public async Task CreateProfilePictureAsyncShouldCreateCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext);
            var applicationUser        = new EfDeletableEntityRepository <ApplicationUser>(dbContext);
            var pictureRepository      = new EfRepository <UserProfilePicture>(dbContext);
            var repositoryComment      = new EfDeletableEntityRepository <NewsFeedComment>(dbContext);
            var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext);
            var friendRepository       = new EfDeletableEntityRepository <Friend>(dbContext);

            var userPicture = new UserProfilePicture
            {
                PictureURL        = "mountain.jpg",
                ApplicationUserId = "1",
            };

            var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository);

            var createResult = service.CreateProfilePictureAsync(userPicture.ApplicationUserId, userPicture.PictureURL);

            Assert.Equal(1, pictureRepository.All().Count());
        }
        public async Task CreateProfilePictureAsync(string userId, string pictureUrl)
        {
            var userPicture = new UserProfilePicture
            {
                PictureURL        = pictureUrl,
                ApplicationUserId = userId,
            };

            await this.pictureRepository.AddAsync(userPicture);

            await this.pictureRepository.SaveChangesAsync();
        }
Esempio n. 3
0
    bool TryReadElementFromXml(EwsServiceXmlReader reader)
    {
        switch (reader.LocalName)
        {
        case XmlElementNames.InsightSource:
            this.InsightSource = reader.ReadElementValue <string>();
            break;

        case XmlElementNames.UpdatedUtcTicks:
            this.UpdatedUtcTicks = reader.ReadElementValue <long>();
            break;

        case XmlElementNames.FullName:
            this.fullName = reader.ReadElementValue();
            break;

        case XmlElementNames.FirstName:
            this.firstName = reader.ReadElementValue();
            break;

        case XmlElementNames.LastName:
            this.lastName = reader.ReadElementValue();
            break;

        case XmlElementNames.EmailAddress:
            this.emailAddress = reader.ReadElementValue();
            break;

        case XmlElementNames.Avatar:
            this.avatar = reader.ReadElementValue();
            break;

        case XmlElementNames.JoinedUtcTicks:
            this.joinedUtcTicks = reader.ReadElementValue <long>();
            break;

        case XmlElementNames.ProfilePicture:
            var picture = new UserProfilePicture();
            picture.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.ProfilePicture);
            this.profilePicture = picture;
            break;

        case XmlElementNames.Title:
            this.title = reader.ReadElementValue();
            break;

        default:
            return(false);
        }

        return(true);
    }
Esempio n. 4
0
        public async Task <IActionResult> UpdateProfilePicture([FromBody] UserProfilePicture profilePictureUpdate, [FromHeader] string authorization)
        {
            try
            {
                await _userService.UpdateProfilePicture(UserUtilities.UserIdFromAuth(authorization), profilePictureUpdate.ProfilePicture);
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            return(Ok());
        }
Esempio n. 5
0
        private void initializeUserGeneralInfo()
        {
            UserProfilePicture.LoadAsync(m_UserManager.NativeClient.PictureLargeURL);
            UserNameLabel.Text   = m_UserManager.NativeClient.Name;
            UserGenderLabel.Text = m_UserManager.NativeClient.Gender.ToString();
            UsersBirthdate.Text  = m_UserManager.NativeClient.Birthday;
            if (m_UserManager.NativeClient.Hometown != null)
            {
                UserHomeTownLabel.Text = m_UserManager.NativeClient.Hometown.Name;
            }

            if (m_UserManager.NativeClient.Location != null)
            {
                UserCurrentCityLabel.Text = m_UserManager.NativeClient.Location.Name;
            }

            if (m_UserManager.NativeClient.RelationshipStatus.HasValue)
            {
                UserRelationshipLabel.Text = m_UserManager.NativeClient.RelationshipStatus.Value.ToString();
            }
        }
Esempio n. 6
0
        public async Task GetLastProfilePictureShouldReturnLastPicture()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext);
            var applicationUser        = new EfDeletableEntityRepository <ApplicationUser>(dbContext);
            var pictureRepository      = new EfRepository <UserProfilePicture>(dbContext);
            var repositoryComment      = new EfDeletableEntityRepository <NewsFeedComment>(dbContext);
            var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext);
            var friendRepository       = new EfDeletableEntityRepository <Friend>(dbContext);

            var firstUserPicture = new UserProfilePicture
            {
                PictureURL        = "mountain.jpg",
                ApplicationUserId = "1",
            };

            var secondUserPicture = new UserProfilePicture
            {
                PictureURL        = "mountain2.jpg",
                ApplicationUserId = "1",
            };

            await pictureRepository.AddAsync(firstUserPicture);

            await pictureRepository.AddAsync(secondUserPicture);

            await pictureRepository.SaveChangesAsync();

            var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository);

            var result = await service.LastProfilePictureAsync("1");

            var resultWhenIsNull = await service.LastProfilePictureAsync("2");

            Assert.Equal(secondUserPicture.PictureURL, result);
            Assert.Null(resultWhenIsNull);
        }
Esempio n. 7
0
        public async Task GetAllProfilePicturesAsyncShouldReturnCorrectCount()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext);
            var applicationUser        = new EfDeletableEntityRepository <ApplicationUser>(dbContext);
            var pictureRepository      = new EfRepository <UserProfilePicture>(dbContext);
            var repositoryComment      = new EfDeletableEntityRepository <NewsFeedComment>(dbContext);
            var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext);
            var friendRepository       = new EfDeletableEntityRepository <Friend>(dbContext);

            var userPicture = new UserProfilePicture
            {
                PictureURL        = "mountain.jpg",
                ApplicationUserId = "1",
            };

            var secondUserPicture = new UserProfilePicture
            {
                PictureURL        = "mountainTwo.jpg",
                ApplicationUserId = "1",
            };

            var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository);

            var firstPictureResult  = service.CreateProfilePictureAsync(userPicture.ApplicationUserId, userPicture.PictureURL);
            var secondPictureResult = service.CreateProfilePictureAsync(secondUserPicture.ApplicationUserId, secondUserPicture.PictureURL);

            AutoMapperConfig.RegisterMappings(typeof(GetAllProfilePictureForUserViewModel).GetTypeInfo().Assembly);

            var resultCount = await service.GetAllProfilePicturesAsync <GetAllProfilePictureForUserViewModel>(userPicture.ApplicationUserId);

            Assert.Equal(2, resultCount.Count());
        }
Esempio n. 8
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
                case XmlElementNames.EmailAddress:
                    this.EmailAddress = reader.ReadElementValue();
                    break;
                case XmlElementNames.FullName:
                    this.FullName = reader.ReadElementValue();
                    break;
                case XmlElementNames.DisplayName:
                    this.DisplayName = reader.ReadElementValue();
                    break;
                case XmlElementNames.GivenName:
                    this.GivenName = reader.ReadElementValue();
                    break;
                case XmlElementNames.Surname:
                    this.Surname = reader.ReadElementValue();
                    break;
                case XmlElementNames.PhoneNumber:
                    this.PhoneNumber = reader.ReadElementValue();
                    break;
                case XmlElementNames.SMSNumber:
                    this.SMSNumber = reader.ReadElementValue();
                    break;
                case XmlElementNames.FacebookProfileLink:
                    this.FacebookProfileLink = reader.ReadElementValue();
                    break;
                case XmlElementNames.LinkedInProfileLink:
                    this.LinkedInProfileLink = reader.ReadElementValue();
                    break;
                case XmlElementNames.ProfessionalBiography:
                    this.ProfessionalBiography = reader.ReadElementValue();
                    break;
                case XmlElementNames.TeamSize:
                    this.TeamSize = reader.ReadElementValue();
                    break;
                case XmlElementNames.Birthday:
                    this.Birthday = reader.ReadElementValue();
                    break;
                case XmlElementNames.Hometown:
                    this.Hometown = reader.ReadElementValue();
                    break;
                case XmlElementNames.CurrentLocation:
                    this.CurrentLocation = reader.ReadElementValue();
                    break;
                case XmlElementNames.Office:
                    this.Office = reader.ReadElementValue();
                    break;
                case XmlElementNames.Headline:
                    this.Headline = reader.ReadElementValue();
                    break;
                case XmlElementNames.Title:
                    this.Title = reader.ReadElementValue();
                    break;
                case XmlElementNames.Alias:
                    this.Alias = reader.ReadElementValue();
                    break;
                case XmlElementNames.Department:
                    this.Department = reader.ReadElementValue();
                    break;
                case XmlElementNames.MutualManager:
                    this.MutualManager = new ProfileInsightValue();
                    this.MutualManager.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.MutualManager);
                    break;
                case XmlElementNames.ManagementChain:
                    this.ManagementChain = new ProfileInsightValueCollection(XmlElementNames.Item);
                    this.ManagementChain.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.ManagementChain);
                    break;
                case XmlElementNames.DirectReports:
                    this.DirectReports = new ProfileInsightValueCollection(XmlElementNames.Item);
                    this.DirectReports.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.DirectReports);
                    break;
                case XmlElementNames.Peers:
                    this.Peers = new ProfileInsightValueCollection(XmlElementNames.Item);
                    this.Peers.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.Peers);
                    break;
                case XmlElementNames.MutualConnections:
                    this.MutualConnections = new ProfileInsightValueCollection(XmlElementNames.Item);
                    this.MutualConnections.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.MutualConnections);
                    break;
                case XmlElementNames.Skills:
                    this.Skills = new SkillInsightValueCollection(XmlElementNames.Item);
                    this.Skills.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.Skills);
                    break;
                case XmlElementNames.CurrentJob:
                    this.CurrentJob = new JobInsightValueCollection(XmlElementNames.Item);
                    this.CurrentJob.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.CurrentJob);
                    break;
                case XmlElementNames.CompanyProfile:
                    this.CompanyProfile = new CompanyInsightValueCollection(XmlElementNames.Item);
                    this.CompanyProfile.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.CompanyProfile);
                    break;
                case XmlElementNames.Insights:
                    this.Insights = new PersonInsightCollection();
                    this.Insights.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.Insights);
                    break;
                case XmlElementNames.UserProfilePicture:
                    this.UserProfilePicture = new UserProfilePicture();
                    this.UserProfilePicture.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.UserProfilePicture);
                    break;
                default:
                    return base.TryReadElementFromXml(reader);
            }

            return true;
        }
Esempio n. 9
0
    bool TryReadElementFromXml(EwsServiceXmlReader reader)
    {
        do
        {
            reader.Read();
            InsightValue item = null;

            if (reader.NodeType == XmlNodeType.Element && reader.LocalName == XmlElementNames.Item)
            {
                switch (reader.ReadAttributeValue("xsi:type"))
                {
                case XmlElementNames.StringInsightValue:
                    item = new StringInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.ProfileInsightValue:
                    item = new ProfileInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.JobInsightValue:
                    item = new JobInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.UserProfilePicture:
                    item = new UserProfilePicture();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.EducationInsightValue:
                    item = new EducationInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.SkillInsightValue:
                    item = new SkillInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.ComputedInsightValue:
                    item = new ComputedInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.MeetingInsightValue:
                    item = new MeetingInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.EmailInsightValue:
                    item = new EmailInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.DelveDocument:
                    item = new DelveDocument();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                default:
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        } while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.ItemList));

        return(true);
    }
Esempio n. 10
0
        /// <summary>
        /// Tries to read element from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>True if element was read.</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
            case XmlElementNames.EmailAddress:
                this.EmailAddress = reader.ReadElementValue();
                break;

            case XmlElementNames.FullName:
                this.FullName = reader.ReadElementValue();
                break;

            case XmlElementNames.DisplayName:
                this.DisplayName = reader.ReadElementValue();
                break;

            case XmlElementNames.GivenName:
                this.GivenName = reader.ReadElementValue();
                break;

            case XmlElementNames.Surname:
                this.Surname = reader.ReadElementValue();
                break;

            case XmlElementNames.PhoneNumber:
                this.PhoneNumber = reader.ReadElementValue();
                break;

            case XmlElementNames.SMSNumber:
                this.SMSNumber = reader.ReadElementValue();
                break;

            case XmlElementNames.FacebookProfileLink:
                this.FacebookProfileLink = reader.ReadElementValue();
                break;

            case XmlElementNames.LinkedInProfileLink:
                this.LinkedInProfileLink = reader.ReadElementValue();
                break;

            case XmlElementNames.ProfessionalBiography:
                this.ProfessionalBiography = reader.ReadElementValue();
                break;

            case XmlElementNames.TeamSize:
                this.TeamSize = reader.ReadElementValue();
                break;

            case XmlElementNames.Birthday:
                this.Birthday = reader.ReadElementValue();
                break;

            case XmlElementNames.Hometown:
                this.Hometown = reader.ReadElementValue();
                break;

            case XmlElementNames.CurrentLocation:
                this.CurrentLocation = reader.ReadElementValue();
                break;

            case XmlElementNames.Office:
                this.Office = reader.ReadElementValue();
                break;

            case XmlElementNames.Headline:
                this.Headline = reader.ReadElementValue();
                break;

            case XmlElementNames.Title:
                this.Title = reader.ReadElementValue();
                break;

            case XmlElementNames.MutualManager:
                this.MutualManager = new ProfileInsightValue();
                this.MutualManager.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.MutualManager);
                break;

            case XmlElementNames.ManagementChain:
                this.ManagementChain = new ProfileInsightValueCollection(XmlElementNames.Item);
                this.ManagementChain.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.ManagementChain);
                break;

            case XmlElementNames.DirectReports:
                this.DirectReports = new ProfileInsightValueCollection(XmlElementNames.Item);
                this.DirectReports.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.DirectReports);
                break;

            case XmlElementNames.Peers:
                this.Peers = new ProfileInsightValueCollection(XmlElementNames.Item);
                this.Peers.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.Peers);
                break;

            case XmlElementNames.MutualConnections:
                this.MutualConnections = new ProfileInsightValueCollection(XmlElementNames.Item);
                this.MutualConnections.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.MutualConnections);
                break;

            case XmlElementNames.Skills:
                this.Skills = new SkillInsightValueCollection(XmlElementNames.Item);
                this.Skills.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.Skills);
                break;

            case XmlElementNames.CurrentJob:
                this.CurrentJob = new JobInsightValueCollection(XmlElementNames.Item);
                this.CurrentJob.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.CurrentJob);
                break;

            case XmlElementNames.CompanyProfile:
                this.CompanyProfile = new CompanyInsightValueCollection(XmlElementNames.Item);
                this.CompanyProfile.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.CompanyProfile);
                break;

            case XmlElementNames.Insights:
                this.Insights = new PersonInsightCollection();
                this.Insights.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.Insights);
                break;

            case XmlElementNames.UserProfilePicture:
                this.UserProfilePicture = new UserProfilePicture();
                this.UserProfilePicture.LoadFromXml(reader, XmlNamespace.Types, XmlElementNames.UserProfilePicture);
                break;

            default:
                return(base.TryReadElementFromXml(reader));
            }

            return(true);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["status"] != null && Session["status"].ToString().Equals("1"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Datele au fost actualizate cu succes!','success');", true);
                Session.Remove("status");
            }
        }
        catch (Exception err)
        {
        }
        if (!Page.IsPostBack)
        {
            try
            {
                MembershipUser userCheck = System.Web.Security.Membership.GetUser();
                if (userCheck != null)
                //   bool userCheck = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
                // if (userCheck)
                {
                    string username = System.Web.Security.Membership.GetUser().UserName.ToString();
                    string email    = System.Web.Security.Membership.GetUser().Email.ToString();
                    string user     = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString();
                    Username.Text = username;
                    Email.Text    = email;

                    string        sqlVerif = "SELECT count(*) from PozeUseri where Id_User = @IdUser";
                    SqlConnection con      = ConnectionFactory.getNewSqlConnection();
                    con.Open();
                    SqlCommand com = new SqlCommand(sqlVerif, con);
                    com.Parameters.AddWithValue("IdUser", user);
                    int userCount = (int)com.ExecuteScalar();
                    con.Close();
                    if (userCount > 0)
                    {
                        string sql = "SELECT Poza_User FROM PozeUseri WHERE Id_User = @IdUser";
                        con = ConnectionFactory.getNewSqlConnection();
                        con.Open();
                        com = new SqlCommand(sql, con);
                        com.Parameters.AddWithValue("IdUser", user);
                        try
                        {
                            SqlDataReader r = com.ExecuteReader();
                            while (r.Read())
                            {
                                UserImage.ImageUrl = "~/pozeUseri/" + r["Poza_User"].ToString();
                            }
                        }
                        catch (Exception err)
                        {
                        }
                        con.Close();
                    }
                    else
                    {
                        UserImage.Attributes["src"] = "pozeUseri/DefaultUserIcon.png";
                    }

                    string userId = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString();

                    SqlDataSource3.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiFavorite ON Carti.Id = CartiFavorite.Id_Carte WHERE CartiFavorite.Id_User = @user";
                    SqlDataSource3.SelectParameters.Clear();
                    SqlDataSource3.SelectParameters.Add("user", userId);
                    SqlDataSource3.DataBind();

                    SqlDataSource4.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiDeCitit ON Carti.Id = CartiDeCitit.Id_Carte WHERE CartiDeCitit.Id_User = @user";
                    SqlDataSource4.SelectParameters.Clear();
                    SqlDataSource4.SelectParameters.Add("user", userId);
                    SqlDataSource4.DataBind();

                    SqlDataSource5.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiCitite ON Carti.Id = CartiCitite.Id_Carte WHERE CartiCitite.Id_User = @user";
                    SqlDataSource5.SelectParameters.Clear();
                    SqlDataSource5.SelectParameters.Add("user", userId);
                    SqlDataSource5.DataBind();
                }
                else
                {
                    Response.Redirect("~/Home.aspx", false);
                }
            }
            catch (Exception err)
            {
            }
        }
        if (IsPostBack && UserProfilePicture.PostedFile != null)
        {
            try
            {
                if (UserProfilePicture.HasFile)
                {
                    String type = UserProfilePicture.PostedFile.ContentType.ToLower();
                    System.Drawing.Image img = System.Drawing.Image.FromStream(UserProfilePicture.PostedFile.InputStream);
                    int     height           = img.Height;
                    int     width            = img.Width;
                    decimal size             = Math.Round(((decimal)UserProfilePicture.PostedFile.ContentLength / (decimal)1024), 2);
                    if (size > 3500)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Imagine prea mare! Dimensiunea maxima pentru imagine este 3,5MB.', 'danger');", true);
                    }
                    else
                    {
                        if (type.Contains("jpg") || type.Contains("jpeg"))
                        {
                            string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString();
                            UserProfilePicture.SaveAs(Server.MapPath("~/pozeUseri/") + user + ".jpg");

                            string        sqlVerif = "SELECT count(*) from PozeUseri where Id_User = @IdUser";
                            SqlConnection con      = ConnectionFactory.getNewSqlConnection();
                            con.Open();
                            SqlCommand com = new SqlCommand(sqlVerif, con);
                            com.Parameters.AddWithValue("IdUser", user);
                            int userCount = (int)com.ExecuteScalar();
                            con.Close();
                            if (userCount > 0)
                            {
                                string sql = "UPDATE PozeUseri SET Poza_User = @Poza WHERE Id_User = @IdUser";
                                con = ConnectionFactory.getNewSqlConnection();
                                con.Open();
                                com = new SqlCommand(sql, con);
                                com.Parameters.AddWithValue("IdUser", user);
                                string urlPoza = user + ".jpg";
                                com.Parameters.AddWithValue("Poza", urlPoza);
                                com.ExecuteNonQuery();
                                con.Close();
                                UserImage.ImageUrl = "~/pozeUseri/" + urlPoza;
                            }
                            else
                            {
                                string sql = "INSERT INTO PozeUseri (Id_User, Poza_User) VALUES (@IdUser, @Poza)";
                                con = ConnectionFactory.getNewSqlConnection();
                                con.Open();
                                com = new SqlCommand(sql, con);
                                com.Parameters.AddWithValue("IdUser", user);
                                string urlPoza = user + ".jpg";
                                com.Parameters.AddWithValue("Poza", urlPoza);
                                com.ExecuteNonQuery();
                                con.Close();
                                UserImage.ImageUrl = "~/pozeUseri/" + urlPoza;
                            }
                            //Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Imaginea au fost actualizata cu succes!','success');", true);
                            //Session.Remove("status");

                            Session["status"] = "1";
                            Response.Redirect(Request.RawUrl, false);
                        }
                        //Response.Redirect(Request.RawUrl);
                        //Server.TransferRequest(Request.Url.AbsolutePath, false);
                    }
                }
            }
            catch (Exception err)
            {
            }
        }
    }
Esempio n. 12
0
    /// <summary>
    /// Reads ItemList from XML
    /// </summary>
    /// <param name="reader">The reader.</param>
    /* private */ void ReadItemList(EwsServiceXmlReader reader)
    {
        do
        {
            reader.Read();
            InsightValue item = null;

            if (reader.NodeType == XmlNodeType.Element && reader.LocalName == XmlElementNames.Item)
            {
                switch (reader.ReadAttributeValue("xsi:type"))
                {
                case XmlElementNames.StringInsightValue:
                    item = new StringInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.ProfileInsightValue:
                    item = new ProfileInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.JobInsightValue:
                    item = new JobInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.UserProfilePicture:
                    item = new UserProfilePicture();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.EducationInsightValue:
                    item = new EducationInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.SkillInsightValue:
                    item = new SkillInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.ComputedInsightValue:
                    item = new ComputedInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.MeetingInsightValue:
                    item = new MeetingInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.EmailInsightValue:
                    item = new EmailInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.DelveDocument:
                    item = new DelveDocument();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.CompanyInsightValue:
                    item = new CompanyInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;

                case XmlElementNames.OutOfOfficeInsightValue:
                    item = new OutOfOfficeInsightValue();
                    item.LoadFromXml(reader, reader.LocalName);
                    this.ItemList.InternalAdd(item);
                    break;
                }
            }
        }while (!reader.IsEndElement(XmlNamespace.Types, XmlElementNames.ItemList));
    }