Example #1
0
        public void PopulateProjectTechnologies(Faker faker, Project project, IEnumerable <Technology> technologies)
        {
            if (project.UsedTechnologies.Any() && faker.Random.Bool(0.3f))
            {
                project.UsedTechnologies = faker.Random.ListItems(project.UsedTechnologies);
            }

            foreach (var technology in project.UsedTechnologies.Any() ? faker.Random.ListItems(project.UsedTechnologies) : Enumerable.Empty <ProjectTechnology>())
            {
                technology.Component = faker.Random.Bool(0.5f) ? faker.Lorem.Word() : technology.Component;
            }

            if (technologies.Any())
            {
                var technologiesList = technologies.ToList();
                var max    = faker.Random.Bool(0.8f) ? Math.Min(technologiesList.Count, 99) : technologiesList.Count; // Maximal batch-size is 100 (going above this causes a HTTP 500)
                var number = faker.Random.Int(1, max);

                foreach (var technology in faker.Random.ListItems(technologiesList, number))
                {
                    var projTechnology = ProjectTechnology.Generate();
                    projTechnology.ProjectKey    = project.RowKey;
                    projTechnology.TechnologyKey = technology.RowKey;

                    project.UsedTechnologies.Add(projTechnology);
                }
            }
        }
 public ProjectTechnologyViewModel()
 {
     if (_projectTechnology == null)
     {
         _projectTechnology = new ProjectTechnology();
     }
 }
Example #3
0
        private void OnOtherPlayerCompanyWorkerAbilityChangedRPC(int photonPlayerID, int workerID, int updatedAbility, float updatedAbilityValue)
        {
            SharedWorker updatedWorker =
                OtherPlayersWorkers.First(x => x.Key.ID == photonPlayerID).Value.First(x => x.ID == workerID);
            ProjectTechnology updatedAbilityEnum = (ProjectTechnology)updatedAbility;

            updatedWorker.UpdateAbility(updatedAbilityEnum, updatedAbilityValue);
        }
        public async Task AddProjectTechnology(Project project, Technology technology,
                                               CancellationToken cancellationToken)
        {
            ProjectTechnology projectTechnologyLink = ProjectTechnology.CreateProjectTechnology(project, technology);

            ProjectContext.ProjectTechnologies.Add(projectTechnologyLink);
            await ProjectContext.SaveChangesAsync(cancellationToken);
        }
 public ProjectTechnology Delete(ProjectTechnology technology)
 {
     using (var context = new PortfolioContext())
     {
         context.Entry(technology).State = EntityState.Deleted;
         context.SaveChanges();
         return(technology);
     }
 }
Example #6
0
 private void OnCompanyWorkerAbilityUpdated(SharedWorker companyWorker, ProjectTechnology workerAbility, float workerAbilityValue)
 {
     this.photonView.RPC("OnOtherPlayerCompanyWorkerAbilityChangedRPC",
                         PhotonTargets.Others,
                         PhotonNetwork.player.ID,
                         companyWorker.ID,
                         (int)workerAbility,
                         workerAbilityValue);
 }
Example #7
0
        /// <summary>
        /// Add a technology to a project.
        /// </summary>
        /// <param name="projectId"> int project id </param>
        /// <param name="techId"> int tech id </param>
        public async Task AddTechToProject(int projectId, int techId)
        {
            ProjectTechnology newTech = new ProjectTechnology()
            {
                ProjectId    = projectId,
                TechnologyId = techId
            };

            _context.Entry(newTech).State = EntityState.Added;
            await _context.SaveChangesAsync();
        }
Example #8
0
        public ActionResult CreateProjectFromTempProject(int projectId)
        {
            _db = new ApplicationDbContext();

            var tempProject = (from x in _db.TempProjects
                               where x.TempProjectId == projectId
                               select x).FirstOrDefault();
            Project project = Mapper.Map <TempProject, Project>(tempProject);

            if (tempProject != null)
            {
                _db.Projects.Add(project);
            }
            _db.SaveChanges();

            BlobConnector.MoveIconFromTempToProject(projectId, project.ProjectId);

            ApplicationDbContext db2    = new ApplicationDbContext();
            var tempProjectTechnologies = from x in db2.TempProjectTechnologies
                                          where x.ProjectId == projectId
                                          select x;

            foreach (var tempProjectTechnology in tempProjectTechnologies)
            {
                ProjectTechnology projectTechnology = Mapper.Map <TempProjectTechnology, ProjectTechnology>(tempProjectTechnology);
                if (projectTechnology == null)
                {
                    continue;
                }
                projectTechnology.ProjectId = project.ProjectId;
                db2.ProjectTechnologies.Add(projectTechnology);
            }
            db2.SaveChanges();


            var imgList = from z in _db.Images
                          where z.ProjectId == projectId && z.TempraryProject
                          select z;

            foreach (var v in imgList)
            {
                BlobConnector.MoveImageFromTempToProject(v, project.ProjectId);
                v.FileName         = "Project" + project.ProjectId + v.OriginalFileName;
                v.TempraryProject  = false;
                v.ProjectId        = project.ProjectId;
                _db.Entry(v).State = System.Data.Entity.EntityState.Modified;
            }
            _db.SaveChanges();


            RemoveTempProject(projectId);

            return(RedirectToAction("ProjectsListView"));
        }
Example #9
0
 private void AddTechnologies(List <int> technologies, int projectID)
 {
     for (int i = 0; i < technologies.Count; i++)
     {
         ProjectTechnology projectTechnology = new ProjectTechnology();
         projectTechnology.ID_Project    = projectID;
         projectTechnology.ID_Technology = technologies[i];
         db.ProjectTechnologies.Add(projectTechnology);
         db.SaveChanges();
     }
 }
Example #10
0
        /// <summary>
        /// Remove a technology form a project.
        /// </summary>
        /// <param name="projectId"> int project id </param>
        /// <param name="techId"> int tech id </param>
        public async Task RemoveTechFromProject(int projectId, int techId)
        {
            ProjectTechnology tech = await _context.ProjectTechnologies
                                     .Where(x => x.ProjectId == projectId && x.TechnologyId == techId)
                                     .Select(y => new ProjectTechnology
            {
                ProjectId    = y.ProjectId,
                TechnologyId = y.TechnologyId
            }).FirstOrDefaultAsync();

            _context.Entry(tech).State = EntityState.Deleted;
            await _context.SaveChangesAsync();
        }
Example #11
0
        private void AddTechnologyToProject(int projectId, int selectedTechnology)
        {
            ApplicationDbContext db = new ApplicationDbContext();

            ProjectTechnology projectTechnology = new ProjectTechnology()
            {
                ProjectId    = projectId,
                TechnologyId = selectedTechnology
            };

            db.ProjectTechnologies.Add(projectTechnology);
            db.SaveChanges();
        }
Example #12
0
        public void AddAllTechnologies(int projectId, int[] technologyIds)
        {
            foreach (var technologyId in technologyIds)
            {
                var projectTechnology = new ProjectTechnology()
                {
                    ProjectId    = projectId,
                    TechnologyId = technologyId
                };

                this.personalBlogDbContext.Add(projectTechnology);
            }
        }
Example #13
0
        /// <summary>
        /// Increases given ability of worker by provided value. In case worker does
        /// not have given ability it will be added to his abilites list and value of
        /// ability will be set to provided value
        /// </summary>
        public void UpdateAbility(ProjectTechnology ability, float abilityValue)
        {
            abilityValue = Mathf.Clamp(abilityValue, 0f, MAX_ABILITY_VALUE);

            if (true == Abilites.ContainsKey(ability))
            {
                SafeFloat abilityCurrentValue = Abilites[ability];
                Abilites[ability] = new SafeFloat(abilityCurrentValue.Value + abilityValue);
            }
            else
            {
                Abilites.Add(ability, new SafeFloat(abilityValue));
            }

            AbilityUpdated?.Invoke(this, ability, abilityValue);
        }
        public static object Deserialize(byte[] projectBytes)
        {
            if (null == ResourceHolderComponent)
            {
                ResourceHolderComponent = GameObject.FindGameObjectWithTag("ScriptsGameObject").GetComponent <ResourceHolder>();
            }

            int offset = 0;
            int nameIndex;
            int iconIndex;
            int ID;
            int completeBonus;
            int completionTime;
            int technologiesSize;
            List <ProjectTechnology> technologies = new List <ProjectTechnology>();

            nameIndex        = BitConverter.ToInt32(projectBytes, offset);
            offset          += sizeof(int);
            iconIndex        = BitConverter.ToInt32(projectBytes, offset);
            offset          += sizeof(int);
            ID               = BitConverter.ToInt32(projectBytes, offset);
            offset          += sizeof(int);
            completeBonus    = BitConverter.ToInt32(projectBytes, offset);
            offset          += sizeof(int);
            completionTime   = BitConverter.ToInt32(projectBytes, offset);
            offset          += sizeof(int);
            technologiesSize = BitConverter.ToInt32(projectBytes, offset);
            offset          += sizeof(int);

            for (int i = 0; i < technologiesSize; i++)
            {
                ProjectTechnology technology = (ProjectTechnology)projectBytes[offset];
                technologies.Add(technology);
                offset += sizeof(byte);
            }

            SharedProject deserializedProject = new SharedProject(ProjectData.Names[nameIndex]);

            deserializedProject.ID = ID;
            deserializedProject.CompletionBonus  = completeBonus;
            deserializedProject.UsedTechnologies = technologies;
            deserializedProject.CompletionTime   = completionTime;
            deserializedProject.IconIndex        = iconIndex;
            deserializedProject.Icon             = ResourceHolderComponent.ProjectsIcons[iconIndex];
            ;
            return(deserializedProject);
        }
        /*Private methods*/

        protected string GetProjectTechnologiesString(SharedProject proj)
        {
            StrBuilder.Clear();

            for (int i = 0; i < proj.UsedTechnologies.Count; i++)
            {
                ProjectTechnology pt = proj.UsedTechnologies[i];
                StrBuilder.Append(EnumToString.ProjectTechnologiesStrings[pt]);

                if (i != proj.UsedTechnologies.Count - 1)
                {
                    StrBuilder.Append(" / ");
                }
            }

            return(StrBuilder.ToString());
        }
Example #16
0
    private List <ProjectTechnology> GenerateProjectTechnologies()
    {
        List <ProjectTechnology> projectTechnologies = new List <ProjectTechnology>();
        int numberOfTechnologies = UnityEngine.Random.Range(1, MAX_NUMBER_OF_PROJECT_ABILITIES);

        for (int i = 0; i < numberOfTechnologies; i++)
        {
            ProjectTechnology projectAbility =
                (ProjectTechnology)UnityEngine.Random.Range(0, NUMBER_OF_PROJECT_TECHNOLOGIES);

            if (false == projectTechnologies.Contains(projectAbility))
            {
                projectTechnologies.Add(projectAbility);
            }
        }

        return(projectTechnologies);
    }
Example #17
0
        public async Task <IActionResult> AddTechnologyToProject([FromBody] ProjectTechnologyInputModel model)
        {
            var project = context.Projects.Include(x => x.ProjectTechnology).FirstOrDefault(x => x.Id == model.ProjectId);

            if (project == null)
            {
                return(StatusCode((int)HttpStatusCode.NotFound));
            }

            var techno = context.Technologies.Include(x => x.ProjectTechnology).FirstOrDefault(x => x.Id == model.TechnologyId);

            if (techno == null)
            {
                return(StatusCode((int)HttpStatusCode.NotFound));
            }

            if (project.ProjectTechnology == null)
            {
                project.ProjectTechnology = new List <ProjectTechnology>();
            }
            if (techno.ProjectTechnology == null)
            {
                techno.ProjectTechnology = new List <ProjectTechnology>();
            }

            if (project.EmployeeProjects.Any(x => x.EmployeeId == techno.Id))
            {
                return(StatusCode((int)HttpStatusCode.BadRequest));
            }

            var projectTechno = new ProjectTechnology
            {
                Project      = project,
                ProjectId    = model.ProjectId,
                Technology   = techno,
                TechnologyId = model.TechnologyId,
            };

            techno.ProjectTechnology.Add(projectTechno);
            project.ProjectTechnology.Add(projectTechno);
            await context.SaveChangesAsync();

            return(StatusCode((int)HttpStatusCode.OK));
        }
    private Dictionary <ProjectTechnology, SafeFloat> CreateWorkerAbilities()
    {
        Dictionary <ProjectTechnology, SafeFloat> workerAbilities = new Dictionary <ProjectTechnology, SafeFloat>();

        //Value that will be used when adding abilities for
        //worker. After each ability added this value will be
        //decreased so there is less chance for new ability to be
        //added. Created worker will have at least one ability so 1st
        //ability will be added with 100% probability
        int abilityAddTreshold = 100;

        for (int i = 0; i < NUMBER_OF_PROJECT_TECHNOLOGIES; i++)
        {
            int randomNum = UnityEngine.Random.Range(0, 101);

            if (abilityAddTreshold >= randomNum)
            {
                bool uniqueAbility = false;

                while (true != uniqueAbility)
                {
                    int abilityIndex                  = UnityEngine.Random.Range(0, NUMBER_OF_PROJECT_TECHNOLOGIES);
                    ProjectTechnology newAbility      = (ProjectTechnology)abilityIndex;
                    float             newAbilityValue = UnityEngine.Random.Range(0.0f, LocalWorker.MAX_ABILITY_VALUE);
                    uniqueAbility = (false == workerAbilities.ContainsKey(newAbility));

                    if (true == uniqueAbility)
                    {
                        workerAbilities.Add(newAbility, new SafeFloat(newAbilityValue));
                    }
                }
            }

            abilityAddTreshold -= 10 * (i + 1);
        }

        return(workerAbilities);
    }
Example #19
0
        public ActionResult Edit(Project project, List <int> myTechnologies)
        {
            Project old = db.Projects.Find(project.ID);

            old.Name        = project.Name;
            old.Description = project.Description;
            old.Code        = project.Code;
            db.ProjectTechnologies.RemoveRange(old.ProjectTechnologies);
            old.ProjectTechnologies.Clear();

            for (int i = 0; i < myTechnologies.Count; i++)
            {
                ProjectTechnology projectTechnology = new ProjectTechnology();
                projectTechnology.ID_Project    = old.ID;
                projectTechnology.ID_Technology = myTechnologies[i];
                db.ProjectTechnologies.Add(projectTechnology);
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.Entry(old).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Home"));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    ViewBag.Error = "Nastala chyba. Opakujte prosím akci.";
                }
            }
            ViewBag.technologies   = new MultiSelectList(db.Technologies.Where(t => t.ProjectTechnologies.Select(s => s.ID_Project).Contains(project.ID) == false), "ID", "Name");
            ViewBag.myTechnologies = new MultiSelectList(db.Technologies.Where(t => t.ProjectTechnologies.Select(s => s.ID_Project).Contains(project.ID)), "ID", "Name");
            return(RedirectToAction("Edit", new { id = old.ID }));
        }
 public IHttpActionResult AddTechnology(ProjectTechnology projectTechnology, int projectId)
 {
     return(Ok(_projectTechnologyManager.AddTech(projectTechnology, projectId)));
 }
Example #21
0
        // END SKILL CRUD METHODS
        // ######
        // BEGIN ASSIGNREQUEST CRUD METHODS
        public async Task AssignSkillAsync(AssignRequest assignRequest)
        {
            switch (assignRequest.SkillType)
            {
            case Project.LanguageSkill:
                var language = await context.Languages.FirstOrDefaultAsync(l => l.Name == assignRequest.Name);

                if (language == null)
                {
                    language = new Language {
                        Name = assignRequest.Name
                    };
                    language.Slug = language.Name;
                    context.Languages.Add(language);
                    await context.SaveChangesAsync();
                }
                var pl = new ProjectLanguage
                {
                    ProjectId  = assignRequest.ProjectId,
                    LanguageId = language.Id
                };
                context.ProjectLanguages.Add(pl);
                await context.SaveChangesAsync();

                break;

            case Project.PlatformSkill:
                var platform = await context.Platforms.FirstOrDefaultAsync(l => l.Name == assignRequest.Name);

                if (platform == null)
                {
                    platform = new Platform {
                        Name = assignRequest.Name
                    };
                    platform.Slug = platform.Name;
                    context.Platforms.Add(platform);
                    await context.SaveChangesAsync();
                }
                var pp = new ProjectPlatform
                {
                    ProjectId  = assignRequest.ProjectId,
                    PlatformId = platform.Id
                };
                context.ProjectPlatforms.Add(pp);
                await context.SaveChangesAsync();

                break;

            case Project.TechnologySkill:
                var technology = await context.Technologies.FirstOrDefaultAsync(l => l.Name == assignRequest.Name);

                if (technology == null)
                {
                    technology = new Technology {
                        Name = assignRequest.Name
                    };
                    technology.Slug = technology.Name;
                    context.Technologies.Add(technology);
                    await context.SaveChangesAsync();
                }
                var pt = new ProjectTechnology
                {
                    ProjectId    = assignRequest.ProjectId,
                    TechnologyId = technology.Id
                };
                context.ProjectTechnologies.Add(pt);
                await context.SaveChangesAsync();

                break;

            default:
                break;
            }
        }
Example #22
0
        public async Task AssignCategoryAsync(AssignRequest assignRequest)
        {
            switch (assignRequest.CategoryType)
            {
            case Project.LanguageCategory:
                var language = await context.Languages.FirstOrDefaultAsync(la => la.Name == assignRequest.Name);

                if (language == null)
                {
                    language = new Language {
                        Name = assignRequest.Name
                    };
                    await SaveLanuguageAsync(language);
                }
                var lc = new ProjectLanguage
                {
                    ProjectId  = assignRequest.ProjectId,
                    LanguageId = language.Id
                };
                context.ProjectLanguages.Add(lc);
                await context.SaveChangesAsync();

                break;

            case Project.PlatformCategory:
                var platform = await context.Platforms.FirstOrDefaultAsync(plat => plat.Name == assignRequest.Name);

                if (platform == null)
                {
                    platform = new Platform {
                        Name = assignRequest.Name
                    };
                    await SavePlatformAsync(platform);
                }
                var pl = new ProjectPlatform
                {
                    ProjectId  = assignRequest.ProjectId,
                    PlatformId = platform.Id
                };
                context.ProjectPlatforms.Add(pl);
                await context.SaveChangesAsync();

                break;

            case Project.TechnologyCategory:
                var technology = await context.Technologies.FirstOrDefaultAsync(tech => tech.Name == assignRequest.Name);

                if (technology == null)
                {
                    technology = new Technology {
                        Name = assignRequest.Name
                    };
                    await SaveTechnologyAsync(technology);
                }
                var te = new ProjectTechnology
                {
                    ProjectId    = assignRequest.ProjectId,
                    TechnologyId = technology.Id
                };
                context.ProjectTechnologies.Add(te);
                await context.SaveChangesAsync();

                break;

            default:
                break;
            }
        }
        private void OnCompanyWorkerAbilityUpdated(SharedWorker worker, ProjectTechnology workerAbility, float workerAbilityValue)
        {
            LocalWorker companyWorker = (LocalWorker)worker;

            SetWorkerAbilitiesText();
        }
Example #24
0
        public async Task <AppResult> ImportFile(FileUpload file, int?id)
        {
            AppResult appResult = new AppResult();
            var       fileName  = file.files.FileName;

            if (!ImportFileHandling.HasFileExtension(Path.GetExtension(fileName)))
            {
                appResult.Result  = false;
                appResult.Message = "CV Import Failed, Invalid file format!";
                return(appResult);
            }
            var list = await ImportFileHandling.GetInformationCV(file.files);

            if (list.Count > 0)
            {
                var resultCheckFile = ImportFileHandling.CheckFile(list);
                if (resultCheckFile.Result)
                {
                    int idPerson = 0;
                    List <SkillRequestModel> listSkill = new List <SkillRequestModel>();
                    List <int> listIdWorkHistory       = new List <int>();
                    List <SaveWorkHistoryResource> saveWorkHistoryResources = new List <SaveWorkHistoryResource>();
                    List <int> listIdEducation = new List <int>();
                    List <SaveEducationResource> saveEducationResources = new List <SaveEducationResource>();
                    List <int> listIdCertificate = new List <int>();
                    List <SaveCertificateResource> saveCertificateResources = new List <SaveCertificateResource>();
                    List <int>           listIdSkill        = new List <int>();
                    List <SkillResource> skillRequestModels = new List <SkillResource>();
                    List <int>           listIdProject      = new List <int>();
                    List <Project>       listProject        = new List <Project>();
                    try
                    {
                        using (TransactionScope txScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                        {
                            Person person = ImportFileHandling.GetPerson(list);
                            Image  image  = await ImportFileHandling.GetImageCV(file.files);

                            if (id == null)
                            {
                                var resultPerson = await _personService.InsertPersonToImportFile(person, image);

                                appResult = resultPerson.AppResult;
                                idPerson  = resultPerson.PersonInfo.Id;
                            }
                            else
                            {
                                idPerson = (int)id;
                                if (idPerson > 0)
                                {
                                    var tempPerson = await _personService.GetPersonById(idPerson);

                                    var modelPerson = (Person)tempPerson;
                                    if (modelPerson != null)
                                    {
                                        person.Id = (int)id;
                                        var resultPerson = await _personService.UpdatePersonToImportFile(person, image);

                                        appResult = resultPerson.AppResult;
                                        if (appResult.Result)
                                        {
                                            var listWorkHistoryResourceByPersonId = await _workHistoryService.GetWorkHistoryByPersonId(idPerson);

                                            saveWorkHistoryResources = listWorkHistoryResourceByPersonId.ToList();
                                            if (saveWorkHistoryResources != null)
                                            {
                                                foreach (var item in saveWorkHistoryResources)
                                                {
                                                    listIdWorkHistory.Add(item.Id);
                                                }
                                                if (listIdWorkHistory != null)
                                                {
                                                    foreach (var item in listIdWorkHistory)
                                                    {
                                                        await _workHistoryService.DeleteWorkHistory(item);
                                                    }
                                                }
                                            }
                                            var listEducationByPersonId = await _educationService.GetEducationByPersonId(idPerson);

                                            saveEducationResources = listEducationByPersonId.ToList();
                                            if (saveEducationResources != null)
                                            {
                                                foreach (var item in saveEducationResources)
                                                {
                                                    listIdEducation.Add(item.Id);
                                                }
                                                if (listIdEducation != null)
                                                {
                                                    foreach (var item in listIdEducation)
                                                    {
                                                        await _educationService.DeleteEducation(item);
                                                    }
                                                }
                                            }
                                            var listCertificateByPersonId = await _certificateService.GetCertificateByPersonId(idPerson);

                                            saveCertificateResources = listCertificateByPersonId.ToList();
                                            if (saveCertificateResources != null)
                                            {
                                                foreach (var item in saveCertificateResources)
                                                {
                                                    listIdCertificate.Add(item.Id);
                                                }
                                                if (listIdCertificate != null)
                                                {
                                                    foreach (var item in listIdCertificate)
                                                    {
                                                        await _certificateService.DeleteCertificate(item);
                                                    }
                                                }
                                            }
                                            var listSkillByPeronId = await _skillService.GetSkillByPerson(idPerson);

                                            skillRequestModels = listSkillByPeronId.ToList();
                                            if (skillRequestModels != null)
                                            {
                                                foreach (var item in skillRequestModels)
                                                {
                                                    listIdSkill.Add(item.PersonCategoryId);
                                                }
                                                if (listIdSkill != null)
                                                {
                                                    foreach (var item in listIdSkill)
                                                    {
                                                        await _skillService.DeleteSkill(item);
                                                    }
                                                }
                                            }
                                            var listProjectByPersonId = await _projectService.GetProjectByPersonId(idPerson);

                                            listProject = listProjectByPersonId.ToList();
                                            if (listProject != null)
                                            {
                                                foreach (var item in listProject)
                                                {
                                                    listIdProject.Add(item.Id);
                                                }
                                                if (listIdProject != null)
                                                {
                                                    foreach (var item in listIdProject)
                                                    {
                                                        await _projectService.DeleteProject(item);
                                                    }
                                                }
                                            }
                                        }
                                        idPerson = resultPerson.PersonInfo.Id;
                                    }
                                    else
                                    {
                                        appResult.Result  = false;
                                        appResult.Message = "CV Import Failed, CV not exist";
                                        return(appResult);
                                    }
                                }
                            }
                            if (idPerson > 0)
                            {
                                List <CreateWorkHistoryResource> workHistoryResources = ImportFileHandling.GetListWorkHistory(list, idPerson);
                                if (workHistoryResources != null)
                                {
                                    foreach (var item in workHistoryResources)
                                    {
                                        if (item != null)
                                        {
                                            await _workHistoryService.CreateWorkHistory(item);
                                        }
                                    }
                                }
                                List <CreateEducationResource> createEducationResources = ImportFileHandling.GetListEducation(list, idPerson);
                                if (createEducationResources != null)
                                {
                                    foreach (var item in createEducationResources)
                                    {
                                        if (item != null)
                                        {
                                            await _educationService.CreateEducation(item);
                                        }
                                    }
                                }
                                List <CreateCertificateResource> createCertificateResources = ImportFileHandling.GetListCertifiate(list, idPerson);
                                if (createCertificateResources != null)
                                {
                                    foreach (var item in createCertificateResources)
                                    {
                                        if (item != null)
                                        {
                                            await _certificateService.CreateCertificate(item);
                                        }
                                    }
                                }
                                List <Category> categories = ImportFileHandling.GetListCategory(list);
                                List <int>      Category   = new List <int>();
                                if (categories != null)
                                {
                                    listSkill = new List <SkillRequestModel>();
                                    foreach (var groupItem in categories)
                                    {
                                        var resultCategory = await _categoryService.InsertCategory(groupItem);

                                        int idCategory = resultCategory.Category.Id;
                                        Category.Add(idCategory);
                                        List <int> listTechnology = new List <int>();
                                        foreach (var item in groupItem.Technologies)
                                        {
                                            item.CategoryId = idCategory;
                                            var resultTechnology = await _technologyService.InsertTechnology(item);

                                            int idTechnology = resultTechnology.Technology.Id;
                                            listTechnology.Add(idTechnology);
                                        }
                                        SkillRequestModel skill = new SkillRequestModel
                                        {
                                            PersonId     = idPerson,
                                            CategoryId   = idCategory,
                                            TechnologyId = listTechnology
                                        };
                                        listSkill.Add(skill);
                                    }
                                    if (listSkill.Count > 0)
                                    {
                                        foreach (var item in listSkill)
                                        {
                                            await _skillService.InserSkill(item);
                                        }
                                    }
                                }
                                List <Project> projects = ImportFileHandling.GetListProject(list, idPerson);
                                if (projects != null)
                                {
                                    foreach (var gorupItem in projects)
                                    {
                                        List <ProjectTechnology> projectTechnologies = new List <ProjectTechnology>();
                                        var resultProject = await _projectService.InsertProject(gorupItem);

                                        int idProject = resultProject.Project.Id;
                                        foreach (var item in gorupItem.Technologies)
                                        {
                                            ProjectTechnology projectTechnology = new ProjectTechnology
                                            {
                                                ProjectId    = idProject,
                                                TechnologyId = await _technologyService.GetTechnologyByPersonAndNameAsync(idPerson, item.Name)
                                            };
                                            projectTechnologies.Add(projectTechnology);
                                        }
                                        await _projectTechnologyService.InsertListTechnologyAsync(projectTechnologies);
                                    }
                                }
                            }
                            txScope.Complete();
                        }
                    }
                    catch
                    {
                        appResult.Result  = false;
                        appResult.Message = "CV Import Failed, file is invalid!";
                    }
                }
                else
                {
                    appResult.Result  = false;
                    appResult.Message = resultCheckFile.Message;
                }
            }
            else
            {
                appResult.Result  = false;
                appResult.Message = "CV Import Failed, file is invalid!";
            }
            return(appResult);
        }
Example #25
0
 public Task <int> UpdateAsync(ProjectTechnology entity)
 {
     throw new NotImplementedException();
 }
 public IHttpActionResult EditTechnology(ProjectTechnology projectTechnology)
 {
     return(Ok(_projectTechnologyManager.Edit(projectTechnology)));
 }
Example #27
0
 public ProjectTechnology AddTech(ProjectTechnology tech, int projectId)
 {
     tech.ProjectId = projectId;
     return(_projectTechnologyRepository.Create(tech));
 }
Example #28
0
 public ProjectTechnology Edit(ProjectTechnology tech)
 {
     return(_projectTechnologyRepository.Edit(tech));
 }
Example #29
0
        public static object Deserialize(byte[] workerBytes)
        {
            if (null == Resources)
            {
                GameObject scriptsObject = GameObject.FindGameObjectWithTag("ScriptsGameObject");
                Resources = scriptsObject.GetComponent <ResourceHolder>();;
            }

            int offset = 0;

            int nameIndex = BitConverter.ToInt32(workerBytes, offset);

            offset += sizeof(int);
            int surenameIndex = BitConverter.ToInt32(workerBytes, offset);

            offset += sizeof(int);
            int avatarIndex = BitConverter.ToInt32(workerBytes, offset);

            offset += sizeof(int);
            int abilitiesSize = BitConverter.ToInt32(workerBytes, offset);

            offset += sizeof(int);

            Dictionary <ProjectTechnology, SafeFloat> abilities = new Dictionary <ProjectTechnology, SafeFloat>();

            for (int i = 0; i < abilitiesSize; i++)
            {
                ProjectTechnology abilityType = (ProjectTechnology)BitConverter.ToInt32(workerBytes, offset);
                offset += sizeof(int);
                float abilityValue = BitConverter.ToSingle(workerBytes, offset);
                offset += sizeof(float);
                abilities.Add(abilityType, new SafeFloat(abilityValue));
            }

            int expierienceTime = BitConverter.ToInt32(workerBytes, offset);

            offset += sizeof(int);
            int salary = BitConverter.ToInt32(workerBytes, offset);

            offset += sizeof(int);
            int workerID = BitConverter.ToInt32(workerBytes, offset);

            offset += sizeof(int);
            Gender workerGender = (Gender)BitConverter.ToInt32(workerBytes, offset);

            string name     = (Gender.Male == workerGender) ? WorkerData.MaleNames[nameIndex] : WorkerData.FemaleNames[nameIndex];
            string surename = WorkerData.Surenames[surenameIndex];
            Sprite avatar   = (Gender.Male == workerGender) ? Resources.MaleCharactersAvatars[avatarIndex] : Resources.FemaleCharactersAvatars[avatarIndex];

            SharedWorker deserializedWorker = new SharedWorker(name, surename, workerGender);

            deserializedWorker.Abilites       = abilities;
            deserializedWorker.ExperienceTime = expierienceTime;
            deserializedWorker.Salary         = salary;
            deserializedWorker.ID             = workerID;
            deserializedWorker.NameIndex      = nameIndex;
            deserializedWorker.SurenameIndex  = surenameIndex;
            deserializedWorker.AvatarIndex    = avatarIndex;
            deserializedWorker.Avatar         = avatar;

            return(deserializedWorker);
        }