protected void SaveClicked(object o, EventArgs e)
 {
     if (CurrentReview != null)
     {
         CurrentReview.IsActive = cbIsActive.Checked;
         CurrentReview.Title    = tbTitle.Text;
         new ReviewTemplateServices().Save(CurrentReview);
     }
     else
     {
         var t = new HRR.Core.Domain.ReviewTemplate();
         t.IsActive  = cbIsActive.Checked;
         t.Title     = tbTitle.Text;
         t.AccountID = SecurityContextManager.Current.CurrentAccount.ID;
         new ReviewTemplateServices().Save(t);
         Response.Redirect("/Reviews/Templates/" + t.ID.ToString());
     }
 }
        protected void ItemCommand(object o, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.InitInsertCommandName)
            {
                e.Canceled = true;
                var i = new HRR.Core.Domain.ReviewTemplateQuestion();
                i.CategoryID            = 0;
                i.Question              = "";
                i.ReviewTemplateID      = CurrentReview.ID;
                i.QuestionRatingScaleID = 0;
                i.ID = 0;
                e.Item.OwnerTableView.InsertItem(i);
            }

            if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                var t = new HRR.Core.Domain.ReviewTemplateQuestion();
                t.Question              = (e.Item.FindControl("tbQuestion") as IdeaSeed.Web.UI.TextBox).Text;
                t.ReviewTemplateID      = CurrentReview.ID;
                t.CategoryID            = Convert.ToInt16((e.Item.FindControl("ddlCategory") as IdeaSeed.Web.UI.DropDownList).SelectedValue);
                t.QuestionRatingScaleID = Convert.ToInt16((e.Item.FindControl("ddlScale") as IdeaSeed.Web.UI.DropDownList).SelectedValue);
                new ReviewTemplateQuestionServices().Save(t);
            }
            if (e.CommandName == RadGrid.UpdateCommandName)
            {
                if (e.Item is GridEditableItem)
                {
                    var t = new ReviewTemplateQuestionServices().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]);
                    t.Question              = (e.Item.FindControl("tbQuestion") as IdeaSeed.Web.UI.TextBox).Text;
                    t.CategoryID            = Convert.ToInt16((e.Item.FindControl("ddlCategory") as IdeaSeed.Web.UI.DropDownList).SelectedValue);
                    t.QuestionRatingScaleID = Convert.ToInt16((e.Item.FindControl("ddlScale") as IdeaSeed.Web.UI.DropDownList).SelectedValue);
                    new ReviewTemplateQuestionServices().Save(t);
                }
            }
            if (e.CommandName == RadGrid.DeleteCommandName)
            {
                var t = new ReviewTemplateQuestionServices().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]);
                new ReviewTemplateQuestionServices().Delete(t);
            }
            CurrentReview = new ReviewTemplateServices().GetByID(Convert.ToInt32(HttpContext.Current.Request.Url.Segments[HttpContext.Current.Request.Url.Segments.Count() - 1]));
        }
 protected override void OnUnload(EventArgs e)
 {
     base.OnUnload(e);
     CurrentReview = null;
 }