Beispiel #1
0
        public bool UpdateSkillTraining(SkillTrainingRequest req)
        {
            bool result = false;

            try
            {
                SkillTraining skillTraining = new SkillTraining();
                skillTraining.selectedTraining     = req.selectedTraining;
                skillTraining.selectedCompetence   = req.selectedCompetence;
                skillTraining.selectedGEO          = req.selectedGEO;
                skillTraining.selectedSkill        = req.selectedSkill;
                skillTraining.isMandatory          = req.isMandatory;
                skillTraining.isAssessmentRequired = req.isAssessmentRequired;
                skillTraining.assessmentId         = req.assessmentId;
                skillTraining.points = req.points;
                skillTraining.id     = req.id;

                SqlSvrDAL dal = new SqlSvrDAL(req.ClientInfo);
                result = dal.UpdateSkillTraining(skillTraining);
            }
            catch (Exception ex)
            {
                //  LogHelper.AddLog("TrainingController,UpdateSkillTraining", ex.Message, ex.StackTrace, "HCL.Academy.Service", req.ClientInfo.emailId);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(result);
        }
Beispiel #2
0
        public List <SkillTraining> GetTrainingsByID(SkillTrainingRequest req)
        {
            List <SkillTraining> trainingCourses = new List <SkillTraining>();

            try
            {
                SqlSvrDAL dal = new SqlSvrDAL(req.ClientInfo);
                trainingCourses = dal.GetTrainingsByID(Convert.ToInt32(req.selectedSkill), Convert.ToInt32(req.selectedCompetence), Convert.ToInt32(req.selectedTraining));
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("TrainingController,GetTrainingsByID", ex.Message, ex.StackTrace, "HCL.Academy.Service", req.ClientInfo.emailId);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(trainingCourses);
        }
        public async Task <ActionResult> Create(SkillTraining skillTraining)
        {
            try
            {
                InitializeServiceClient();
                int? assessmentID = null;
                bool result       = false;
                SkillwiseAssessmentsRequest assessmentRequest = new SkillwiseAssessmentsRequest();
                assessmentRequest.ClientInfo   = req.ClientInfo;
                assessmentRequest.CompetenceId = Convert.ToInt32(skillTraining.selectedCompetence);
                assessmentRequest.SkillId      = Convert.ToInt32(skillTraining.selectedSkill);
                HttpResponseMessage assessmentResponse = await client.PostAsJsonAsync("Assessment/GetAssessments", assessmentRequest);

                List <Assessment> assessmentsList = await assessmentResponse.Content.ReadAsAsync <List <Assessment> >();

                if (assessmentsList.Count > 0)
                {
                    assessmentID = assessmentsList.FirstOrDefault().AssessmentId;
                }
                skillTraining.assessmentId = assessmentID;
                string trainingName = skillTraining.selectedTraining;
                skillTraining.trainingName = trainingName;
                List <SkillTraining> skills = new List <SkillTraining>();

                SkillTrainingRequest skillTrainigRequest = new SkillTrainingRequest();
                skillTrainigRequest.ClientInfo         = req.ClientInfo;
                skillTrainigRequest.selectedSkill      = skillTraining.selectedSkill;
                skillTrainigRequest.selectedCompetence = skillTraining.selectedCompetence;
                skillTrainigRequest.selectedTraining   = skillTraining.selectedTraining;
                HttpResponseMessage skillTrainigResponse = await client.PostAsJsonAsync("Training/GetTrainingsByID", skillTrainigRequest);

                skills = await skillTrainigResponse.Content.ReadAsAsync <List <SkillTraining> >();

                if (skills != null)
                {
                    if (skills.Count > 0)
                    {
                        TempData["Message"] = "Combination already exists";
                        TempData.Keep();
                        return(RedirectToAction("Index"));
                    }
                }
                SkillTrainingRequest skilltrainingRequest = new SkillTrainingRequest();
                skilltrainingRequest.ClientInfo           = req.ClientInfo;
                skilltrainingRequest.selectedTraining     = skillTraining.selectedTraining;
                skilltrainingRequest.selectedCompetence   = skillTraining.selectedCompetence;
                skilltrainingRequest.selectedGEO          = skillTraining.selectedGEO;
                skilltrainingRequest.selectedSkill        = skillTraining.selectedSkill;
                skilltrainingRequest.isMandatory          = skillTraining.isMandatory;
                skilltrainingRequest.isAssessmentRequired = skillTraining.isAssessmentRequired;
                skilltrainingRequest.assessmentId         = skillTraining.assessmentId;
                skilltrainingRequest.points = skillTraining.points;
                HttpResponseMessage trainingResponse = await client.PostAsJsonAsync("Training/AddSkillTraining", skilltrainingRequest);

                result = await trainingResponse.Content.ReadAsAsync <bool>();

                if (result)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("SkillTrainingController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
                return(View(skillTraining));
            }
        }
        public async Task <ActionResult> Edit(int id, SkillTraining skillTraining, string category, string skillType)
        {
            try
            {
                InitializeServiceClient();
                bool result       = false;
                int? assessmentID = null;

                SkillwiseAssessmentsRequest assessmentRequest = new SkillwiseAssessmentsRequest();
                assessmentRequest.ClientInfo   = req.ClientInfo;
                assessmentRequest.CompetenceId = Convert.ToInt32(skillTraining.competencyLevelId);
                assessmentRequest.SkillId      = Convert.ToInt32(skillTraining.skillId);
                HttpResponseMessage assessmentResponse = await client.PostAsJsonAsync("Assessment/GetAssessments", assessmentRequest);

                List <Assessment> assessmentsList = await assessmentResponse.Content.ReadAsAsync <List <Assessment> >();

                if (assessmentsList.Count > 0)
                {
                    assessmentID = assessmentsList.FirstOrDefault().AssessmentId;
                }
                skillTraining.assessmentId = assessmentID;

                HttpResponseMessage geoResponse = await client.PostAsJsonAsync("Geo/GetAllGEOs", req);

                skillTraining.GEOs = await geoResponse.Content.ReadAsAsync <List <GEO> >();

                HttpResponseMessage competencyResponse = await client.PostAsJsonAsync("Competency/GetCompetenciesBySkillId?skillId=" + skillTraining.skillId, req);

                skillTraining.competences = await competencyResponse.Content.ReadAsAsync <List <Competence> >();

                //        HttpResponseMessage competenceResponse = await client.PostAsJsonAsync("Competency/GetAllCompetenceList", req);
                //      skillTraining.competences = await competenceResponse.Content.ReadAsAsync<List<Competence>>();

                HttpResponseMessage skillResponse = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                skillTraining.skills = await skillResponse.Content.ReadAsAsync <List <Skill> >();

                List <SkillTraining> training = new List <SkillTraining>();
                skillTraining.trainings = new List <SkillCompetencyLevelTraining>();

                HttpResponseMessage mastertrainingResponse = await client.PostAsJsonAsync("Training/GetMasterTrainings", req);

                training = await mastertrainingResponse.Content.ReadAsAsync <List <SkillTraining> >();

                foreach (var train in training)
                {
                    SkillCompetencyLevelTraining item = new SkillCompetencyLevelTraining();
                    item.Title = train.trainingName;
                    item.ID    = train.id;
                    skillTraining.trainings.Add(item);
                }
                List <SkillTraining> skills = new List <SkillTraining>();

                SkillTrainingRequest skillTrainigRequest = new SkillTrainingRequest();
                skillTrainigRequest.ClientInfo         = req.ClientInfo;
                skillTrainigRequest.selectedSkill      = skillTraining.skillId.ToString();
                skillTrainigRequest.selectedCompetence = skillTraining.competencyLevelId.ToString();
                skillTrainigRequest.selectedTraining   = skillTraining.trainingId.ToString();
                //HttpResponseMessage skillTrainigResponse = await client.PostAsJsonAsync("Training/GetTrainingsByID", skillTrainigRequest);
                //skills = await skillTrainigResponse.Content.ReadAsAsync<List<SkillTraining>>();

                //if (skills.Count > 0)
                //{
                //    TempData["Message"] = "Combination already exists";
                //    TempData.Keep();
                //    return RedirectToAction("Index");
                //}

                SkillTrainingRequest updateSkillTrainigRequest = new SkillTrainingRequest();
                updateSkillTrainigRequest.ClientInfo         = req.ClientInfo;
                updateSkillTrainigRequest.selectedSkill      = skillTraining.skillId.ToString();
                updateSkillTrainigRequest.selectedCompetence = skillTraining.competencyLevelId.ToString();
                updateSkillTrainigRequest.selectedTraining   = skillTraining.trainingId.ToString();
                updateSkillTrainigRequest.id                   = skillTraining.id;
                updateSkillTrainigRequest.GEO                  = skillTraining.GEOId.ToString();
                updateSkillTrainigRequest.selectedGEO          = skillTraining.GEOId.ToString();
                updateSkillTrainigRequest.isAssessmentRequired = skillTraining.isAssessmentRequired;
                updateSkillTrainigRequest.isMandatory          = skillTraining.isMandatory;
                updateSkillTrainigRequest.assessmentId         = skillTraining.assessmentId;
                updateSkillTrainigRequest.points               = skillTraining.points;
                updateSkillTrainigRequest.selectedTraining     = skillTraining.trainingId.ToString();
                HttpResponseMessage skillTrainigUpdateResponse = await client.PostAsJsonAsync("Training/UpdateSkillTraining", updateSkillTrainigRequest);

                result = await skillTrainigUpdateResponse.Content.ReadAsAsync <bool>();

                if (result)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["msg"] = "Update unsuccessful";
                    return(View(skillTraining));
                }
            }
            catch
            {
                return(View(skillTraining));
            }
        }