Exemplo n.º 1
0
        public PartialViewResult GetElement(CompetenceViewModel competenceViewModel, int idCompetence)
        {
            competenceViewModel.ElementCompetence = db.ElementCompetence.ToList();
            var elements = new List <SelectListItem>();

            var elementEnonce = from element in db.ElementCompetence
                                join Enonc in db.EnonceCompetence on element.IdCompetence equals Enonc.IdCompetence
                                where Enonc.IdCompetence == idCompetence
                                orderby element.Numero
                                select new
            {
                ID = element.IdElement,
                element.Numero,
                Desc = element.Description
            };

            foreach (var element in elementEnonce)
            {
                elements.Add(new SelectListItem()
                {
                    Value = element.ID.ToString(),
                    Text  = (element.Numero + " : " + element.Desc)
                });
            }

            ViewBag.IdCompetence = idCompetence;
            competenceViewModel.ElementCompetences = elements;
            return(PartialView("GetElement", competenceViewModel));
        }
Exemplo n.º 2
0
        private void SetCompetence(Konsultant newConsultant, CompetenceViewModel comp)
        {
            Competence current = string.IsNullOrEmpty(comp.Id) ?
                                 new Competence
            {
                Name = comp.Name
            } :
            _skillService.GetById(Guid.Parse(comp.Id));

            if (comp.IsDeleted)
            {
                _skillService.Delete(current);
            }
            else
            {
                newConsultant.Competences.Add(
                    new OwnedCompetences
                {
                    Competence   = current,
                    KonsultantId = newConsultant.Id,
                    CompetenceId = current.Id,
                    IsRelevant   = comp.IsRelevant,
                    Rating       = (Rating)Enum.Parse(typeof(Rating), comp.Rating.ToString())
                });
            }
        }
Exemplo n.º 3
0
        public async Task <ResponseApi> Handle(UpdateListCompetenceCommand request, CancellationToken cancellationToken)
        {
            try
            {
                int invalidQty = 0;

                foreach (var competence in request.Competences)
                {
                    competence.Validate();
                    if (competence.Invalid)
                    {
                        invalidQty += 1;
                    }

                    if (invalidQty > 0)
                    {
                        return(new ResponseApi(false, "Something is wrong...", competence.Notifications));
                    }
                }

                List <CompetenceViewModel> result = new List <CompetenceViewModel>();

                for (int i = 0; i < request.Competences.Count; i++)
                {
                    Competences competence = _mapper.Map <Competences>(await _competenceRepository.Get(request.Competences[i].Id));

                    competence.UpdateFields(_mapper.Map <Competences>(request.Competences[i]));
                    await _competenceRepository.Update(competence);

                    var updateResult = new CompetenceViewModel
                    {
                        Id                       = competence.Id,
                        CompetenceName           = competence.CompetenceName,
                        CompetenceExperienceTime = competence.CompetenceExperienceTime,
                        TimeType                 = competence.TimeType,
                        Active                   = competence.Active,
                        Excluded                 = competence.Excluded,
                        CreationDate             = competence.CreationDate,
                        LastUpdate               = competence.LastUpdate,
                        IdUser                   = competence.IdUser
                    };

                    result.Add(updateResult);
                }

                return(new ResponseApi(true, "Competences updated sucessfuly", result));
            }
            catch (Exception e)
            {
                return(new ResponseApi(false, "Error...", e));
            }
        }
Exemplo n.º 4
0
 public async Task <ActionResult <CompetenceViewModel> > Post(CompetenceViewModel model)
 {
     try
     {
         Competence result = mapper.Map <Competence>(model);
         repository.Add(result);
         if (await repository.SaveChangesAsync())
         {
             return(Created($"/api/camps/{result.CompetenceId}", mapper.Map <CompetenceViewModel>(result)));
         }
     }
     catch (Exception)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Error in database"));
     }
     return(BadRequest());
 }
Exemplo n.º 5
0
        public async Task <ActionResult <CompetenceViewModel> > Put(int id, CompetenceViewModel model)
        {
            try
            {
                Competence oldCompetence = await repository.GetCompetenceAsync(id);

                if (oldCompetence == null)
                {
                    return(NotFound($"Could not find competence with ID of {id}"));
                }
                mapper.Map(model, oldCompetence);
                if (await repository.SaveChangesAsync())
                {
                    return(mapper.Map <CompetenceViewModel>(oldCompetence));
                }
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Error in database"));
            }
            return(BadRequest());
        }
Exemplo n.º 6
0
        public ActionResult Choix(int?idPlanCadre)
        {
            if (idPlanCadre == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            competenceViewModel = new CompetenceViewModel
            {
                EnonceCompetence = db.EnonceCompetence.ToList(), ElementCompetence = db.ElementCompetence.ToList()
            };
            var enonces = db.EnonceCompetence.Select(item => new SelectListItem()
            {
                Value = item.IdCompetence.ToString(), Text = (item.CodeCompetence + " : " + item.Description)
            })
                          .ToList();

            competenceViewModel.PlanCadre         = db.PlanCadre.Find(idPlanCadre);
            ViewBag.IdPlanCadre                   = idPlanCadre;
            competenceViewModel.EnonceCompetences = enonces;
            return(View(competenceViewModel));
        }
Exemplo n.º 7
0
        public KonsultantCreationModel toViewModel(Konsultant source)
        {
            if (source == null)
            {
                return(new KonsultantCreationModel());
            }

            var result = new KonsultantCreationModel
            {
                Id           = source.Id.ToString(),
                Name         = source.Name,
                Surname      = source.Surname,
                Function     = source.Function,
                Availability = source.Availability.Date,
            };


            foreach (var comp in source.Competences)
            {
                var current = new CompetenceViewModel
                {
                    Id         = comp.CompetenceId.ToString(),
                    Name       = comp.Competence?.Name,
                    Rating     = (int)comp.Rating,
                    IsRelevant = comp.IsRelevant
                };

                result.Competences.Add(current);

                result.Competences = result.Competences.OrderByDescending(x => x.Rating).ToList();
            }

            foreach (var lang in source.Languages)
            {
                var current = new LanguageViewModel
                {
                    Id         = lang.LanguageId.ToString(),
                    Name       = lang.Language?.Name,
                    Fluency    = (int)lang.Fluency,
                    IsRelevant = lang.IsRelevant,
                };

                result.Languages.Add(current);
            }

            foreach (var edu in source.Educations)
            {
                var current = new EducationViewModel
                {
                    Id         = edu.EducationId.ToString(),
                    Name       = edu.Education?.Name,
                    StartDate  = edu.StartDate.Date,
                    EndDate    = edu.EndDate.Date,
                    IsRelevant = edu.IsRelevant
                };

                result.Educations.Add(current);
            }

            foreach (var cert in source.Certificates)
            {
                var current = new CertificateViewModel
                {
                    Id            = cert.CertificateId.ToString(),
                    Name          = cert.Certificate?.Name,
                    Obtension     = cert.Obtension,
                    EndOfValidity = cert.EndOfValidity,
                    IsRelevant    = cert.IsRelevant
                };

                result.Certificates.Add(current);
            }

            foreach (var exp in source.ProfessionalExperiences)
            {
                var curr = new ProfessionalExperienceViewModel
                {
                    Id         = exp.Id.ToString(),
                    Position   = exp.Position,
                    Summary    = exp.Summary,
                    Customer   = exp.Customer,
                    StartDate  = exp.StartDate.Date,
                    EndDate    = exp.EndDate.Date,
                    IsRelevant = exp.IsRelevant
                };

                foreach (var acc in exp.Accomplishments)
                {
                    var accomplished = new AccomplishmentViewModel
                    {
                        Id         = acc.Id.ToString(),
                        Title      = acc.Title,
                        IsRelevant = acc.IsRelevant
                    };
                    curr.Accomplishments.Add(accomplished);
                }
                ;

                foreach (var tech in exp.TechnicalEnvironments)
                {
                    var technical = new TechnicalEnvironmentViewModel
                    {
                        Id         = tech.Id.ToString(),
                        Name       = tech.Name,
                        IsRelevant = tech.IsRelevant
                    };

                    curr.TechnicalEnvironments.Add(technical);
                }
                ;

                result.ProfessionalExperiences.Add(curr);
            }

            foreach (var refer in source.ProfessionalReferences)
            {
                var current = new ProfessionalReferenceViewModel
                {
                    Id       = refer.Id.ToString(),
                    Name     = refer.Name,
                    Surname  = refer.Surname,
                    Function = refer.Function,
                    Mail     = refer.Contacts?.Mail,
                    Phone    = refer.Contacts?.Phone
                };

                result.ProfessionalReferences.Add(current);
            }

            return(result);
        }