コード例 #1
0
    private void SavePortfolio()
    {
        UserInput input = null;
        Portfolio p     = PortfolioService.GetPortfolio(PortfolioId);

        if (null != p)
        {
            input = UserService.GetUserProfile(p.User.Id);
        }
        else
        {
            input = new UserInput();
        }

        input.FullName = txtFullName.Text;
        input.EMail    = txtEmail.Text;
        input.Comment  = txtComment.Text;
        input.Phone    = txtPhone.Text;
        input.Role     = RoleType.Nominee;

        input.School   = GetSchool();
        input.Category = CategoryService.GetCategory(input.School.Area.Region, ddlCategory.SelectedValue);

        MembershipCreateStatus status = UserService.AddNewUser(input);

        if (status == MembershipCreateStatus.Success)
        {
            User      user      = UserService.GetUser(input.EMail);
            Portfolio portfolio = PortfolioService.GetPortfolioByUser(user);
            portfolio.Parents = txtParents.Text;
            portfolio.Address = txtAddress.Text;
            portfolio.City    = txtCity.Text;
            portfolio.Zip     = txtZip.Text;
            portfolio.State   = ddlState.SelectedValue;
            portfolio.Sex     = (Sexes)Enum.Parse(typeof(Sexes), ddlGender.SelectedValue.ToString());

            if (ddlStatus.Enabled)
            {
                portfolio.Status = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
            }
            PortfolioService.Save(portfolio);
            SaveTestScores(portfolio);
            if (input.Id <= 0)
            {
                EMailService.SendEmail("Sterling Scholar Registration Request", UserService.FormatTemplate(System.Web.HttpContext.Current.Server.MapPath("~/") + "/assets/NewUserTemplate.html", user), user.EMail, UserService.AdminEmailAddress, null);
            }

            PortfolioId            = portfolio.Id;
            lnkPicture.Visible     = true;
            lnkTransUpload.Visible = true;
        }
    }
コード例 #2
0
    protected void EmailValidator_ServerValidate(object source, ServerValidateEventArgs args)
    {
        CustomValidator sender = (CustomValidator)source;

        SS.Model.User u         = UserService.GetUser(txtEmail.Text);
        Portfolio     portfolio = PortfolioService.GetPortfolioByUser(u);

        if (u != null && PortfolioId == -1)
        {
            sender.ErrorMessage = "The email entered has been used, please enter a new email address";
            args.IsValid        = false;
        }
        else
        {
            args.IsValid = true;
        }
    }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: rjustesen/Sterling
    protected void lnkViewTrans_Click(object sender, EventArgs e)
    {
        Portfolio          application = PortfolioService.GetPortfolioByUser(CurrentUser);
        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, application.Id);
        Attachment         attachment  = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.Transcript);

        if (null != attachment)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=JavaScript id='openit'>");
            sb.Append("window.open('../DocView.aspx?id=" + attachment.Id + "', '', '');");
            sb.Append("</script>");
            if (!ClientScript.IsStartupScriptRegistered("openit"))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "openit", sb.ToString());
            }
        }
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string       report = Request["report"];
            MemoryStream stream = null;

            if ("profile".Equals(report))
            {
                string id           = Request["id"];
                String UrlDirectory = Request.Url.GetLeftPart(UriPartial.Path);
                UrlDirectory = UrlDirectory.Substring(0, UrlDirectory.LastIndexOf("/"));
                Portfolio portfolio = PortfolioService.GetPortfolio(Convert.ToInt32(id));
                if (CurrentUser.Role == RoleType.Nominee)
                {
                    if (portfolio.User.Id != CurrentUser.Id)
                    {
                        portfolio = PortfolioService.GetPortfolioByUser(CurrentUser);
                    }
                }
                else if (CurrentUser.Role == RoleType.Coordinator)
                {
                    School school = RegionService.GetSchoolByUser(CurrentUser);
                    if (portfolio.School.Id != school.Id)
                    {
                        portfolio = null;
                    }
                }
                if (null != portfolio)
                {
                    IList <Attachment> list = PortfolioService.GetAttachments(AttachmentCategory.Portfolio, AttachmentType.FinalPortfolio, portfolio.Id);
                    if (list.Count > 0)
                    {
                        stream = new MemoryStream();
                        Attachment attachment = PortfolioService.GetAttachment(list[0].Id);
                        stream.Write(attachment.Data, 0, attachment.Data.Length);
                    }
                    else
                    {
                        stream = ReportService.CreatePortfolioReport(portfolio, UrlDirectory);
                    }
                }
            }
            if ("principal".Equals(report))
            {
                if (CurrentUser.Role == RoleType.Principal || CurrentUser.Role == RoleType.Coordinator)
                {
                    string    id        = Request["id"];
                    Portfolio portfolio = PortfolioService.GetPortfolio(Convert.ToInt32(id));
                    stream = ReportService.CreatePrincipalReport(portfolio);
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            if ("nominees".Equals(report))
            {
                if (CurrentUser.Role != RoleType.Nominee)
                {
                    string id     = Request["id"];
                    School school = RegionService.GetSchool(Convert.ToInt32(id));
                    stream = ReportService.NomineeReport(school);
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            Response.Clear();
            Response.ContentType = "application/pdf";

            Response.OutputStream.Write(stream.GetBuffer(), 0, (int)stream.GetBuffer().Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.End();
        }
    }
コード例 #5
0
ファイル: Default.aspx.cs プロジェクト: rjustesen/Sterling
    protected void gvUsers_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            for (int i = 0; i < e.Row.Cells.Count; i++)
            {
                DataControlFieldHeaderCell obj = (DataControlFieldHeaderCell)e.Row.Cells[i];
                if (!String.IsNullOrEmpty(this.SortColumn) && obj.ContainingField.SortExpression == this.SortColumn)
                {
                    GridHelper.AddSortImage(obj, SortDirection);
                }
            }
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DisplayUser ds = e.Row.DataItem as DisplayUser;
            if (null != ds)
            {
                Label      labStatus = e.Row.FindControl("labStatus") as Label;
                LinkButton btnDelete = e.Row.FindControl("btnDelete") as LinkButton;
                LinkButton btnStatus = e.Row.FindControl("btnStatus") as LinkButton;
                LinkButton btnUnlock = e.Row.FindControl("btnUnlock") as LinkButton;

                btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this user?');");

                if (null != ds.Status)
                {
                    labStatus.Text = ((Status)Enum.ToObject(typeof(Status), ds.Status)).ToDescription();
                }
                if (ds.Disabled)
                {
                    btnStatus.Text = "Enable";
                }
                else
                {
                    btnStatus.Text = "Disable";
                }
                btnUnlock.Visible = false;
                HyperLink btnView = e.Row.FindControl("btnView") as HyperLink;
                User      u       = UserService.GetUser(ds.Id);
                if (UserService.IsAccountLocked(u))
                {
                    btnUnlock.Visible = true;
                }
                if (ds.Role == RoleType.Nominee)
                {
                    Portfolio portfolio = PortfolioService.GetPortfolioByUser(u);
                    if (null != portfolio)
                    {
                        btnView.NavigateUrl = "~/ReportView.aspx?report=profile&id=" + portfolio.Id.ToString();
                    }
                }
                else if (ds.Role == RoleType.AreaJudge || ds.Role == RoleType.RegionJudge)
                {
                    btnView.Text        = "Create Scores";
                    btnView.NavigateUrl = "~/Admin/BuildScores.aspx?id=" + ds.Id.ToString();
                }
                else
                {
                    btnView.Visible = false;
                }
            }
        }
    }
コード例 #6
0
ファイル: Default.aspx.cs プロジェクト: rjustesen/Sterling
 private Portfolio GetPortfolio()
 {
     return(PortfolioService.GetPortfolioByUser(CurrentUser));
 }