public ActionResult Index(string page)
        {
            // TODO: What kind of sorting/paging to allow
            // TODO: Can pass duedays to vista and always sort on that?
            // TODO: Will need better sort to handle paging in vista or can handle paging/sorting in repository (less efficient)

            ChecklistIndex model = new ChecklistIndex();

            int pageVal = this.GetPage(page);

            //ChecklistItemsResult result = this.DashboardRepository.Checklist.GetItems("", pageVal, ItemsPerPage);
            ChecklistItemsResult result = this.DashboardRepository.Checklist.GetItems("", 1, 1000);

            if (!result.Success)
            {
                this.Error(result.Message);
            }
            else
            {
                model.Items = result.Items;

                model.Items.Sort(delegate(ChecklistItem x, ChecklistItem y)
                {
                    int returnVal = 0;

                    returnVal = x.DueDays.CompareTo(y.DueDays);

                    if (returnVal == 0)
                    {
                        returnVal = x.ItemType.ToString().CompareTo(y.ItemType.ToString());
                    }

                    if (returnVal == 0)
                    {
                        returnVal = x.Category.CompareTo(y.Category);
                    }

                    if (returnVal == 0)
                    {
                        returnVal = x.Description.CompareTo(y.Description);
                    }

                    return(returnVal);
                });

                //model.Paging.SetPagingData(ItemsPerPage, pageVal, result.TotalResults);
                model.Paging.SetPagingData(1000, pageVal, result.TotalResults);
                model.Paging.BaseUrl = Url.Action("Index", new { @page = "" });
            }

            return(View(model));
        }
        private ActionResult LoadDefaults(ChecklistIndex model)
        {
            BrokerOperationResult result = this.DashboardRepository.Checklist.LoadDefaultChecklist();

            if (!result.Success)
            {
                this.Error(result.Message);
            }
            else
            {
                this.Information("Default Checklist Items Added Successfully");
            }

            return(RedirectToAction("Index", new { page = "1" }));
        }
        public ActionResult PostIndex(ChecklistIndex model)
        {
            ActionResult result;

            if (model.PostOperation == ChecklistIndexOperation.Delete)
            {
                //ClearAllItems();

                result = DeleteItem(model);
            }
            else if (model.PostOperation == ChecklistIndexOperation.LoadDefaults)
            {
                result = LoadDefaults(model);
            }
            else
            {
                this.Attention("Unknown operation");
                result = RedirectToAction("Index", new { page = "1" });
            }

            return(result);
        }
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        private ActionResult DeleteItem(ChecklistIndex model)
        {
            if (string.IsNullOrWhiteSpace(model.SelectedItemIen))
            {
                this.Error("Please select an item to delete");
            }
            else
            {
                BrokerOperationResult result = this.DashboardRepository.Checklist.DeleteItem(model.SelectedItemIen);

                if (!result.Success)
                {
                    this.Error(result.Message);
                }
                else
                {
                    this.Information("The item has been deleted");
                }
            }

            return(RedirectToAction("Index"));
        }
        public void Given_Checklist_index_with_signed_off_comments_and_resolved_executive_summary_then_commentStatus_is_AllQaCommentsResolved()
        {
            ChecklistIndex index = new ChecklistIndex();

            index.HasQaComments = true;
            index.HasResolvedQaComments = true;
            index.HasSignedOffQaComments = true;

            index.ExecutiveSummaryUpdateRequired = true;
            index.ExecutiveSummaryQACommentsResolved = true;
            index.ExecutiveSummaryQASignedOff = false;



            Assert.AreEqual("AllQaCommentsResolved", index.QACommentStatus());
        }
        public void Given_Checklist_index_with_signed_off_Exec_Summary_comments_then_commentStatus_is_None()
        {
            ChecklistIndex index = new ChecklistIndex();

            index.HasQaComments = false;
            index.HasResolvedQaComments = false;
            index.HasSignedOffQaComments = false;

            index.ExecutiveSummaryUpdateRequired = true;
            index.ExecutiveSummaryQACommentsResolved = true;
            index.ExecutiveSummaryQASignedOff = true;

            

            Assert.AreEqual("None", index.QACommentStatus());
        }
        public void Given_Checklist_index_with_resolved_Exec_Summary_comments_and_unresolved_qacomments_then_commentStatus_is_HasUnresolvedQaComments()
        {
            ChecklistIndex index = new ChecklistIndex();

            index.HasQaComments = true;
            index.HasResolvedQaComments = false;
            index.ExecutiveSummaryUpdateRequired = true;
            index.ExecutiveSummaryQACommentsResolved = true;

            Assert.AreEqual("HasUnresolvedQaComments", index.QACommentStatus());
        }