Exemplo n.º 1
0
        public ResponseCVDTO CreateCV(CVDTO cvDTO)
        {
            if (cvDTO == null)
            {
                return(null);
            }
            var responseCVDTO = new ResponseCVDTO();

            var cv   = _mapper.Map <CV>(cvDTO);
            var user = _userRepository.GetFilter(x => x.Id == cvDTO.UserId);

            user.Result.CV = cv;
            _userRepository.Update(user.Result);

            responseCVDTO = _mapper.Map <ResponseCVDTO>(cv);

            //Toplam çalışma süresini hesaplayı response da gösterilmesi amaçlanmaktadır.
            TimeSpan workTime = new TimeSpan();

            foreach (var experience in responseCVDTO.ResponseExperienceInformationsDTO)
            {
                workTime += experience.EndDate - experience.StartDate;
            }
            var year  = (int)(workTime.Days / 365.2425);
            var month = (int)((workTime.Days % 365.2425) / 30.436875);
            var day   = (int)(((workTime.Days % 365.2425) % 30.436875));

            responseCVDTO.TotalWorkTime = year + " Yıl " + month + " Ay " + day + " Gün";

            return(responseCVDTO);
        }
Exemplo n.º 2
0
        public void Insert(CVDTO dto)
        {
            ATPEntities context = new ATPEntities();

            context.CV.Add(Convert(dto));
            context.SaveChanges();
        }
Exemplo n.º 3
0
        public async Task <IActionResult> updateCV(CVDTO input)
        {
            var user = await userManager.FindByIdAsync(input.userID);

            if (user.CV == null)
            {
                user.CV = new CV();
            }
            user.CV.company_name                         = input.company_name;
            user.CV.color                                = input.color;
            user.CV.company_logo                         = input.company_logo;
            user.CV.contact_phoneNumber                  = input.contact_phoneNumber;
            user.CV.contact_website                      = input.contact_website;
            user.CV.contact_email                        = input.contact_email;
            user.CV.consult_picture                      = input.consult_picture;
            user.CV.consult_name                         = input.consult_name;
            user.CV.consult_role                         = input.consult_role;
            user.CV.consult_presentations                = input.consult_presentations;
            user.CV.consult_experience_focus_title       = input.consult_experience_focus_title;
            user.CV.consult_experience_focus_role        = input.consult_experience_focus_role;
            user.CV.consult_experience_focus_description = input.consult_experience_focus_description;
            user.CV.sale_name                            = input.sale_name;
            user.CV.sale_email                           = input.sale_email;
            user.CV.sale_phone                           = input.sale_phone;
            user.CV.consult_experience_other_list        = input.consult_experience_other_list;
            await userManager.UpdateAsync(user);

            return(Ok(user.CV));
        }
Exemplo n.º 4
0
 public ActionResult Edit(CVModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.Picture != null)
         {
             _service.Edit(Convert(model));
         }
         else
         {
             CVDTO dto = _service.Get(model.ID);
             dto.Address    = model.Address;
             dto.Education  = model.Education;
             dto.Email      = model.Email;
             dto.Experience = model.Experience;
             dto.Qualities  = model.Qualities;
             _service.Edit(dto);
         }
         return(RedirectToAction("List"));
     }
     else
     {
         return(View(model));
     }
 }
Exemplo n.º 5
0
 private CV Convert(CVDTO dto) =>
 new CV
 {
     Address     = dto.Address,
     Education   = dto.Education,
     Email       = dto.Email,
     Experience  = dto.Experience,
     FirstName   = dto.FirstName,
     LastName    = dto.LastName,
     Qualities   = dto.Qualities,
     Picture     = dto.PictureBytes,
     PictureName = dto.PictureName
 };
Exemplo n.º 6
0
        public void Edit(CVDTO dto)
        {
            ATPEntities context = new ATPEntities();
            CV          entity  = context.CV.FirstOrDefault(element => element.ID == dto.ID);

            entity.Address     = dto.Address;
            entity.Education   = dto.Education;
            entity.Email       = dto.Email;
            entity.Experience  = dto.Experience;
            entity.FirstName   = dto.FirstName;
            entity.ID          = dto.ID;
            entity.LastName    = dto.LastName;
            entity.Qualities   = dto.Qualities;
            entity.Picture     = dto.PictureBytes;
            entity.PictureName = dto.PictureName;
            context.SaveChanges();
        }
Exemplo n.º 7
0
        public void Add_TryToCreate_RepositoryShouldCallOnce()
        {
            //act
            var cv = new CVDTO
            {
                Position          = It.IsAny <string>(),
                Id                = It.IsAny <int>(),
                Skills            = It.IsAny <string>(),
                Education         = It.IsAny <string>(),
                Language          = It.IsAny <string>(),
                WorkingExperience = It.IsAny <string>(),
                Goal              = It.IsAny <string>(),
            };

            cvService.Add(cv);

            //assert
            cvRepository.Verify(x => x.Add(It.IsAny <CV>()), Times.Once);
        }
Exemplo n.º 8
0
        public async Task <CVServiceModel> AddAsync(CVCreationServiceModel cvServiceModel)
        {
            Guid?userId          = cvServiceModel.UserId;
            var  educationsToAdd =
                _mapper.Map <
                    ICollection <EducationWithDetailsServiceModel>,
                    ICollection <EducationWithDetailsDTO> >
                    (cvServiceModel.Educations);


            if (userId == null)
            {
                UserFullInfoDTO userToAdd =
                    _mapper.Map <
                        UserCreationServiceModel,
                        UserFullInfoDTO>
                        (cvServiceModel.User);
                userToAdd.Educations = educationsToAdd;

                var createdUser = await _uow.Users.AddAsync(userToAdd);

                userId = createdUser.Id;
                cvServiceModel.UserId = userId;
            }
            else // check if user has educations
            {
                var addedEducations = await _uow.Users.AddEducationsNoExistAsync(educationsToAdd, (Guid)userId);

                educationsToAdd = _mapper.Map <ICollection <Education>, ICollection <EducationWithDetailsDTO> >(addedEducations);
            }

            CVCreationDTO cv        = _mapper.Map <CVCreationServiceModel, CVCreationDTO>(cvServiceModel);
            CVDTO         createdCV = await _uow.CVs.AddAsync(cv);

            createdCV.Educations = educationsToAdd;
            await _uow.CVs.LinkUserToCV(createdCV.Id, (Guid)userId);

            CVServiceModel result = _mapper.Map <CVDTO, CVServiceModel>(createdCV);

            return(result);
        }
Exemplo n.º 9
0
    public IActionResult CreateCV(CVDTO model)
    {
        var user = _userService.GetUserById(model.UserId);

        if (string.IsNullOrEmpty(user.Id))
        {
            return(OK(StatusCodeType.USER_NOTFOUND, StatusMessage.USER_NOTFOUND, false));
        }

        if (!string.IsNullOrEmpty(user.ResponseCVDTO.Job))
        {
            return(OK(StatusCodeType.ALREADY_HASCV, StatusMessage.ALREADY_HASCV, false));
        }

        var response = _cvService.CreateCV(model);

        if (response == null)
        {
            return(OK(StatusCodeType.HAS_EXCEPTION, StatusMessage.HAS_EXCEPTION, response));
        }

        return(OK(StatusCodeType.SUCCESS, StatusMessage.SUCCESS, response));
    }