Ejemplo n.º 1
0
        public async Task <uint> AddBasicInfoAsync(uint authorId, string title, string description, string authors,
                                                   string specialization)
        {
            var user = await _userManager.FindByIdAsync(authorId.ToString());

            if (user.NormalizedUserName.Split(":")[0] != "PARTICIPANT")
            {
                throw new AuthenticationException();
            }

            var scientificWork = await _scientificWorkRepository.GetByAuthorIdAsync(authorId);

            if (!(scientificWork is null))
            {
                throw new InvalidOperationException();
            }

            scientificWork = new ScientificWork()
            {
                Name           = title,
                Description    = description,
                MainAuthor     = user,
                OtherAuthors   = authors,
                CreationDate   = DateTime.Now,
                Status         = StatusEnum.WaitingForDrawOfReviewers,
                Specialization = specialization
            };

            await _scientificWorkRepository.AddAsync(scientificWork);

            return(await _scientificWorkRepository.GetIdOfWorkByAuthorIdAsync(authorId));
        }
Ejemplo n.º 2
0
        public async Task <HeaderUserInfoDto> GetUserInfoForHeaderAsync(string userId)
        {
            var user = await _userManager.FindByIdAsync(userId);

            var scientificWork = await _scientificWorkRepository.GetByAuthorIdAsync(user.Id);

            var dto = _mapper.Map <HeaderUserInfoDto>(user);

            dto.PhotoBase64      = UserHelper.GetBase64Photo(_fileManager, user.Photo);
            dto.ScientificWorkId = scientificWork?.Id ?? 0;

            return(dto);
        }
Ejemplo n.º 3
0
        public async Task <HeaderUserInfoDto> GetUserInfoForHeaderAsync(string userId)
        {
            var user = await _userManager.FindByIdAsync(userId);

            var scientificWork = await _scientificWorkRepository.GetByAuthorIdAsync(user.Id);

            string base64Photo = null;

            if (!(user.Photo is null))
            {
                var photo = await _fileManager.GetBase64FileAsync(user.Photo);

                var photoExtension = user.Photo.Split(".")[^ 1];