public async Task <IActionResult> Create([FromBody] Person person)
        {
            _logger.LogDebug("Starting save");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var jsSkill = new Skill
            {
                Name = "Test Skill 1"
            };

            var personSkill = new PersonSkill
            {
                Skill = jsSkill
            };

            _personRepository.Add(new Person {
                LastName  = person.LastName,
                FirstName = person.FirstName,
                Skills    = new Collection <PersonSkill> {
                    personSkill
                }
            });

            await _personRepository.SaveChangesAsync();

            _logger.LogDebug("Finished save");

            return(CreatedAtAction(nameof(Get), new { id = person.LastName }, person));
        }
Esempio n. 2
0
        public static PersonSkill CreatePersonSkill(string partyNumber,
                                                    string skillId,
                                                    global::System.DateTimeOffset levelDate,
                                                    decimal yearsOfExperience,
                                                    global::Microsoft.Dynamics.DataEntities.Person person,
                                                    global::Microsoft.Dynamics.DataEntities.RatingLevel ratingLevel,
                                                    global::Microsoft.Dynamics.DataEntities.Skill skill)
        {
            PersonSkill personSkill = new PersonSkill();

            personSkill.PartyNumber       = partyNumber;
            personSkill.SkillId           = skillId;
            personSkill.LevelDate         = levelDate;
            personSkill.YearsOfExperience = yearsOfExperience;
            if ((person == null))
            {
                throw new global::System.ArgumentNullException("person");
            }
            personSkill.Person = person;
            if ((ratingLevel == null))
            {
                throw new global::System.ArgumentNullException("ratingLevel");
            }
            personSkill.RatingLevel = ratingLevel;
            if ((skill == null))
            {
                throw new global::System.ArgumentNullException("skill");
            }
            personSkill.Skill = skill;
            return(personSkill);
        }
Esempio n. 3
0
        public async Task <IActionResult> PutPersonSkill([FromRoute] int id, [FromBody] PersonSkill personSkill)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != personSkill.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 4
0
 private void AssertPersonSkill(PersonSkill skill,
                                UpsertPersonSkillCommand sut)
 {
     Assert.NotNull(skill);
     Assert.Equal(1, skill.SkillId);
     Assert.Equal(sut.SkillLevel, skill.Level);
     Assert.Equal(sut.SkillName, skill.Name);
     Assert.Equal(sut.SkillType, (SkillTypes)skill.SkillTypeId);
     Assert.Equal(Defaults.PersonId, skill.PersonId);
 }
Esempio n. 5
0
        public async Task <IActionResult> PostPersonSkill([FromBody] PersonSkill personSkill)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PersonSkill.Add(personSkill);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPersonSkill", new { id = personSkill.Id }, personSkill));
        }
        public async Task <IActionResult> AddSkill(int git, [FromBody] PersonSkillViewModel personSkillViewModel)
        {
            if (personSkillViewModel == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var person = await _personRepository.GetPersonWithSkills(personSkillViewModel.PersonId);

            if (person == null)
            {
                return(NotFound());
            }

            var skillToAdd = await _skillRepository.GetSingleAsync(personSkillViewModel.SkillId);

            var skillsMetadata = await _metadataRepository.Get();

            var personSkill = new PersonSkill
            {
                Skill         = skillToAdd,
                SkillLevel    = skillsMetadata.SkillLevels.Where(x => x.Code == personSkillViewModel.SkillLevelCode).FirstOrDefault(),
                TimeUsed      = skillsMetadata.TimePeriods.Where(x => x.Code == personSkillViewModel.TimeUsedCode).FirstOrDefault(),
                TimeSinceUsed = skillsMetadata.TimePeriods.Where(x => x.Code == personSkillViewModel.TimeLastUsedCode).FirstOrDefault()
            };

            if (person.Skills == null)
            {
                person.Skills = new Collection <PersonSkill>();
            }
            person.Skills.Add(personSkill);

            await _personRepository.SaveChangesAsync();

            var personViewModel = PersonViewModelFactory.Build(person);

            return(CreatedAtAction(nameof(Get), new { id = personViewModel.LastName }, personViewModel));
        }
        internal static async Task SeedSkill(this ILifetimeScope scope,
                                             int skillId     = 1,
                                             int personId    = Defaults.PersonId,
                                             string name     = "Skill",
                                             string level    = "10",
                                             SkillTypes type = SkillTypes.Technical)
        {
            var db = scope.Resolve <AppDbContext>();

            var toAdd = new PersonSkill()
            {
                SkillId     = skillId,
                SkillTypeId = (byte)type,
                Level       = level,
                Name        = name,
                PersonId    = personId
            };

            db.PersonSkill.Add(toAdd);
            await db.SaveChangesAsync();
        }
Esempio n. 8
0
 public ActionResult AddSkill(AddSkillViewModel skill)
 {
     try
     {
         var newSkill = new PersonSkill
         {
             PersonId        = _appContext.LoginId,
             Skill           = skill.Name,
             ExperienceLevel = skill.Level,
             CreatedOn       = DateTime.Now,
             CreatedBy       = _appContext.LoginId,
             UpdatedOn       = DateTime.Now,
             UpdatedBy       = _appContext.LoginId,
             IsDeleted       = false
         };
         _personSkillRepository.Add(newSkill);
         return(new JsonCamelCaseResult(new { Success = true, newSkill.Id }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(new JsonCamelCaseResult(new { Success = false, Message = "Error while adding new skill " + e.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 9
0
        public async Task <List <SearchedPersonSkill> > Handle(SavePersonSkillsCommand request, CancellationToken cancellationToken)
        {
            List <SearchedPersonSkill> result = new List <SearchedPersonSkill>();


            if (request.Id == null || request.Id == default(decimal))
            {
                using (_context)
                {
                    PersonSkill personSkill = new PersonSkill()
                    {
                        PersonId          = request.PersonId,
                        LanguageId        = request.LanguageId,
                        ExpertiseId       = request.ExpertiseId,
                        ModifiedOn        = request.ModifiedOn,
                        ModifiedBy        = request.ModifiedBy,
                        ReferenceNo       = request.ReferenceNo,
                        CreatedOn         = request.CreatedOn,
                        CreatedBy         = request.CreatedBy,
                        Locationid        = request.Locationid,
                        Remarks           = request.Remarks,
                        CertificationId   = request.CertificationId,
                        CertifiedFrom     = request.CertifiedFrom,
                        CertificationDate = request.CertificationDate,
                        StartDate         = request.StartDate,
                        EndDate           = request.EndDate
                    };

                    _context.PersonSkill.Add(personSkill);
                    await _context.SaveChangesAsync(cancellationToken);


                    result = await _mediator.Send(new Queries.SearchPersonSkillQuery()
                    {
                        Id = personSkill.Id
                    });
                }
            }
            else
            {
                using (_context)
                {
                    PersonSkill toUpdateRecord = await(from ps in _context.PersonSkill
                                                       where ps.Id == request.Id
                                                       select ps).SingleOrDefaultAsync();

                    toUpdateRecord.PersonId          = request.PersonId;
                    toUpdateRecord.LanguageId        = request.LanguageId;
                    toUpdateRecord.ExpertiseId       = request.ExpertiseId;
                    toUpdateRecord.ModifiedOn        = request.ModifiedOn;
                    toUpdateRecord.ModifiedBy        = request.ModifiedBy;
                    toUpdateRecord.ReferenceNo       = request.ReferenceNo;
                    toUpdateRecord.CreatedOn         = request.CreatedOn;
                    toUpdateRecord.CreatedBy         = request.CreatedBy;
                    toUpdateRecord.Locationid        = request.Locationid;
                    toUpdateRecord.Remarks           = request.Remarks;
                    toUpdateRecord.CertificationId   = request.CertificationId;
                    toUpdateRecord.CertifiedFrom     = request.CertifiedFrom;
                    toUpdateRecord.CertificationDate = request.CertificationDate;
                    toUpdateRecord.StartDate         = request.StartDate;
                    toUpdateRecord.EndDate           = request.EndDate;
                    await _context.SaveChangesAsync(cancellationToken);

                    result = await _mediator.Send(new Queries.SearchPersonSkillQuery()
                    {
                        Id = toUpdateRecord.Id
                    });
                }
            }

            return(result);
        }
Esempio n. 10
0
        public ActionResult PersonSkill_Destroy([DataSourceRequest] DataSourceRequest request, PersonSkill _objPersonSkill)
        {
            if (ModelState.IsValid)
            {
                PersonSkillsInterest _objSkillsInterest = new PersonSkillsInterest();
                _objSkillsInterest.UpdatedBy   = CurrentUser.NameIdentifierInt64;
                _objSkillsInterest.UpdatedDate = DateTime.Now;
                _objSkillsInterest.ID          = _objPersonSkill.ID;
                var result = _objISkillsInterestLevelBAL.PersonSkillsInterest_DeleteBAL(_objSkillsInterest);
                if (result == -1)
                {
                    ModelState.AddModelError(lr.ErrorServerError, lr.ResourceUpdateValidationError);
                }
            }
            var resultData = new[] { _objPersonSkill };

            return(Json(resultData.AsQueryable().ToDataSourceResult(request, ModelState)));
        }
Esempio n. 11
0
        public ActionResult PersonSkill_Update([DataSourceRequest] DataSourceRequest request, PersonSkill _objPersonSkill)
        {
            if (ModelState.IsValid)
            {
                PersonSkillsInterest _objSkillsInterest = new PersonSkillsInterest();
                _objSkillsInterest.UpdatedBy   = CurrentUser.NameIdentifierInt64;
                _objSkillsInterest.UpdatedDate = DateTime.Now;
                _objSkillsInterest.Title       = _objPersonSkill.Title;
                _objSkillsInterest.Description = "";
                _objSkillsInterest.ID          = _objPersonSkill.ID;
                _objSkillsInterest.Type        = PersonSKillInterest.PersonSKillInterest_Person_Skills;
                if (_objISkillsInterestLevelBAL.PersonSkillsInterest_DuplicationCheckBAL(_objSkillsInterest) > 0)
                {
                    ModelState.AddModelError(lr.PersonSkill, lr.PersonSkillDuplicationCheck);
                }
                else
                {
                    var result = _objISkillsInterestLevelBAL.PersonSkillsInterest_UpdateBAL(_objSkillsInterest);
                    if (result == -1)
                    {
                        ModelState.AddModelError(lr.ErrorServerError, lr.ResourceUpdateValidationError);
                    }
                }
            }
            var resultData = new[] { _objPersonSkill };

            return(Json(resultData.AsQueryable().ToDataSourceResult(request, ModelState)));
        }