Exemplo n.º 1
0
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="PhoneDTO"/> converted from <see cref="Phone"/>.</param>
 static partial void OnDTO(this Experience entity, ExperienceDTO dto)
 {
     if (entity != null && entity.Business != null)
     {
         dto.Business = BusinessAssembler.ToDTO(entity.Business);
     }
 }
Exemplo n.º 2
0
        public async Task <List <ExperienceDTO> > buildExperience(int cvId)
        {
            List <ExperienceDTO> experienceList = new List <ExperienceDTO>();
            List <Experience>    experience     = await dbContext.Experience.Include(p => p.SkillsExperience).Where(p => p.CvId == cvId).OrderByDescending(p => p.DateFrom).ToListAsync();

            foreach (Experience expr in experience)
            {
                List <string>   skills = dbContext.SkillsExperience.Where(p => p.ExperienceId == expr.Id).Select(p => p.Skills.Label).ToList();
                List <TasksDTO> tasks  = dbContext.Tasks.Where(p => p.ExperienceId == expr.Id).Select(p => new TasksDTO
                {
                    Label = p.Label
                }).ToList();
                ExperienceDTO buildExperience = new ExperienceDTO
                {
                    Company  = expr.Company,
                    DateFrom = expr.DateFrom,
                    DateTo   = expr.DateTo,
                    Title    = expr.Title,
                    Skills   = skills,
                    Tasks    = tasks,
                };
                experienceList.Add(buildExperience);
            }
            return(experienceList);
        }
Exemplo n.º 3
0
        public void CreateExperience(ExperienceDTO experience)
        {
            var mapped = _mapper.Map <Experience>(experience);

            _context.ExperienceEntities.Add(mapped);
            _context.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public async Task <IActionResult> postExperience(ExperienceDTO input)
        {
            var user = await userManager.FindByIdAsync(input.userID);

            if (input.newExperience)
            {
                if (user.Experiences == null)
                {
                    user.Experiences = new List <Experience>();
                }
                user.Experiences.Add(new Experience
                {
                    Title       = input.title,
                    Assignments = input.Assignments,
                    Language    = input.Language,
                    Role        = input.Role,
                    StartDate   = input.startDate,
                    EndDate     = input.endDate,
                    Software    = input.Software,
                    id          = input.id
                });
            }
            else
            {
                for (int i = 0; i < user.Experiences.Count; i++)
                {
                }
            }
            await userManager.UpdateAsync(user);

            return(Ok(user.Experiences));
        }
Exemplo n.º 5
0
        public void EditExperience(ExperienceDTO experienceDTO)
        {
            if (experienceDTO == null)
            {
                throw new ArgumentNullException(nameof(experienceDTO));
            }

            Experience experience = Database.Experiences.Get(experienceDTO.Id);

            if (experience == null)
            {
                throw new ArgumentOutOfRangeException("Not found experience");
            }

            Resume resume = Database.Resumes.Get(experienceDTO.ResumeId);

            if (resume == null)
            {
                throw new ArgumentOutOfRangeException("Invalid argument ResumeId");
            }

            experience.ResumeId     = experienceDTO.ResumeId;
            experience.Company      = experienceDTO.Company;
            experience.LastPosition = experienceDTO.LastPosition;
            experience.StartDate    = experienceDTO.StartDate;
            experience.FinishDate   = experienceDTO.FinishDate;
            experience.Resume       = resume;

            Database.Experiences.Update(experience);
            Database.Save();
        }
Exemplo n.º 6
0
        public async Task <Result <SkillsDTO> > GetUserSkills(string userId)
        {
            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(Result <SkillsDTO> .CreateFailed(
                           HttpStatusCode.NotFound, "User not found"));
            }

            var expiriences = await _context.Experiences.Where(x => x.User == user).ToListAsync();

            var educations = await _context.Educations.Where(x => x.User == user).ToListAsync();

            var personalSkills = await _context.PersonalSkills.Where(x => x.User == user).ToListAsync();

            var a = Result <SkillsDTO> .CreateSuccessful(
                new SkillsDTO(
                    ExperienceDTO.ToExperienceDTOList(expiriences),
                    EducationDTO.ToEducationDTOList(educations),
                    PersonalSkillDTO.ToPersonalSkillDTOList(personalSkills)
                    ));

            return(a);
        }
        public IHttpActionResult PutExperience(int id, ExperienceDTO experience)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != experience.ExperienceID)
            {
                return(BadRequest());
            }

            try
            {
                db.Create(experience);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExperienceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 8
0
        public async Task CreateAsync(ExperienceDTO experienceDTO)
        {
            // if no Job is provided
            if (experienceDTO.Job == null)
            {
                throw new ArgumentNullException(nameof(experienceDTO.Job));
            }

            var adminRoleId = this.roles.AllAsNoTracking().FirstOrDefault(x => x.Name == GlobalConstants.AdministratorRoleName).Id;
            var user        = this.users.All().FirstOrDefault(x => x.Roles.Any(x => x.RoleId == adminRoleId));

            var experience = new Experience
            {
                Job           = experienceDTO.Job.Trim(),
                Company       = experienceDTO.Company.Trim(),
                Url           = experienceDTO.Url.Trim(),
                Logo          = experienceDTO.Logo.Trim(),
                StartDate     = DateTime.Parse(experienceDTO.StartDate.Trim(), CultureInfo.InvariantCulture).Date,
                EndDate       = DateTime.Parse(experienceDTO.EndDate.Trim(), CultureInfo.InvariantCulture).Date,
                IconClassName = experienceDTO.IconClassName.Trim(),
                Details       = experienceDTO.Details.Trim(),
                UserId        = user.Id,
            };

            await this.experiencesRepository.AddAsync(experience);

            await this.experiencesRepository.SaveChangesAsync();
        }
 public void Add(ExperienceDTO DTO)
 {
     using (var container = new InventoryContainer())
     {
         EmpExperienceInfo gur = new EmpExperienceInfo();
         container.EmpExperienceInfoes.AddObject((EmpExperienceInfo)DTOMapper.DTOObjectConverter(DTO, gur));
         container.SaveChanges();
     }
 }
Exemplo n.º 10
0
        public ExperienceDTO Create(ExperienceDTO modelDTO)
        {
            if (modelDTO != null)
            {
                return(ExperienceAssembler.ToDTO(ExperiencesRepo.Create(ExperienceAssembler.ToEntity(modelDTO))));
            }

            return(null);
        }
Exemplo n.º 11
0
        public void EditExperience_NullElement_ShouldThrowException()
        {
            //arrange
            var experience = new ExperienceDTO {
                Id = It.IsAny <int>()
            };

            //act & assert
            NUnit.Framework.Assert.Throws <ArgumentOutOfRangeException>(() => expService.EditExperience(experience));
        }
Exemplo n.º 12
0
 public void Update(ExperienceDTO experienceDTO)
 {
     Company     = experienceDTO.Company;
     StartDate   = experienceDTO.StartDate;
     EndDate     = experienceDTO.EndDate;
     Link        = experienceDTO.Link;
     StillThere  = experienceDTO.StillThere;
     Title       = experienceDTO.Title;
     Description = experienceDTO.Description;
     IsPublic    = experienceDTO.IsPublic;
 }
        public IHttpActionResult PostExperience(ExperienceDTO experience)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Create(experience);

            return(CreatedAtRoute("DefaultApi", new { id = experience.ExperienceID }, experience));
        }
Exemplo n.º 14
0
        public IHttpActionResult GetExperience(int id)
        {
            ExperienceDTO experience = db.Get(id);

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

            return(Ok(experience));
        }
Exemplo n.º 15
0
        public ExperienceDTO Update(ExperienceDTO modelDTO)
        {
            ExperienceDTO returnExperience = null;

            if (modelDTO != null && modelDTO.ExperienceID > 0)
            {
                ExperiencesRepo.Update(0, ExperienceAssembler.ToEntity(modelDTO));
                returnExperience = modelDTO;
            }

            return(returnExperience);
        }
Exemplo n.º 16
0
        public Experience ConvertToEF(ExperienceDTO DTO)
        {
            var EF = new Experience()
            {
                ExperienceId = DTO.ExperienceId,
                EMax         = DTO.EMax,
                EMin         = DTO.EMin,
                EShow        = DTO.EShow
            };

            return(EF);
        }
Exemplo n.º 17
0
        public void CreateExperience_TryToCreateExperience_ShouldRepositoryCreateOnce()
        {
            var Experience = new ExperienceDTO {
                Id = It.IsAny <int>(), ResumeId = It.IsAny <int>()
            };

            // act
            expService.CreateExperience(Experience);

            //assert
            expRepository.Verify(x => x.Create(It.IsAny <Experience>()));
        }
Exemplo n.º 18
0
        public ExperienceDTO ConvertToDTO(Experience EF)
        {
            var DTO = new ExperienceDTO()
            {
                ExperienceId = EF.ExperienceId,
                EMax         = EF.EMax,
                EMin         = EF.EMin,
                EShow        = EF.EShow
            };

            return(DTO);
        }
Exemplo n.º 19
0
 public IActionResult UpdateUserExperience(Guid id, Guid experienceId, [FromBody] ExperienceDTO experience)
 {
     try
     {
         experience.UserID       = id;
         experience.ExperienceID = experienceId;
         _userExperienceService.UpdateExperience(experienceId, experience);
         return(NoContent());
     }
     catch (Exception e)
     {
         return(_handler.HandleError(e));
     }
 }
Exemplo n.º 20
0
        public void CreateExperience_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var           service    = this.CreateService();
            ExperienceDTO experience = null;

            // Act
            //service.CreateExperience(
            //    experience);

            // Assert
            Assert.True(true);
            this.mockRepository.VerifyAll();
        }
Exemplo n.º 21
0
        public ExperienceDTO Get(int id)
        {
            ExperienceDTO oExperienceDTO = null;

            if (id > 0)
            {
                Experience oExperience = ExperiencesRepo.Get(id);
                if (oExperience != null)
                {
                    oExperienceDTO = ExperienceAssembler.ToDTO(oExperience);
                }
            }

            return(oExperienceDTO);
        }
Exemplo n.º 22
0
        public void RemoveExperience(ExperienceDTO experienceDTO)
        {
            if (experienceDTO == null)
            {
                throw new ArgumentNullException(nameof(experienceDTO));
            }

            if (Database.Experiences.Get(experienceDTO.Id) == null)
            {
                throw new ArgumentOutOfRangeException("Not found experience");
            }

            Database.Experiences.Delete(experienceDTO.Id);
            Database.Save();
        }
        public async Task <ActionResult <ExperienceDTO> > PostExperience(ExperienceDTO experienceDTO)
        {
            Experience sanitizedExperience = DTOToExperience(experienceDTO);

            if (!await ResumeAccessAuthorized(sanitizedExperience.ResumeId))
            {
                return(GenerateResumeNotFoundError(sanitizedExperience.ResumeId));
            }


            _context.Experiences.Add(sanitizedExperience);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("PostExperience", new { resumeId = sanitizedExperience.ResumeId, order = sanitizedExperience.Order }, experienceDTO));
        }
Exemplo n.º 24
0
        public IHttpActionResult PostExperience(ExperienceDTO experience)
        {
            //experience = new ExperienceDTO();
            //experience.BusinessID = 18;
            //experience.JobPossition = "Software Developer";
            //experience.UserID = 50;

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

            var objExprience = db.Create(experience);

            return(CreatedAtRoute("DefaultApi", new { id = experience.ExperienceID }, objExprience));
        }
Exemplo n.º 25
0
        public async Task <IActionResult> removeExperience(ExperienceDTO input)
        {
            var user = await userManager.FindByIdAsync(input.userID);

            for (int i = 0; i < user.Experiences.Count; i++)
            {
                if (user.Experiences[i].id == input.id)
                {
                    user.Experiences.RemoveAt(i);
                    await userManager.UpdateAsync(user);

                    return(Ok(user.Experiences));
                }
            }
            return(BadRequest());
        }
Exemplo n.º 26
0
        public void UpdateExperience_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var           service    = this.CreateService();
            Guid          id         = default(global::System.Guid);
            ExperienceDTO experience = null;

            // Act
            //service.UpdateExperience(
            //    id,
            //    experience);

            // Assert
            Assert.True(true);
            this.mockRepository.VerifyAll();
        }
Exemplo n.º 27
0
        public ActionResult Edit(ExperienceViewModel model)
        {
            var experienceDTO = new ExperienceDTO
            {
                Id              = model.Id,
                CompanyName     = model.CompanyName.Trim(),
                CountExperience = model.CountExperience.Trim(),
                CityId          = model.CityId,
                KnowledgeId     = model.KnowledgeId,
                UserId          = model.UserId
            };

            experienceService.Update(experienceDTO);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 28
0
        public void RemoveExperience_Delete()
        {
            var Experience = new ExperienceDTO {
                Id = It.IsAny <int>(), Company = It.IsAny <string>()
            };

            expRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(new Experience {
                Id = It.IsAny <int>(), Company = It.IsAny <string>()
            });

            //act
            expService.RemoveExperience(Experience);

            //assert
            expRepository.Verify(x => x.Delete(It.IsAny <int>()));
        }
Exemplo n.º 29
0
        public void CreateUserExperience_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var           usersController = this.CreateUsersController();
            Guid          id         = default(global::System.Guid);
            ExperienceDTO experience = new ExperienceDTO();

            // Act
            var result = usersController.CreateUserExperience(
                id,
                experience);

            // Assert
            Assert.True(true);
            this.mockRepository.VerifyAll();
        }
Exemplo n.º 30
0
        public async Task <Result <ExperienceDTO> > SaveExperience(string userId, ExperienceDTO experienceDTO)
        {
            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(Result <ExperienceDTO> .CreateFailed(
                           HttpStatusCode.NotFound, "User not found"));
            }

            var expirience = await _context.Experiences.Where(x => x.User == user && x.Id == experienceDTO.Id).FirstOrDefaultAsync();

            if (expirience != null)
            {
                expirience.Update(experienceDTO);
                await _knnService.RemoveSkill(expirience, user);
            }
            else
            {
                expirience = new Experience();
                expirience.Update(experienceDTO);
                expirience.User = user;
                await _context.Experiences.AddAsync(expirience);
            }

            if (expirience.StillThere == true)
            {
                user.CurrentState = expirience.Description + " at " + expirience.Company;
            }

            await _knnService.ManageSkill(expirience, user);


            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(Result <ExperienceDTO> .CreateFailed(
                           HttpStatusCode.NotFound, "Error Changes are not saved"));;
            }

            return(Result <ExperienceDTO> .CreateSuccessful(new ExperienceDTO(expirience)));
        }