Ejemplo n.º 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);
        }
        // GET: SkillTraining/Edit/5
        public async Task <ActionResult> Edit(int id, string trainingId, int skillId, int competencyId, int points, int GEOId, bool isAssessmentRequired, bool isMandatory)
        {
            InitializeServiceClient();



            SkillTraining skillTraining = new SkillTraining();
            string        dataStore     = ConfigurationManager.AppSettings["DATASTORE"].ToString();

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

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


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

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

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

            skillTraining.skills = await response.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);
            }
            skillTraining.id = id;
            //skillTraining.trainingName = trainingName;
            //skillTraining.skill = skill;
            skillTraining.skillId = skillId;
            //skillTraining.selectedSkill = skillId;
            // skillTraining.competency = competency;
            skillTraining.competencyLevelId = competencyId;
            //skillTraining.selectedCompetence = competencyId;
            //skillTraining.selectedGEO = GEO;
            //Session["GEO"] = GEO;
            //Session["Skill"] = skill;
            //Session["Competency"] = competency;
            //Session["Training"] = trainingName;
            skillTraining.trainingId = trainingId;
            skillTraining.points     = points;
            // skillTraining.GEO = GEO;
            skillTraining.GEOId = GEOId;
            skillTraining.isAssessmentRequired = isAssessmentRequired;
            skillTraining.isMandatory          = isMandatory;
            return(View(skillTraining));
        }
        // GET: SkillTraining/Create
        public async Task <ActionResult> Create()
        {
            InitializeServiceClient();
            SkillTraining training  = new SkillTraining();
            string        dataStore = ConfigurationManager.AppSettings["DATASTORE"].ToString();

            if (dataStore == DataStore.SQLServer)
            {
                HttpResponseMessage competencyResponse = await client.PostAsJsonAsync("Competency/GetAllCompetenceList", req);

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

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

                training.GEOs = await geoResponse.Content.ReadAsAsync <List <GEO> >();
            }
            else
            {
                HttpResponseMessage competencyResponse = await client.PostAsJsonAsync("Competency/GetAllCompetenceList", req);

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

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

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

            training.trainings = new List <SkillCompetencyLevelTraining>();
            HttpResponseMessage mastertrainingResponse = await client.PostAsJsonAsync("Training/GetMasterTrainings", req);

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

            foreach (var train in skillTrainings)
            {
                SkillCompetencyLevelTraining item = new SkillCompetencyLevelTraining();
                item.Title = train.trainingName;
                item.ID    = train.id;
                training.trainings.Add(item);
            }

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

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

            return(View(training));
        }
 public static int SkillRank(this Character character, SkillTraining training)
 {
     int rank = 0;
     switch(training)
     {
         case SkillTraining.Athletics:
             rank = character.Abilities.Strength.Modifier();
             break;
         case SkillTraining.Acrobatics:
         case SkillTraining.SlieghtOfHand:
         case SkillTraining.Stealth:
             rank = character.Abilities.Dexterity.Modifier();
             break;
         case SkillTraining.Arcana:
         case SkillTraining.History:
         case SkillTraining.Investigation:
         case SkillTraining.Nature:
         case SkillTraining.Religion:
             rank = character.Abilities.Intelligence.Modifier();
             break;
         case SkillTraining.AnimalHandling:
         case SkillTraining.Insight:
         case SkillTraining.Medicine:
         case SkillTraining.Perception:
         case SkillTraining.Survival:
             rank = character.Abilities.Wisdom.Modifier();
             break;
         case SkillTraining.Deception:
         case SkillTraining.Intimidation:
         case SkillTraining.Performance:
         case SkillTraining.Persuasion:
             rank = character.Abilities.Charisma.Modifier();
             break;
     }
     if(character.SkillProfiencies.HasFlag(training))
     {
         rank += character.ProfiencyBonus();
     }
     if (character.SkillExcellencies.HasFlag(training))
     {
         rank += character.ProfiencyBonus();
     }
     return rank;
 }
        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));
            }
        }