public ActionResult DisplayProtocols(int aId)
        {
            ViewData["SelectedAuditId"] = aId;
            var rlist = new List <RigOapChecklist>();

            if (!(bool)Session["isAuditIdClick"])
            {
                var protocols = OapAuditClient.GetAuditProtocolsAsync(aId).Result?.Result?.Data;
                var ap        = protocols?.Where(r => r.OapChecklist?.OapType?.Code == "AR").FirstOrDefault();
                protocols.Remove(ap);

                Session["isAuditIdClick"] = false;
                return(PartialView("ProtocolsToAuditPartial", protocols));
            }
            return(PartialView("ProtocolsToAuditPartial", rlist));
        }
        public virtual async Task <ActionResult> CreateProtocolChecklist(int OapChecklistId, int OwnerId)
        {
            RigOapChecklist model = new RigOapChecklist()
            {
                OapchecklistId = OapChecklistId, OwnerId = OwnerId
            };

            var audit = (OapAudit)Session["OapAudit"];

            model.RigId             = audit.RigId.ToString();
            model.Title             = "Audit Protocol";
            model.ChecklistDateTime = DateTime.UtcNow;

            var count = audit.OapAuditProtocols.Where(p => p.RigOapChecklist.OapchecklistId == model.OapchecklistId).Count();

            var response = (count == 0) ? await OapAuditClient.AddProtocolToAuditAsync(audit.Id, model) : throw new Exception("Protocol Already Exists");

            var protocols = OapAuditClient.GetAuditProtocolsAsync(audit.Id).Result?.Result?.Data;

            return(TryCatchCollectionDisplayPartialView("ProtocolsToAuditPartial", "GenericDashBoardErrorsKey", () => protocols));
        }