Exemplo n.º 1
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());
        }
Exemplo n.º 2
0
        public async Task <CommonRecruitmentPostDataset> InsertRecruitmentPost(NewRecruitmentPostParam param)
        {
            RecruitmentPost post = new RecruitmentPost()
            {
                Title          = param.Title,
                CompanyId      = param.CompanyId,
                DueDate        = param.DueDate,
                ExpectedNumber = param.ExpectedNumber,
                JobBenefit     = param.JobBenefit,
                JobDescription = param.JobDescription,
                JobRequirement = param.JobRequirement,
                Location       = param.Location,
                MajorId        = param.MajorId,
                MinSalary      = param.MinSalary,
                MaxSalary      = param.MaxSalary
            };

            _uow.RecruitmentRepository.Insert(post);
            if (await _uow.CommitAsync() > 0)
            {
                return(await this.GetRecruitmentPostById(post.PostId));
            }
            return(null);
        }