Exemplo n.º 1
0
        public async Task <ActionResult <CommonRecruitmentPostDataset> > GetById(int id, string lang = "vi")
        {
            string userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            CommonRecruitmentPostDataset result = await _recruitmentService.GetRecruitmentPostById(id, lang);

            if (result == null)
            {
                return(NotFound());
            }
            if (userId != null)
            {
                result.IsApplied = await _recruitmentService.IsUserApplied(id, int.Parse(userId));
            }
            return(Ok(result));
        }
Exemplo n.º 2
0
        public async Task <CommonRecruitmentPostDataset> GetRecruitmentPostById(int id, string lang = "vi")
        {
            CommonRecruitmentPostDataset result = null;
            RecruitmentPost post = await _uow.RecruitmentRepository.GetFirst(filter : post => post.PostId == id, includeProperties : "Company,Company.Account");

            if (post != null)
            {
                result       = _mapper.Map <CommonRecruitmentPostDataset>(post);
                result.Major = new Datasets.Major.MajorDataset()
                {
                    MajorId   = post.MajorId,
                    MajorName = (await _uow.TranslationRepository.GetFirst(filter: t => t.MajorId == post.MajorId && t.Language == lang)).Text
                };
            }
            return(result);
        }
Exemplo n.º 3
0
        public async Task <ActionResult <CommonRecruitmentPostDataset> > CreatePost([FromBody] NewRecruitmentPostParam param)
        {
            int userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));

            if (userId != param.CompanyId)
            {
                return(Forbid());
            }
            CommonRecruitmentPostDataset result = await _recruitmentService.InsertRecruitmentPost(param);

            if (result != null)
            {
                await _fcmService.SendMessage(userId, "Creating post succeed", "Recruitment post " + result.Title + " has created.");

                return(Created("", result));
            }
            else
            {
                await _fcmService.SendMessage(userId, "Creating post failed", "Creating recruitment post failed.");
            }
            return(BadRequest());
        }