Exemplo n.º 1
0
        private async void SaveQueryMethod()
        {
            if (SelectedProjects == null)
            {
                SelectedProjects = new ObservableCollection <Models.ProjectsManagementPageModels.Project>();
            }
            if (QueryDescription.Length > 1 && QueryDescription.Length < 100)
            {
                var skillsQuery    = string.Join(",", SkillsConditions?.Select(s => $"{s.Skill.Id}:{s.From.Id}-{s.To.Id}"));
                var languagesQuery = string.Join(",", LanguagesConditions?.Select(l => $"{l.Language.Id}:{l.From.Id}-{l.To.Id}"));
                var projectsQuery  = string.Join(",", SelectedProjects?.Select(p => p.Id));

                var query = $"{skillsQuery}&{languagesQuery}&{projectsQuery}";

                using (var _database = new ITManagerEntities())
                {
                    var user = await _database.Users.Where(u => u.Id == ShellViewModel.CurrentUserId)
                               .Include(u => u.Queries).FirstOrDefaultAsync();

                    user.Queries.Add(new Query()
                    {
                        Description = QueryDescription,
                        QueryString = query,
                        UserId      = ShellViewModel.CurrentUserId
                    });
                    await _database.SaveChangesAsync();
                }
                _eventAggregator.GetEvent <UpdateQueriesEvent>().Publish();
                QueryErrors = string.Empty;
            }
            else
            {
                QueryErrors = "Query description length must be from 1 to 100 sybmols.";
            }
        }
Exemplo n.º 2
0
        private void SkillsSelectionChangedMethod()
        {
            if (SelectedSkills == null)
            {
                SelectedSkills = new ObservableCollection <Models.UserPageModel.ProfessionalSkill>();
            }
            if (SelectedSkills.Count > SkillsConditions.Count)
            {
                foreach (var selectedSkill in SelectedSkills)
                {
                    if (SkillsConditions.Where(s => s.Skill.Id == selectedSkill.Id).FirstOrDefault() == null)
                    {
                        SkillsConditions.Add(new SkillCondition
                        {
                            Skill = selectedSkill,
                            From  = SkillLevels.First(),
                            To    = SkillLevels.Last()
                        });
                        return;
                    }
                }
            }

            if (SelectedSkills.Count < SkillsConditions.Count)
            {
                foreach (var skillCondition in SkillsConditions)
                {
                    if (SelectedSkills.Where(s => s.Id == skillCondition.Skill.Id).FirstOrDefault() == null)
                    {
                        var skill = SkillsConditions.Where(s => s.Skill.Id == skillCondition.Skill.Id).FirstOrDefault();
                        if (skill == null)
                        {
                            return;
                        }
                        SkillsConditions.Remove(skill);
                        return;
                    }
                }
            }
        }