Пример #1
0
        public async Task <Result <int> > Handle(UpdateJobApplicationCommand command, CancellationToken cancellationToken)
        {
            var userName = _authenticatedUser.Username;
            var user     = await _userManager.FindByNameAsync(userName);

            var rolesList = await _userManager.GetRolesAsync(user).ConfigureAwait(false);

            var item = await _repository.GetByIdAsync(command.Id);

            if (item != null && (rolesList.Contains("Admin") || rolesList.Contains("SuperAdmin") || userName == item.UserName))
            {
                item.Name              = command.Name ?? item.Name;
                item.CVFile            = command.CVFile ?? item.CVFile;
                item.CurrentPositionId = command.CurrentPositionId ?? item.CurrentPositionId;
                item.PositionId        = command.PositionId ?? item.PositionId;
                item.DegreeId          = command.DegreeId ?? item.DegreeId;
                item.ExperienceId      = command.ExperienceId ?? item.ExperienceId;
                item.MinExpectedSalary = command.MinExpectedSalary ?? item.MinExpectedSalary;
                item.Adrress           = command.Adrress ?? item.Adrress;
                item.JobTypeId         = command.JobTypeId ?? item.JobTypeId;
                item.IsSearchAllowed   = command.IsSearchAllowed ?? item.IsSearchAllowed;
                await _repository.UpdateAsync(item);

                await _unitOfWork.Commit(cancellationToken);

                return(Result <int> .Success(item.Id));
            }
            return(Result <int> .Fail("Lỗi!!!"));
        }
            public async Task <Result <JobApplicationResponse> > Handle(GetJobApplicationByIdQuery query, CancellationToken cancellationToken)
            {
                var item = await _repository.GetByIdAsync(query.Id);

                var mappedCategory = _mapper.Map <JobApplicationResponse>(item);

                return(Result <JobApplicationResponse> .Success(mappedCategory));
            }
Пример #3
0
            public async Task <Result <int> > Handle(DeleteJobApplicationCommand command, CancellationToken cancellationToken)
            {
                var userName = _authenticatedUser.Username;
                var user     = await _userManager.FindByNameAsync(userName);

                var rolesList = await _userManager.GetRolesAsync(user).ConfigureAwait(false);

                var item = await _repository.GetByIdAsync(command.Id);


                if (item != null && (rolesList.Contains("Admin") || rolesList.Contains("SuperAdmin") || userName == item.UserName))
                {
                    await _repository.DeleteAsync(item);

                    await _unitOfWork.Commit(cancellationToken);

                    return(Result <int> .Success(item.Id));
                }

                return(Result <int> .Fail("Lỗi!!!"));
            }