Esempio n. 1
0
        public async Task <bool> ApplyCV(int postId, int userId, int cvId)
        {
            if (!await IsUserApplied(postId, userId))
            {
                _uow.AppliedCVRepository.Insert(new Application()
                {
                    CVId   = cvId,
                    PostId = postId,
                    Viewed = false
                });
                Models.CV cv = await _uow.CVRepository.GetById(cvId);

                RecruitmentPost post = await _uow.RecruitmentRepository.GetById(postId);

                if (await _uow.AccessKeyRepository.GetFirst(filter: key => key.DataKey == cv.DataKey && key.UserId == post.CompanyId) == null)
                {
                    _uow.AccessKeyRepository.Insert(new AccessKey()
                    {
                        DataKey = cv.DataKey,
                        UserId  = post.CompanyId
                    });
                }
                Models.Employee employee = await _uow.EmployeeRepository.GetById(userId);

                if (await _uow.AccessKeyRepository.GetFirst(filter: key => key.DataKey == employee.DataKey && key.UserId == post.CompanyId) == null)
                {
                    _uow.AccessKeyRepository.Insert(new AccessKey()
                    {
                        DataKey = employee.DataKey,
                        UserId  = post.CompanyId
                    });
                }
            }
            return(await _uow.CommitAsync() > 0);
        }
Esempio n. 2
0
        public async Task <bool> UpdateCV(NewCVParam param)
        {
            Models.CV cv = await _uow.CVRepository.GetById(param.CVId);

            cv.MajorId = param.MajorId;
            cv.Title   = param.Title;
            _uow.CVRepository.Update(cv);
            return(await _uow.CommitAsync() > 0);
        }
Esempio n. 3
0
        public async Task <CVDataset> GetCVById(int id, string lang = "vi")
        {
            CVDataset result = null;

            Models.CV cv = await _uow.CVRepository.GetFirst(filter : cv => cv.CVId == id, includeProperties : "Employee,Employee.Account");

            if (cv != null)
            {
                result       = _mapper.Map <CVDataset>(cv);
                result.Major = new Datasets.Major.MajorDataset()
                {
                    MajorId   = cv.MajorId.GetValueOrDefault(0),
                    MajorName = (await _uow.TranslationRepository.GetFirst(filter: t => t.MajorId == cv.MajorId.GetValueOrDefault(0) && t.Language == lang)).Text
                };
                IEnumerable <Section> sections = await _uow.SectionRepository.Get(filter : section => section.CVId == id, includeProperties : "SectionType");

                IEnumerable <SectionField> fields = await _uow.SectionFieldRepository.Get(filter : field => field.Section.CVId == id, includeProperties : "Section");

                IEnumerable <Models.Video> videos = await _uow.VideoRepository.Get(filter : video => video.Section.CVId == id, includeProperties : "Section,VideoStyle");

                result.Sections = (from section in sections
                                   select new CVSectionDataset()
                {
                    SectionId = section.SectionId,
                    CVId = id,
                    SectionTypeId = section.SectionTypeId,
                    Text = section.Text,
                    Title = section.DisplayTitle,
                    Icon = section.SectionType.Image,
                    Fields = (from field in fields
                              where field.SectionId == section.SectionId
                              select new CVFieldDataset()
                    {
                        FieldId = field.FieldId,
                        Name = field.FieldTitle,
                        Text = field.Text
                    }).ToList(),
                    Videos = (from video in videos
                              where video.SectionId == section.SectionId
                              select new VideoDataset()
                    {
                        AspectRatio = video.AspectRatio,
                        ThumbUrl = video.ThumbUrl,
                        VideoUrl = video.VideoUrl,
                        CoverUrl = video.CoverUrl,
                        VideoId = video.VideoId,
                        VideoStyle = new VideoStyleDataset()
                        {
                            StyleId = video.VideoStyle.StyleId,
                            StyleName = video.VideoStyle.StyleName
                        }
                    }).ToList()
                }).ToList();
            }
            return(result);
        }
Esempio n. 4
0
 public async Task <CVDataset> CreateCV(int userId, string cvName, int majorId)
 {
     Models.CV cv = new Models.CV()
     {
         EmployeeId = userId,
         Title      = cvName,
         MajorId    = majorId
     };
     _uow.CVRepository.Insert(cv);
     if (await _uow.CommitAsync() > 0)
     {
         return(_mapper.Map <CVDataset>(await _uow.CVRepository.GetById(cv.CVId)));
     }
     return(null);
 }