Ejemplo n.º 1
0
        public void Should_create_new_summary_for_user_in_repository()
        {
            // Arrange
            var userId      = 4;
            var summaryData = new CreateSummaryDto(
                "Spec2",
                new List <String> {
                "Skill1", "Skill3"
            },
                "Inform");

            var expected = new SummaryDto(
                userId,
                2,
                summaryData.Specialization,
                summaryData.Skills,
                summaryData.Information);

            // Act
            var result = _summaryService.CreateForUser(userId, summaryData);

            // Assert
            Assert.That(result != null);
            Assert.That(result.Equals(expected));
            Assert.That(result.Equals(SummaryDto.Create(_summaryRepository.GetForUser(userId))));
        }
Ejemplo n.º 2
0
        public SummaryDto CreateForUser(Int32 userId, CreateSummaryDto summaryData)
        {
            User user = _userRepository.Get(userId);

            if (user.Type != UserType.Candidate)
            {
                throw new ArgumentException($"Unable to create summary for not candidate user with id {userId}!");
            }

            if (_summaryRepository.IsHaveForUser(userId))
            {
                throw new ArgumentException($"Summary for user with id {userId} have already created!");
            }

            var summary = new Summary(
                user,
                _specializationRepository.GetByName(summaryData.Specialization),
                summaryData.Skills
                .Select(s => _skillRepository.GetByName(s))
                .ToList(),
                summaryData.Information);

            summary = _summaryRepository.Create(summary);

            return(SummaryDto.Create(summary));
        }
Ejemplo n.º 3
0
        public void Should_throw_argument_exception_when_try_to_create_summary_for_user_who__already_have_summary()
        {
            // Arrange
            var userId      = 1;
            var summaryData = new CreateSummaryDto(
                "Spec2",
                new List <String> {
                "Skill1", "Skill3"
            },
                "Inform");

            // Assert
            Assert.Throws <ArgumentException>(() => _summaryService.CreateForUser(userId, summaryData));
        }
Ejemplo n.º 4
0
 public ActionResult <SummaryDto> Create([FromHeader] Guid token, [FromBody] CreateSummaryDto summaryData)
 {
     try
     {
         Int32 currentUserId = ValidateToken(token);
         return(Ok(_summaryService.CreateForUser(currentUserId, summaryData)));
     }
     catch (AuthenticationException)
     {
         return(Unauthorized());
     }
     catch (ArgumentException e)
     {
         return(BadRequest());
     }
 }
Ejemplo n.º 5
0
 public SummaryDto CreateForMe(Guid token, CreateSummaryDto summary)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public SummaryDto CreateForMe(Guid token, CreateSummaryDto summary)
 {
     return(_summaryClient.Create(token, summary).Result);
 }