/// <summary>
 /// Approves this request with comments. The request must be reviewable prior to approval.
 /// </summary>
 /// <param name="comments">The comments.</param>
 public void Approve(string comments)
 {
     RequestOfficer officer = new RequestOfficer(this.applicationContext);
     if (officer.CanApprove())
     {
         if (CanBeReviewed)
             AddApprovalAudit(ApprovalStatus.Approved, comments);
         else
             throw new System.InvalidOperationException(Resources.ApproveNotAllowedException);
     }
     else
         throw new System.Security.SecurityException(Resources.ApproveNotAuthorizedException);
 }
 /// <summary>
 /// Final approves this request with comments.
 /// </summary>
 /// <param name="comments">The comments.</param>
 public void FinalApprove(string comments)
 {
     // if you have the authority and it can be reviewed, then final approve
     RequestOfficer officer = new RequestOfficer(this.applicationContext);
     if (officer.CanApprove())
     {
         if (CanBeReviewed)
         {
             this.Status = RequestStatus.Approved;
             this.FinalReviewedBy = this.applicationContext.Identity.Name;
             this.FinalReviewedOn = DateTime.Now;
             this.PendingReviewBy = "";
             ttrProvider.Save(this);
             // audit the approval
             AddApprovalAudit(ApprovalStatus.FinalApproved, comments);
             // send out an email to the requestor
             RequestNotifier notifier = new RequestNotifier();
             notifier.SendRequestFinalReviewed(this, comments);
         }
         else
             throw new System.InvalidOperationException(Resources.FinalApproveNotAllowedException);
     }
     else
         throw new System.Security.SecurityException(Resources.FinalApproveNotAuthorizedException);
 }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.RequestId = System.Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]);
                if (this.RequestId != 0)
                {
                    TravelAndTrainingRequestFinder requestFinder = new TravelAndTrainingRequestFinder(this.User);
                    TravelAndTrainingRequest request = requestFinder.GetRequestById(this.RequestId);

                    // adamsb 2/27/09 Check status for routing
                    if (request != null)
                    {
                        if (request.CanBeReviewed)
                        {
                            RequestOfficer securityOfficer = new RequestOfficer(this.User);
                            if (securityOfficer.CanApprove())
                                Response.Redirect(string.Format("~/Approvers/RequestApproval.aspx?id={0}",
                                    request.Id), false);
                            else
                            {
                                // if not a final approver,
                                // load the request, set the active step to the confirmation page
                                // and load the summary
                                this.UnpackRequest(request);
                                requestIsLoaded = true;
                                this.wzCreateRequest.ActiveStepIndex = 2;
                                this.LoadSummary(request);
                            }
                        }
                        else if (request.CanBeSaved)
                        {
                            // if not a final approver,
                            // load the request, set the active step to the confirmation page
                            // and load the summary
                            this.UnpackRequest(request);
                            requestIsLoaded = true;
                            this.wzCreateRequest.ActiveStepIndex = 2;
                            this.LoadSummary(request);
                        }
                        else
                            Response.Redirect("~/Main.aspx", false);
                    }
                    //if (request != null && request.CanBeSaved)
                    //{
                    //    this.UnpackRequest(request);
                    //    // if its pending review by someone, then load the summary page
                    //    if (request.PendingReviewBy.Length > 0)
                    //    {
                    //        requestIsLoaded = true;
                    //        this.wzCreateRequest.ActiveStepIndex = 2;
                    //        this.LoadSummary(request);
                    //    }
                    //}
                    //else
                    //    Response.Redirect("~/Main.aspx", false);
                }
            }
        }