Esempio n. 1
0
        public async Task GetEnabledCompetenciesTest()
        {
            var objA = new Competency()
            {
                Id           = Guid.NewGuid(),
                Name         = "Test",
                IsEnabled    = true,
                CreatedOnUtc = DateTime.UtcNow,
            };

            using var srv = new TestServer(TestHostBuilder <Startup, UnigrationODataTestStartup>()
                                           .ConfigureTestServices(x =>
            {
                ExecuteOnContext <CompetenciesContext>(x, db =>
                {
                    db.Competencies.Add(objA);
                });
            })
                                           );
            var client = srv.CreateClient();

            GenerateAuthHeader(client, GenerateTestToken());

            var resp = await client.GetStringAsync("odata/v1/competencies?$count=true");

            TestContext.WriteLine($"Server Reponse: {resp}");
            var envelope = JsonConvert.DeserializeObject <ODataEnvelope <Competency> >(resp);

            Assert.AreEqual(objA.CreatedOnUtc, envelope.Value.First().CreatedOnUtc.ToUniversalTime());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutCompetency([FromRoute] int id, [FromBody] Competency competency)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != competency.CompetencyId)
            {
                return(BadRequest());
            }

            _context.Entry(competency).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CompetencyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> EditCompetency(Competency item)
        {
            var model = await _context.Competencies.SingleOrDefaultAsync(b => b.Id == item.Id);

            await TryUpdateModelAsync(model);

            model.LastUpdated = DateTime.Now.Date;
            model.UpdatedBy   = "user";
            await _context.SaveChangesAsync();

            string level;

            if (item.IsCompanyPolicy)
            {
                level = "ORG";
            }
            else if (item.GradeGroupId.HasValue)
            {
                level = "GRADE_GROUP";
            }
            else
            {
                level = "JOB_GRADE";
            }

            return(RedirectToAction("CompetenciesList", new { level = level }));
        }
Esempio n. 4
0
        public async Task DeleteCompetencyTest()
        {
            var objA = new Competency
            {
                Id        = Guid.NewGuid(),
                Name      = Guid.NewGuid().ToString(),
                IsEnabled = true,
            };

            using var srv = new TestServer(TestHostBuilder <Startup, IntegrationTestStartup>());
            var client = srv.CreateClient();

            GenerateAuthHeader(client, GenerateTestToken());

            var resp = await client.PostAsJsonAsync($"api/v1/Competencies.json?id={objA.Id}", objA);

            _    = resp.EnsureSuccessStatusCode();
            objA = await DeserializeResponseAsync <Competency>(resp);

            //Delete
            resp = await client.DeleteAsync($"api/v1/Competencies.json?id={objA.Id}");

            _ = resp.EnsureSuccessStatusCode();
            Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode);
            var result = await DeserializeResponseAsync <Competency>(resp);

            Assert.IsNotNull(result.UpdatedBy);
            Assert.IsFalse(result.IsEnabled);
        }
 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" }));
     }
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Competency sComp = (Competency)e.Parameter;

            if (viewModel == null)
            {
                viewModel                      = new UpdateViewModel(sComp);
                this.Student                   = viewModel.Student;
                this.sQual                     = viewModel.Qualification;
                App.tempComp                   = sComp;
                stackComp.DataContext          = sComp;
                stackStudentDetail.DataContext = Student;
                tbkQual.Text                   = sQual.QualName;
                listView1.ItemsSource          = viewModel.Qualifications;
                foreach (var qual in viewModel.Qualifications)
                {
                    List <Competency> compList = new List <Competency>();
                    compList          = Competency.GetCompetencyList(Student.UserID, qual.QualCode).Where(c => c.CompletionStatus == "C").ToList();
                    qual.Competencies = compList;
                }
            }
            else
            {
                //Frame.Navigate(typeof(views.MainPage));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Handles the Click event of the btnEdit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            ResidencyService <Competency> service = new ResidencyService <Competency>();
            Competency item = service.Get(hfCompetencyId.ValueAsInt());

            ShowEditDetails(item);
        }
        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" }));
            }
        }
        private async void BtnUpdateData_Click(object sender, RoutedEventArgs e)
        {
            Competency sComp     = App.tempComp;
            string     studentID = Student.UserID;
            string     qualID    = sQual.QualCode;
            string     compID    = sComp.TafeCode;
            string     status;

            if (comboStatus.SelectedIndex != -1)
            {
                status = ((ComboBoxItem)comboStatus.SelectedItem).Content.ToString();
            }
            else
            {
                status = sComp.CompletionStatus;
            }
            string comment = txbComment.Text;

            if (sComp.UpdateToDB(studentID, qualID, compID, status, comment))
            {
                var message = new MessageDialog("Update successful.");
                await message.ShowAsync();
            }

            else
            {
                var message = new MessageDialog("Update failed. Please contact admin staff");
                await message.ShowAsync();
            }
        }
Esempio n. 10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IsRequired,Skill,TypeId")] Competency competency)
        {
            if (id != competency.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(competency);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompetencyExists(competency.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TypeId"] = new SelectList(_context.CompetencyTypes, "Id", "Id", competency.TypeId);
            return(View(competency));
        }
Esempio n. 11
0
        public async Task HideDisabledCompetenciesTest()
        {
            var objA = new Competency()
            {
                Id        = Guid.NewGuid(),
                Name      = "Test",
                IsEnabled = false
            };

            using var srv = new TestServer(TestHostBuilder <Startup, UnigrationODataTestStartup>()
                                           .ConfigureTestServices(x =>
            {
                ExecuteOnContext <CompetenciesContext>(x, db =>
                {
                    db.Competencies.Add(objA);
                });
            })
                                           );
            var client = srv.CreateClient();

            GenerateAuthHeader(client, GenerateTestToken());

            var resp = await client.GetAsync("odata/v1/competencies?$count=true");

            var objB = await DeserializeResponseAsync <ODataEnvelope <Competency> >(resp);

            Assert.AreEqual(0, objB.Value.Count());
        }
Esempio n. 12
0
 public UpdateViewModel(Competency sComp)
 {
     this.Student        = student.GetStudentById(studentID);
     this.Qualification  = sQual;
     this.Qualifications = new ObservableCollection <Qualification>(Qualification.GetQualificationList(Student.UserID).ToList().OrderBy(q => q.QualName));
     this.Competency     = sComp;
 }
Esempio n. 13
0
        public void Delete(int id)
        {
            Competency competency = dbContext.Competencies.Find(id);

            dbContext.Entry(competency).State = EntityState.Deleted;
            Save();
        }
        public void SelfAssessmentCompetency_action_should_return_view_result()
        {
            // Given
            const int competencyNumber = 1;
            var       selfAssessment   = SelfAssessmentHelper.CreateDefaultSelfAssessment();
            var       competency       = new Competency();

            A.CallTo(() => selfAssessmentService.GetSelfAssessmentForCandidateById(CandidateId, SelfAssessmentId))
            .Returns(selfAssessment);
            A.CallTo(() => selfAssessmentService.GetNthCompetency(competencyNumber, selfAssessment.Id, CandidateId))
            .Returns(competency);
            A.CallTo(() => frameworkService.GetSelectedCompetencyFlagsByCompetecyId(competency.Id))
            .Returns(new List <Data.Models.Frameworks.CompetencyFlag>()
            {
            });
            var expectedModel = new SelfAssessmentCompetencyViewModel(
                selfAssessment,
                competency,
                competencyNumber,
                selfAssessment.NumberOfCompetencies
                );

            // When
            var result = controller.SelfAssessmentCompetency(SelfAssessmentId, competencyNumber);

            // Then
            result.Should().BeViewResult()
            .WithViewName("SelfAssessments/SelfAssessmentCompetency")
            .Model.Should().BeEquivalentTo(expectedModel);
        }
Esempio n. 15
0
        public ActionResult Delete(int competencyId)
        {
            //look up a student in the db
            Competency competency = competenciesRepository.Find(competencyId);

            return(View(competency));
        }
Esempio n. 16
0
        /// <summary>
        /// Handles the Click event of the btnCancel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            SetEditMode(false);

            if (hfCompetencyId.ValueAsInt().Equals(0))
            {
                // Cancelling on Add.  Return to Grid
                // if this page was called from the Track Detail page, return to that
                string trackId = PageParameter("trackId");
                if (!string.IsNullOrWhiteSpace(trackId))
                {
                    Dictionary <string, string> qryString = new Dictionary <string, string>();
                    qryString["trackId"] = trackId;
                    NavigateToParentPage(qryString);
                }
                else
                {
                    NavigateToParentPage();
                }
            }
            else
            {
                // Cancelling on Edit.  Return to Details
                ResidencyService <Competency> service = new ResidencyService <Competency>();
                Competency item = service.Get(hfCompetencyId.ValueAsInt());
                ShowReadonlyDetails(item);
            }
        }
Esempio n. 17
0
        public async Task DeleteCompetencyTest()
        {
            var objA = new Competency
            {
                Id        = Guid.NewGuid(),
                Name      = Guid.NewGuid().ToString(),
                IsEnabled = true,
            };

            using var srv = new TestServer(TestHostBuilder <Startup, UnigrationWebApiTestStartup>()
                                           .ConfigureTestServices(x =>
            {
                ExecuteOnContext <CompetenciesContext>(x, db =>
                {
                    _ = db.Competencies.Add(objA);
                });
            })
                                           );
            var client = srv.CreateClient();

            GenerateAuthHeader(client, GenerateTestToken());
            //Update
            var resp = await client.DeleteAsync($"api/v1/Competencies.json?id={objA.Id}");

            Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode);
            var result = await DeserializeResponseAsync <Competency>(resp);

            Assert.AreEqual("*****@*****.**", result.UpdatedBy);
            Assert.IsFalse(result.IsEnabled);
        }
Esempio n. 18
0
        public ActionResult DeleteConfirmed(int id)
        {
            Competency competency = db.Competencies.Find(id);

            db.Competencies.Remove(competency);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 19
0
        public ActionResult dropCourse(int id)
        {
            Competency compObj     = new Competency();
            int        rowAffected = 0;

            rowAffected = compObj.dropCourse(id);
            return(RedirectToAction("viewCompetency"));
        }
Esempio n. 20
0
        public ActionResult addCourses()
        {
            Competency compObj = new Competency();
            var        list    = compObj.getCompLevel();

            compObj.selectCompLevel = compObj.GetSelectListItem(list);
            return(View(compObj));
        }
Esempio n. 21
0
 public static TextScenario ToModel(this SeedTextScenarioAddDto dto, Competency competency)
 {
     return(new TextScenario {
         Code = dto.Code,
         Competency = competency,
         ScenarioText = dto.ScenarioText,
         Questions = dto.Questions.ToModel(),
     });
 }
Esempio n. 22
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        /// <param name="trackId">The residency track id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?trackId)
        {
            // return if unexpected itemKey
            if (itemKey != "competencyId")
            {
                return;
            }

            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            Competency competency = null;

            if (!itemKeyValue.Equals(0))
            {
                competency = new ResidencyService <Competency>().Get(itemKeyValue);
            }
            else
            {
                competency = new Competency {
                    Id = 0
                };
                competency.TrackId = trackId ?? 0;
                competency.Track   = new ResidencyService <Track>().Get(competency.TrackId);
            }

            hfCompetencyId.Value = competency.Id.ToString();
            hfTrackId.Value      = competency.TrackId.ToString();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Competency.FriendlyTypeName);
            }

            if (readOnly)
            {
                btnEdit.Visible = false;
                ShowReadonlyDetails(competency);
            }
            else
            {
                btnEdit.Visible = true;
                if (competency.Id > 0)
                {
                    ShowReadonlyDetails(competency);
                }
                else
                {
                    ShowEditDetails(competency);
                }
            }
        }
Esempio n. 23
0
        public ActionResult getCourses(Competency competency)
        {
            string     compLevel = competency.compLevel;
            Competency compObj   = new Competency();

            Session["compLevel"]         = compObj.compLevel;
            compObj.getCoursesFromDBList = compObj.getCoursesFromDB(compLevel);
            return(View(compObj));
        }
Esempio n. 24
0
        public List <CompetencyFrameworkAPI.Models.Competency> GetAllCompetencyList(string technologyName, string jobTitle)
        {
            var competencyList = new List <Competency>();


            string connectionString = ConfigurationManager.ConnectionStrings["apiDatabase"].ToString();

            using (var connection = new SqlConnection())
            {
                connection.ConnectionString = connectionString;
                connection.Open();

                using (var command = new SqlCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "ReturnAll";
                    command.Connection  = connection;

                    var parameter = new SqlParameter
                    {
                        ParameterName = "technologyName",
                        SqlDbType     = SqlDbType.VarChar,
                        Size          = 255,
                        Value         = technologyName,
                        Direction     = ParameterDirection.Input
                    };

                    var technologyParameter = new SqlParameter
                    {
                        ParameterName = "jobTitleName",
                        SqlDbType     = SqlDbType.VarChar,
                        Size          = 255,
                        Value         = jobTitle,
                        Direction     = ParameterDirection.Input
                    };

                    command.Parameters.Add(parameter);
                    command.Parameters.Add(technologyParameter);
                    var reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        var competency = new Competency();
                        competency.TopicName      = reader.GetString(0);
                        competency.AreaName       = reader.GetString(1);
                        competency.CompetencyName = reader.GetString(2);
                        competency.CompetencyID   = reader.GetInt32(3);
                        competency.RatingName     = reader.GetString(4);
                        competency.RatingTypeName = reader.GetString(5);
                        competency.RatingTypeID   = reader.GetInt32(6);
                        competency.RatingID       = reader.GetInt32(7);
                        competencyList.Add((competency));
                    }
                }
            }
            return(competencyList);
        }
 public ActionResult Edit([Bind(Include = "CompetencyId,Name,CompetencyHeaderId")] Competency competency)
 {
     if (ModelState.IsValid)
     {
         db.InsertOrUpdate(competency);
         return(RedirectToAction("Index"));
     }
     ViewBag.CompetencyHeaderId = new SelectList(headersDb.CompetencyHeaders, "CompetencyHeaderId", "Name", competency.CompetencyHeaderId);
     return(View(competency));
 }
Esempio n. 26
0
 public void InsertOrUpdate(Competency competency)
 {
     if (competency.CompetencyId == 0) //new
     {
         context.Competencies.Add(competency);
     }
     else //edit
     {
         context.Entry(competency).State = EntityState.Modified;
     }
 }
Esempio n. 27
0
 public static DbCompetency ToDb(this Competency competency)
 {
     return(new DbCompetency {
         Id = competency.Id,
         Code = competency.Code,
         Name = competency.Name,
         DateCreated = competency.DateCreated,
         Deleted = competency.Deleted,
         LastModified = competency.LastModified
     });
 }
Esempio n. 28
0
 public static SimpleQuestion ToModel(this SeedSimpleQuestionAddDto dto, Competency competency)
 {
     return(new SimpleQuestion {
         Code = dto.Code,
         Competency = competency,
         Question = new Question {
             Text = dto.Text,
             Options = dto.Options
         }
     });
 }
Esempio n. 29
0
 public SelfAssessmentCompetencyViewModel(
     CurrentSelfAssessment assessment,
     Competency competency,
     int competencyNumber,
     int totalNumberOfCompetencies
     )
 {
     Assessment                = assessment;
     Competency                = competency;
     CompetencyNumber          = competencyNumber;
     TotalNumberOfCompetencies = totalNumberOfCompetencies;
 }
Esempio n. 30
0
        public async Task <IActionResult> Create([Bind("Id,IsRequired,Skill,TypeId")] Competency competency)
        {
            if (ModelState.IsValid)
            {
                _context.Add(competency);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TypeId"] = new SelectList(_context.CompetencyTypes, "Id", "Id", competency.TypeId);
            return(View(competency));
        }