public bool UpdateAssessmentMaster(AssessmentMasterRequest request)
        {
            AssessmentMaster AM = new AssessmentMaster();

            AM.AssessmentId         = request.AssessmentId;
            AM.AssessmentName       = request.AssessmentName;
            AM.Description          = request.Description;
            AM.AssessmentLink       = request.AssessmentLink;
            AM.AssessmentTimeInMins = request.AssessmentTimeInMins;
            AM.SelCompetencyId      = request.SelCompetencyId;
            AM.SelSkillId           = request.SelSkillId;
            AM.SelTrainingId        = request.SelTrainingId;
            AM.PassingMarks         = request.PassingMarks;
            AM.IsMandatory          = request.IsMandatory;
            AM.Points = request.Points;

            bool response = false;

            try
            {
                SqlSvrDAL dal = new SqlSvrDAL(request.ClientInfo);
                response = dal.UpdateAssessmentMaster(AM);
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Service", request.ClientInfo.emailId);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(response);
        }
        public async Task <ActionResult> Create(AssessmentMaster AM)
        {
            InitializeServiceClient();
            List <Skill>      skilllist      = new List <Skill>();
            List <Competence> competencelist = new List <Competence>();
            string            SelSkill       = String.Empty;

            try
            {
                //var errors = ModelState.Values.SelectMany(v => v.Errors);
                if (ModelState.IsValid)
                {
                    AssessmentMasterRequest AMR = new AssessmentMasterRequest();

                    AMR.AssessmentLink       = AM.AssessmentLink;
                    AMR.AssessmentName       = AM.AssessmentName;
                    AMR.AssessmentTimeInMins = AM.AssessmentTimeInMins;
                    AMR.Description          = AM.Description;
                    AMR.IsMandatory          = AM.IsMandatory;
                    AMR.PassingMarks         = AM.PassingMarks;
                    AMR.Points          = AM.Points;
                    AMR.SelCompetencyId = AM.SelCompetencyId;
                    AMR.SelSkillId      = AM.SelSkillId;
                    AMR.SelTrainingId   = AM.SelTrainingId;
                    HttpResponseMessage response = await client.PostAsJsonAsync("AssessmentMaster/SaveAssessmentMaster", AMR);

                    client.Dispose();
                    TempData["CreateSuccess"] = true;
                    TempData.Keep();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    AssessmentMaster am = new AssessmentMaster();
                    try
                    {
                        HttpResponseMessage response = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                        skilllist = await response.Content.ReadAsAsync <List <Skill> >();

                        am.Skills = skilllist;

                        response = await client.PostAsJsonAsync("Competency/GetAllCompetencyLevels", req);

                        competencelist = await response.Content.ReadAsAsync <List <Competence> >();

                        am.Competencies = competencelist;

                        response = await client.PostAsJsonAsync("Training/GetAllTrainings", req);

                        List <Training> traininglist = await response.Content.ReadAsAsync <List <Training> >();

                        am.Trainings = traininglist;
                    }
                    catch (Exception ex)
                    {
                        //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                        TelemetryClient telemetry = new TelemetryClient();
                        //telemetry.TrackException(ex); TelemetryClient telemetry = new TelemetryClient();
                        telemetry.TrackException(ex);
                    }
                    return(View(am));
                }
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(View());
        }
        public async Task <ActionResult> Edit(AssessmentMaster AM)
        {
            InitializeServiceClient();
            List <Skill>      skilllist      = new List <Skill>();
            List <Competence> competencelist = new List <Competence>();
            string            SelSkill       = String.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    AssessmentMasterRequest AMR = new AssessmentMasterRequest();
                    AMR.AssessmentId         = AM.AssessmentId;
                    AMR.AssessmentLink       = AM.AssessmentLink;
                    AMR.AssessmentName       = AM.AssessmentName;
                    AMR.AssessmentTimeInMins = AM.AssessmentTimeInMins;
                    AMR.Description          = AM.Description;
                    AMR.IsMandatory          = AM.IsMandatory;
                    AMR.PassingMarks         = AM.PassingMarks;
                    AMR.Points = AM.Points;
                    //AMR.SelectedCompetency = AM.SelectedCompetency;
                    AMR.SelCompetencyId = AM.SelCompetencyId;
                    //AMR.SelectedSkill = AM.SelectedSkill;
                    AMR.SelSkillId = AM.SelSkillId;
                    //AMR.SelectedTraining = AM.SelectedTraining;
                    AMR.SelTrainingId = AM.SelTrainingId;
                    HttpResponseMessage response = await client.PostAsJsonAsync("AssessmentMaster/UpdateAssessmentMaster", AMR);

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

                    if (result)
                    {
                        ViewBag.Success = true;
                    }
                    else
                    {
                        ViewBag.Success = false;
                    }
                    response = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                    skilllist = await response.Content.ReadAsAsync <List <Skill> >();

                    AM.Skills = skilllist;
                    SelSkill  = skilllist.Where(x => x.SkillId == AM.SelSkillId).FirstOrDefault().SkillName;
                    response  = await client.PostAsJsonAsync("Competency/GetCompetenciesBySkillName?skillName=" + SelSkill, req);

                    competencelist = await response.Content.ReadAsAsync <List <Competence> >();

                    AM.Competencies = competencelist;

                    UserTrainingsRequest utr = new UserTrainingsRequest();
                    //utr.SkillId = skilllist.Where(x=>x.SkillName == SelectedSkill).FirstOrDefault().SkillId;
                    utr.SkillId = AM.SelSkillId;
                    //utr.CompetenceId = competencelist.Where(x=>x.CompetenceName == SelectedCompetency).FirstOrDefault().CompetenceId;
                    utr.CompetenceId = AM.SelCompetencyId;
                    HttpResponseMessage responseMessage = await client.PostAsJsonAsync("Training/GetTrainings", utr);

                    List <Training> traininglist = await responseMessage.Content.ReadAsAsync <List <Training> >();

                    AM.Trainings = traininglist;
                }
                else
                {
                    AssessmentMaster am = new AssessmentMaster();
                    try
                    {
                        HttpResponseMessage response = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                        skilllist = await response.Content.ReadAsAsync <List <Skill> >();

                        am.Skills = skilllist;

                        response = await client.PostAsJsonAsync("Competency/GetAllCompetencyLevels", req);

                        competencelist = await response.Content.ReadAsAsync <List <Competence> >();

                        am.Competencies = competencelist;

                        response = await client.PostAsJsonAsync("Training/GetAllTrainings", req);

                        List <Training> traininglist = await response.Content.ReadAsAsync <List <Training> >();

                        am.Trainings = traininglist;
                    }
                    catch (Exception ex)
                    {
                        //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                        TelemetryClient telemetry = new TelemetryClient();
                        telemetry.TrackException(ex);
                    }
                    return(View(am));
                }
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("AssessmentMasterController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
            }
            return(View(AM));
        }