Esempio n. 1
0
        public SkillComponent(IEntity entity)
        {
            Entity = entity;

            if (!(entity is IPlayerEntity player))
            {
                return;
            }

            int tmp = 200 + 20 * (byte)player.Character.Class;

            this.AddSkill(SkillService.GetById(tmp));
            this.AddSkill(SkillService.GetById(tmp + 1));

            if (player.Character.Class != CharacterClassType.Adventurer)
            {
                return;
            }

            this.AddSkill(SkillService.GetById(tmp + 9));

            IEnumerable <SkillDto> skills = SkillService.GetByClassIdAsync((byte)player.Character.Class).ConfigureAwait(false).GetAwaiter().GetResult();

            foreach (SkillDto skillDto in skills.Where(s => s.LevelMinimum < player.JobLevel && s.Id >= 200 && s.Id != 209 && s.Id <= 210))
            {
                this.AddSkill(skillDto);
            }
        }
Esempio n. 2
0
 public IActionResult Update(int id)
 {
     return(View(new SkillUpdateViewModel
     {
         Skill = _skillService.GetById(id)
     }));
 }
Esempio n. 3
0
        public ActionResult EditSkill(int id)
        {
            Skill s = skillService.GetById(id);

            if (s == null)
            {
                return(HttpNotFound());
            }

            return(View(s));
        }
Esempio n. 4
0
        public IActionResult Get(int id)
        {
            var entity = _skillService.GetById(id);
            var model  = entity.ToModel();

            //locals
            AddLocales(_languageWebApi, model.Locales, (locale, languageId) =>
            {
                locale.Name = entity.GetLocalized(x => x.Name, languageId, false, false);
            });

            return(Ok(model));
        }
        /// <summary>
        /// To delete a skill
        /// </summary>
        /// <param name="id">SkillId</param>
        public void Delete(string id)
        {
            ISkillService <Skill> jobSeekerService = ServiceFactory.GetSkill();
            var jobSeeker = jobSeekerService.GetById(id);

            jobSeekerService.Delete(jobSeeker);
        }
Esempio n. 6
0
        public IActionResult GetById(int id)
        {
            try
            {
                var data = _skillService.GetById(id);

                if (data == null)
                {
                    return(NotFound("Id not found !"));
                }

                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Esempio n. 7
0
        // GET: Skills/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            skill skill = _skillService.GetById((int)id);

            if (skill == null)
            {
                return(HttpNotFound());
            }
            return(View(new SkillsViewDetailsModel()
            {
                User = CurrentUser, Skill = skill
            }));
        }
Esempio n. 8
0
        public ActionResult Edit(int id)
        {
            var skill = _skillService.GetById(id);

            if (skill == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new SkillFormViewModel
            {
                Id         = id,
                Name       = skill.Name,
                CategoryId = skill.CategoryId,
                Categories = _categoryService.GetAll(),
                Heading    = "Edit a skill"
            };

            return(View("SkillForm", viewModel));
        }
Esempio n. 9
0
        public IActionResult BuscarPorId(int id)
        {
            try
            {
                //busca a skill pelo id e verifica se ela é encontrada
                Skills skillBuscada = _skillRepository.GetById(id);
                if (skillBuscada == null)
                {
                    return(NotFound(new { Mensagem = $"Não foi possível encontrar a skill {id}" }));
                }

                return(Ok(_mapperSkill.GetById(id)));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { Erro = ex.ToString() }));
            }
        }
Esempio n. 10
0
        public IHttpActionResult GetSkill(int id)
        {
            //get the skill first
            var skill = _skillService.GetById(id);

            if (skill == null)
            {
                return(NotFound());
            }
            var model = skill.ToModel(_workContext);

            return(Response(new { Success = true, Skill = model }));
        }
        public string Update(int id, string name, string description)
        {
            string msg;

            try
            {
                Skill model = service.GetById(id);
                model.Name        = name;
                model.Description = description;
                model.ChangedBy   = User.Identity.GetUserId();
                service.Update(model);
                msg = "Saved Successfully";
            }
            catch (Exception ex)
            {
                msg = "Error occured:" + ex.Message;
            }
            return(msg);
        }
Esempio n. 12
0
        public IActionResult GetById(Guid id)
        {
            try
            {
                var skillOnDb = _service.GetById(id);

                var dto = _mapper.Map <SkillDto>(skillOnDb);

                return(Ok(dto));
            }
            catch (SkillNotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 13
0
 public ActionResult <SkillDto> Get([FromRoute] Guid id)
 {
     return(_skillService.GetById(id));
 }
Esempio n. 14
0
        public ActionResult Edit(ProjectViewModel projectViewModel, string tags, string btn)
        {
            if (btn != null && btn == "Next Step")
            {
                using (var client = new HttpClient())
                {
                    String clientId    = Request.Form["CLIENT"].ToString();
                    string projectType = Request.Form["TypeProject"].ToString();
                    projectViewModel.projectType = projectType;
                    person person = clientService.GetById(Int32.Parse(clientId));
                    projectViewModel.clientId = person;
                    client.BaseAddress        = new Uri("http://127.0.0.1:18080/");
                    var putTask =
                        client.PutAsJsonAsync <ProjectViewModel>("Map-JavaEE-web/MAP/projects", projectViewModel);
                    putTask.Wait();
                    var result = putTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                FillEnumDropDownList();
                ViewBag.CLIENT = new SelectList(db.people, "id", "nameSociety", projectViewModel.clientId.id);

                //list value of tags from view
                List <string> listTagsFromView = tags.Split(',').ToList();
                //list of skills of project from db
                List <skill> listSkillsFromDb = new List <skill>();
                //List qui sera envoyer à la vue EditSkills avec liste des skills ajouter
                List <SkillViewModel> listSkillViewModel = new List <SkillViewModel>();

                skill        skillDomain  = new skill();
                projectskill projectSkill = new projectskill();
                var          res          = db.projectskills
                                            .Join(db.skills, ps => ps.idSkill, s => s.IdSkill, (ps, s) => new { ps, s })
                                            .Join(db.projects, ppc => ppc.ps.idProject, p => p.id, (ppc, p) => new { ppc, p })
                                            .Where(m => m.p.id.Equals(projectViewModel.id))
                                            .Select(m => new
                {
                    id      = m.ppc.s.IdSkill,
                    name    = m.ppc.s.NameSkill,
                    percent = m.ppc.ps.percentage
                }).ToList();

                foreach (var item in res)
                {
                    listSkillsFromDb.Add(new skill(item.id, item.name));
                }

                List <string> nameSkills = listSkillsFromDb.Select(o => o.NameSkill).ToList();

                foreach (var tag in listTagsFromView)
                {
                    if (!(nameSkills.Contains(tag)))
                    {
                        skillDomain.NameSkill = tag;
                        skillService.Add(skillDomain);
                        skillService.Commit();
                        listSkillViewModel.Add(new SkillViewModel(skillDomain.IdSkill, skillDomain.NameSkill));
                    }
                }
                foreach (var skill in listSkillsFromDb)
                {
                    if (!(listTagsFromView.Contains(skill.NameSkill)))
                    {
                        projectSkill = projectSkillService.GetMany().Where(a => a.idProject == projectViewModel.id)
                                       .Where(b => b.idSkill == skill.IdSkill).FirstOrDefault();
                        projectSkillService.Delete(projectSkill);

                        projectSkillService.Commit();

                        skillDomain = skillService.GetById(skill.IdSkill);
                        skillService.Delete(skillDomain);

                        skillService.Commit();
                    }
                    else
                    {
                        listSkillViewModel.Add(new SkillViewModel(skill.IdSkill, skill.NameSkill));
                    }
                }

                return(RedirectToAction("EditSkills", new { serializedModel = JsonConvert.SerializeObject(listSkillViewModel), id = projectViewModel.id }));
            }
            return(View(projectViewModel));
        }
Esempio n. 15
0
        public async Task <IActionResult> GetSkillById(Guid id)
        {
            var skillResult = await _skillService.GetById(id);

            return(Ok(new Response <SkillDto>(skillResult)));
        }