public HttpResponseMessage AddComp(Competency compobj)

        {
            try
            {
                List <Question> ques = new List <Question>();
                //new SelectListItem() { }
                string compname     = compobj.Name;
                var    questionList = new List <Question>();
                questionList = compobj.QuestionList;
                repository   = new SVC();
                bool checkComp = repository.checkCompetencyName(compobj);
                if (checkComp)
                {
                    compobj = repository.AddComp(compobj);
                    return(Request.CreateResponse(HttpStatusCode.OK, new { data = compobj, checkComp }));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { data = "", checkComp }));
                }
            }

            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
 public HttpResponseMessage SaveRoleDetail(Role roleObj)
 {
     try
     {
         string roleName = roleObj.Name;
         //var surveyObj = new Survey();
         repository = new SVC();
         int  result;
         bool uniqueFlag = true;
         if (roleObj.Id == -1)
         {
             uniqueFlag = repository.checkUniqueRoleName(roleObj);
         }
         if (uniqueFlag)
         {
             roleObj = repository.saveRoleDetails(roleObj);
             return(Request.CreateResponse(HttpStatusCode.OK, new { data = roleObj, action = uniqueFlag, message = "Data saved successfully" }));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.OK, new { data = roleObj, action = uniqueFlag, message = "Already data with the same name exists, please choose a new one" }));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
 public HttpResponseMessage SaveCompetencyDetail(Competency compObj)
 {
     try
     {
         List <Question> queslist = null;
         string          compname = compObj.Name;
         queslist   = compObj.QuestionList;
         repository = new SVC();
         bool checkUniqueComp = true;
         if (compObj.Id == -1)
         {
             checkUniqueComp = repository.checkCompetencyName(compObj);
         }
         if (checkUniqueComp)
         {
             compObj = repository.SaveCompetencyDetail(compObj);
             return(Request.CreateResponse(HttpStatusCode.OK, new { data = compObj, action = true, message = "" }));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.OK, new { data = "", action = false, message = "Competency with same name already exists" }));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
 public HttpResponseMessage FetchSurveyDetail(Survey survey)
 {
     try
     {
         int trainingId = survey.Id;
         repository = new SVC();
         survey     = repository.FetchSurveyDetailById(survey);
         return(Request.CreateResponse(HttpStatusCode.OK, new { data = survey }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
 public HttpResponseMessage StartSurvey(Survey survey)
 {
     try
     {
         //role id, compid, take as a guest, takent by
         repository = new SVC();
         survey     = repository.StartSurvey(survey);
         return(Request.CreateResponse(HttpStatusCode.OK, new { data = survey }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
 public HttpResponseMessage GetCompetencyDeatilsTraining()
 {
     try
     {
         //role id, compid, take as a guest, takent by
         repository = new SVC();
         List <Competency> resultCompetency = null;
         resultCompetency = repository.GetCompetencyNames();
         return(Request.CreateResponse(HttpStatusCode.OK, new { data = resultCompetency }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
 public HttpResponseMessage GetRoleDetailsAdmin()
 {
     try
     {
         //role id, compid, take as a guest, takent by
         repository = new SVC();
         var role = new List <Role>();
         role = repository.GetRoleDetailsAdmin();
         return(Request.CreateResponse(HttpStatusCode.OK, new { data = role }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
        public HttpResponseMessage ViewComp()
        {
            List <Competency> complist = null;

            try
            {
                repository = new SVC();
                complist   = repository.ViewComp();
                return(Request.CreateResponse(HttpStatusCode.OK, new { data = complist }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
 public HttpResponseMessage CompDelete(Competency compobj)
 {
     try
     {
         repository = new SVC();
         //int compid = compobj.Id;
         compobj = repository.DeleteComp(compobj);
         return(Request.CreateResponse(HttpStatusCode.OK, new { data = compobj }));
         // return Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" });
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
 public HttpResponseMessage FetchSurveyHistory(Survey survey)
 {
     try
     {
         string userId    = survey.TakenBy;
         var    surveyObj = new Survey();
         repository = new SVC();
         var surveyList = new List <Survey>();
         surveyList = repository.FetchSurveyHistory(userId);
         return(Request.CreateResponse(HttpStatusCode.OK, new { data = surveyList }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
 public HttpResponseMessage DeleteRoleDetail(Role role)
 {
     try
     {
         int roleId = role.Id;
         //var surveyObj = new Survey();
         repository = new SVC();
         bool result;
         result = repository.deleteRoleDetail(roleId);
         return(Request.CreateResponse(HttpStatusCode.OK, new { data = result }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
     }
 }
        public HttpResponseMessage GetRoleCompetencyDetailsToEdit(Role role)
        {
            //var roleDetails = new List<Role>();
            repository = new SVC();
            List <Competency> resultCompetency = null;
            List <Level>      levelList        = null;
            List <Role>       roleList         = null;

            //roleDetails = repository.GetRoleDetailsAdmin();
            //int roleId;
            //roleId=role.Id;
            roleList = repository.GetRoleCompetencyDetails(role);
            //resultCompetency = repository.GetRoleCompetencyDetails(roleId);
            levelList = repository.getLevelNames();
            return(Request.CreateResponse(HttpStatusCode.OK, new { data1 = roleList, data2 = levelList }));
        }
        public HttpResponseMessage FetchCompetecyDetail(Competency Editobj)
        {
            List <Question> queslist = null;

            try
            {
                repository = new SVC();
                Editobj    = repository.EditComp(Editobj);
                queslist   = repository.GetListofNewQues();
                return(Request.CreateResponse(HttpStatusCode.OK, new { competencyEditObject = Editobj, questionList = queslist }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
        public HttpResponseMessage GetListofNewQues()
        {
            List <Question> queslist = null;

            try
            {
                //role id, compid, take as a guest, takent by
                repository = new SVC();
                queslist   = repository.GetListofNewQues();

                return(Request.CreateResponse(HttpStatusCode.OK, new { data = queslist }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
        public HttpResponseMessage GetListofComp()
        {
            List <Competency> complist = null;

            try
            {
                //role id, compid, take as a guest, takent by
                SVC compdet = new SVC();
                complist = compdet.GetCompetencyNames();

                return(Request.CreateResponse(HttpStatusCode.OK, new { data = complist }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
        public HttpResponseMessage GetCompetencyAndLevel()
        {
            //List<Role> resultRole = null;
            List <Competency> resultCompetency = null;
            List <Level>      level            = null;

            try
            {
                repository       = new SVC();
                resultCompetency = repository.GetCompetencyNames();
                level            = repository.getLevelNames();
                //return Request.CreateResponse(HttpStatusCode.OK, new { data = resultCompetency });
                return(Request.CreateResponse(HttpStatusCode.OK, new { data1 = resultCompetency, data2 = level }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
        public HttpResponseMessage UpdateSurvey([FromBody] Survey surveyObj, [FromUri] string action)
        {
            string level          = string.Empty;
            var    ques           = new List <Question>();
            string Result         = string.Empty;
            var    competencyList = new List <Competency>();

            competencyList = surveyObj.CompetencyList;
            int trainingId = surveyObj.Id;
            int roleId     = surveyObj.RoleId;

            repository = new SVC();
            string result = string.Empty;

            try
            {
                if (action == "next")
                {
                    surveyObj = CalculateLevel(surveyObj, "competency");
                }
                else
                {
                    surveyObj = CalculateLevel(surveyObj, "role");
                }
                // send the result corresponding to the competency in case of next button click
                repository.UpdateSurvey(surveyObj);
                if (action == "continue")
                {
                    result = repository.updateSurveyResult(surveyObj);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, new { data = result }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
        // GET: api/TraningService
        public HttpResponseMessage GetRolesDetails()
        {
            List <Role>       resultRole       = null;
            List <Competency> resultCompetency = null;

            try
            {
                System.Collections.Specialized.NameValueCollection queryStringParams = HttpContext.Current.Request.QueryString;
                if (string.IsNullOrEmpty(queryStringParams["option"]))
                {
                    //throw an error message to the client that the querystring parameters are incorrect
                    return(Request.CreateResponse(HttpStatusCode.OK, new { error = "incorrect params" }));
                }
                string option = queryStringParams["option"].ToLower();
                //check for sub module name, get the data from SP and convert to JSON.
                repository = new SVC();
                if (option == "role")
                {
                    resultRole = repository.GetRoleNames();
                    return(Request.CreateResponse(HttpStatusCode.OK, new { data = resultRole }));
                }
                else if (option == "competency")
                {
                    resultCompetency = repository.GetCompetencyNames();
                    return(Request.CreateResponse(HttpStatusCode.OK, new { data = resultCompetency }));
                }
                else
                {
                    //throw an message back to client invalid option
                    return(Request.CreateResponse(HttpStatusCode.OK, new { error = "incorrect option" }));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { error = "sorry an error occured" }));
            }
        }
        public EDI835SchemaModel ParseEDI835(string fileText)
        {
            bool   payerSeg     = false;
            bool   payeeSeg     = false;
            string claimSegment = string.Empty;
            string segmentValue = string.Empty;

            string[] ediTextArray         = fileText.Split("~");
            CLP      clp                  = null;
            SVC      svc                  = null;
            bool     findNextCLP          = false;
            bool     isServiceLineVisited = false;

            foreach (string stringSegment in ediTextArray)
            {
                string[] segmentArray = stringSegment.Split("*");
                if (segmentArray != null)
                {
                    IEnumerable <string> values = Enum.GetValues(typeof(EDI835Segments))
                                                  .OfType <EDI835Segments>()
                                                  .Select(s => Convert.ToString(s));

                    if (values.Contains(segmentArray[0].TrimStart()))
                    {
                        if (segmentArray[0].TrimStart() != "CLP" && findNextCLP == true)
                        {
                            continue;
                        }
                        //else continue;
                        segmentValue = segmentArray[0].TrimStart();
                        if (claimSegment == "CLP")
                        {
                            segmentValue = "CLP";
                        }
                        switch (segmentValue)
                        {
                        case "ISA":
                        {
                            ISA ISA = GetSegmentInfo <ISA>(new ISA(), segmentArray);
                            ediSchemaModel.ISA = ISA;
                            break;
                        }

                        case "GS":
                        {
                            GS GS = GetSegmentInfo <GS>(new GS(), segmentArray);
                            ediSchemaModel.GS = GS;
                            break;
                        }

                        case "ST":
                        {
                            ST ST = GetSegmentInfo <ST>(new ST(), segmentArray);
                            ediSchemaModel.ST = ST;
                            break;
                        }

                        case "BPR":
                        {
                            BPR BPR = GetSegmentInfo <BPR>(new BPR(), segmentArray);
                            ediSchemaModel.BPR = BPR;
                            break;
                        }

                        case "TRN":
                        {
                            TRN TRN = GetSegmentInfo <TRN>(new TRN(), segmentArray);
                            ediSchemaModel.TRN = TRN;
                            break;
                        }

                        case "DTM":
                        {
                            DTM DTM = GetSegmentInfo <DTM>(new DTM(), segmentArray);
                            ediSchemaModel.DTM = DTM;
                            break;
                        }

                        case "N1":
                        {
                            if (segmentArray[1] == "PR")
                            {
                                N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray);
                                ediSchemaModel.PayerInfo = N1;
                                payerSeg = true;
                            }
                            else if (segmentArray[1] == "PE")
                            {
                                N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray);
                                ediSchemaModel.PayeeInfo = N1;
                                payeeSeg = true;
                            }
                            break;
                        }

                        case "N3":
                        {
                            if (payerSeg)
                            {
                                N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray);
                                ediSchemaModel.PayerAddress = N3;
                            }
                            else if (payeeSeg)
                            {
                                N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray);
                                ediSchemaModel.PayeeAddress = N3;
                            }

                            break;
                        }

                        case "N4":
                        {
                            if (payerSeg)
                            {
                                N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray);
                                ediSchemaModel.PayerCityStateZip = N4;
                                payerSeg = false;
                            }
                            else if (payeeSeg)
                            {
                                N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray);
                                ediSchemaModel.PayeeCityStateZip = N4;
                                payeeSeg = false;
                            }
                            break;
                        }

                        case "CLP":
                        {
                            claimSegment = "CLP";
                            switch (segmentArray[0].TrimStart())
                            {
                            case "CLP":
                            {
                                findNextCLP = false;
                                if (clp != null)
                                {
                                    ediSchemaModel.CLPList.Add(clp);
                                    isServiceLineVisited = false;
                                    clp = null;
                                }
                                clp = GetSegmentInfo <CLP>(new CLP(), segmentArray);
                                break;
                            }

                            case "SVC":
                            {
                                //if (svc != null)
                                //{
                                //    if (clp.SVCList == null) clp.SVCList = new List<SVC>();
                                //    clp.SVCList.Add(svc);
                                //    svc = null;
                                //}
                                svc = GetSegmentInfo <SVC>(new SVC(), segmentArray);
                                if (clp != null && clp.SVCList == null)
                                {
                                    clp.SVCList = new List <SVC>();
                                }

                                clp.SVCList.Add(svc);
                                isServiceLineVisited = true;
                                break;
                            }

                            case "CAS":
                            {
                                if (isServiceLineVisited)
                                {
                                    CAS CAS = GetSegmentInfo <CAS>(new CAS(), segmentArray);
                                    if (svc.SVCAdjList == null)
                                    {
                                        svc.SVCAdjList = new List <CAS>();
                                    }
                                    svc.SVCAdjList.Add(CAS);
                                    CAS = null;
                                }
                                break;
                            }

                            case "REF":
                            {
                                if (segmentArray[1].Trim() == "6R" && svc != null && svc.REF == null)
                                {
                                    svc.REF = new REF();
                                    svc.REF = GetSegmentInfo <REF>(new REF(), segmentArray);
                                }
                                break;
                            }

                            case "GE":
                            {
                                if (clp != null)
                                {
                                    ediSchemaModel.CLPList.Add(clp);
                                    isServiceLineVisited = false;
                                    clp         = null;
                                    findNextCLP = true;
                                }
                                break;
                            }

                            default:
                            {
                                break;
                            }
                            }
                            break;
                        }
                        }
                    }
                }
            }
            return(ediSchemaModel);
        }