protected void gvCoordinators_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DisplayUser ds = e.Row.DataItem as DisplayUser; User user = UserService.GetUser(ds.Id); School school = RegionService.GetSchoolByUser(user); Label labSchool = e.Row.FindControl("labSchool") as Label; Label labCaption = e.Row.FindControl("labCaption") as Label; Image imgPhoto = e.Row.FindControl("imgGroupPhoto") as Image; LinkButton lnkDownLoad = e.Row.FindControl("lnkDownLoad") as LinkButton; labSchool.Text = school.Name; IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.User, user.Id); Attachment image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.GroupPhoto); if (null != image) { imgPhoto.Visible = true; imgPhoto.ImageUrl = "~/ImageHandler.ashx?id=" + image.Id; lnkDownLoad.CommandArgument = image.Id.ToString(); } IList <KeyValue> keyValues = PortfolioService.GetKeyValues(ObjectTypes.User, user.Id); var val = keyValues.FirstOrDefault(x => "GroupCaption".Equals(x.KeyName) && x.Type == KeyValueType.String); if (val != null) { labCaption.Text = val.StringValue; } } }
/// <summary> /// Load all applications for this school /// </summary> private void LoadApplications() { School school = GetSchool(); IList <Portfolio> list = PortfolioService.GetPortfolios(school); //lnkSubmit.Visible = (list.FirstOrDefault(x => x.Status != ApplicationStatus.Certified) == null); gvNominees.DataSource = list; gvNominees.DataBind(); IList <Category> missing = new List <Category>(); IList <Category> categories = CategoryService.GetCategories(school.Area.Region); foreach (Category c in categories) { if (list.FirstOrDefault(x => x.Category.Name.Equals(c.Name)) == null) { missing.Add(c); } } lvMissingCats.DataSource = missing; lvMissingCats.DataBind(); IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.User, CurrentUser.Id); Attachment image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.GroupPhoto); if (null != image) { imgPhoto.Visible = true; imgPhoto.ImageUrl = "~/ImageHandler.ashx?id=" + image.Id; } IList <KeyValue> keyValues = PortfolioService.GetKeyValues(ObjectTypes.User, CurrentUser.Id); var val = keyValues.FirstOrDefault(x => "GroupCaption".Equals(x.KeyName) && x.Type == KeyValueType.String); if (val != null) { txtCaption.Text = val.StringValue; } }
protected void btnSave_Click(object sender, EventArgs e) { IList <KeyValue> keyValues = PortfolioService.GetKeyValues(ObjectTypes.User, CurrentUser.Id); var val = keyValues.FirstOrDefault(x => "GroupCaption".Equals(x.KeyName) && x.Type == KeyValueType.String); if (val == null) { val = new KeyValue(); val.Type = KeyValueType.String; val.KeyName = "GroupCaption"; val.ObjectRowId = CurrentUser.Id; val.ObjectType = ObjectTypes.User; } if (txtCaption.Text.Length >= 999) { val.StringValue = txtCaption.Text.Substring(0, 999); } else { val.StringValue = txtCaption.Text; } PortfolioService.SaveKeyValue(val); }