protected void UploadImage_Click(object sender, EventArgs e) { var profile = dbContext.Profiles.Single(p => p.User_UserId == userId); string memberImageUploadPath = ""; if (ProfileImageUpload.HasFile) { string fileExtension = Path.GetExtension(ProfileImageUpload.PostedFile.FileName); memberImageUploadPath = @"~/Uploads/" + Session["Username"].ToString() + fileExtension; ProfileImageUpload.SaveAs(Server.MapPath(memberImageUploadPath)); } profile.PhotoUrl = memberImageUploadPath; dbContext.SubmitChanges(); Response.Redirect(Request.RawUrl); }
protected void Page_Load(object sender, EventArgs e) { ProfileImageUpload.Visible = false; if (IsPostBack && ProfileImageUpload.PostedFile != null) { if (ProfileImageUpload.PostedFile.FileName.Length > 0) { try { bool DirExists = System.IO.Directory.Exists(Server.MapPath("/Files/" + LoggedInUser.UniqueUserID + "/PF")); if (!DirExists) { System.IO.Directory.CreateDirectory(Server.MapPath("/Files/" + LoggedInUser.UniqueUserID + "/PF")); } ProfileImageUpload.SaveAs(Server.MapPath("/Files/" + LoggedInUser.UniqueUserID + "/PF/" + ProfileImageUpload.FileName)); string location = "/Files/" + LoggedInUser.UniqueUserID + "/PF/" + ProfileImageUpload.FileName; DAL.DBUserConnection dBUserConnection = new DAL.DBUserConnection(); string result = dBUserConnection.SetUserData(LoggedInUser, UserData.Types.ProfilePicUrl, location); ShowPFMessage(result + "<br/>Wanneer u opnieuw inlogd zal de foto zichtbaar zijn.", "Resultaat"); ProfileImageUpload.Dispose(); ProfileImageUpload.PostedFile.InputStream.Dispose(); ProfileImageUpload.Attributes.Clear(); } catch (Exception ex) { ShowPFMessage("Fout:" + ex.Message, "Resultaat"); } } } if (!IsPostBack) { messagerPF.Style.Add("display", "none!important"); if (Session["User"] != null) { LoggedInUser = Session["User"] as Entities.User; if (LoggedInUser != null) { BLL.LogInHelper logInHelper = new BLL.LogInHelper(); Entities.User result = new Entities.User(); try { result = logInHelper.LoginAtPageLoad(LoggedInUser); } catch (Exception ex) { Response.Redirect("/SignIn"); } if (result != null) { //akkoord om op de pagina te zijn IngelogdAls.Text = LoggedInUser.FirstName + " " + LoggedInUser.LastName + " BSN:" + LoggedInUser.BsnNumber; Data = LoggedInUser; if (Data != null) { //get user measures from database if (!IsPostBack) { BSNNumberQR.Text = Data.BsnNumber; List <Measure> measures = dBUserConnection.GetUserMeasures(Data); List <string> items = new List <string>(); List <string> itemsCategories = new List <string>(); List <decimal> itemSeries = new List <decimal>(); foreach (var measure in measures) { items.Add(measure.Date.ToString("dd/MM/yyyy hh:mm") + " | Temperatuur: " + measure.Temperature.ToString() + " Bloeddruk: " + measure.BloodPressure); itemSeries.Add(Convert.ToDecimal(measure.Temperature)); itemsCategories.Add(measure.Date.ToString("dd MMMM hh:mm")); } CareControlMeasuresLineChart.Series.Add(new AjaxControlToolkit.LineChartSeries() { Data = itemSeries.ToArray(), Name = "Temperatuur in Celsius", LineColor = "#127a7b" }); CareControlMeasures.DataSource = items; CareControlMeasures.DataBind(); CareControlMeasuresLineChart.CategoriesAxis = string.Join(",", itemsCategories.ToArray()); CareControlMeasuresLineChart.DataBind(); UserData data = UserData.GetUserDataFromDB(Data); DAL.DBRoleConnection dBRoleConnection = new DAL.DBRoleConnection(); string roleDescription = null; try { var resultRights = dBRoleConnection.GetUserRights(LoggedInUser); roleDescription = "<br/>Rol: " + resultRights.Description; } catch (Exception) { } ProfileInformation.InnerHtml = ""; ProfileInformation.InnerHtml = "E-mailadress: " + LoggedInUser.EmailAdress + "<br/>Telefoonummer: " + LoggedInUser.PhoneNumber + "<br/>BSN nummer: " + LoggedInUser.BsnNumber + (roleDescription ?? ""); UserName.Text = LoggedInUser.FirstName + " " + LoggedInUser.LastName; fillUserData(data); } } } else { Response.Redirect("/SignIn"); } } else { Response.Redirect("/SignIn"); } } else { Response.Redirect("/SignIn"); } } }