Exemplo n.º 1
0
        public void Create(CreateFamilyDto inputFamily)
        {
            var family = MapToEntity(inputFamily);

            if (_familyManager.ParentsFamilyExists(family))
            {
                throw new UserFriendlyException(L("FamilyAlreadyExists"));
            }

            GetAndAssignFamilyParents(family);

            _familyRepository.Insert(family);
        }
Exemplo n.º 2
0
        public void Should_Throw_UserFriendlyException_If_Single_Father_Family_Already_Exists()
        {
            var singleManId = GetUnmarriedMan().Id;

            UsingDbContext(Context =>
            {
                Context.Families.Add(new Family {
                    FatherId = singleManId
                });
            });

            var familyInputWithOnlyFather = new CreateFamilyDto {
                FatherId = singleManId
            };

            Should.Throw <UserFriendlyException>(() =>
            {
                _familyAppService.Create(familyInputWithOnlyFather);
            })
            .Message.ShouldBe("This family already exists");
        }
Exemplo n.º 3
0
        public void Should_Throw_UserFriendlyException_If_Family_Already_Exists()
        {
            var singleManId   = GetUnmarriedMan().Id;
            var singleWomenId = GetUnmarriedWomen().Id;

            //Add family too make it exists
            UsingDbContext(Context =>
            {
                Context.Families.Add(new Family {
                    FatherId = singleManId, MotherId = singleWomenId
                });
            });

            var familyInputWithBothParents = new CreateFamilyDto {
                FatherId = singleManId, MotherId = singleWomenId
            };

            Should.Throw <UserFriendlyException>(() =>
            {
                _familyAppService.Create(familyInputWithBothParents);
            })
            .Message.ShouldBe("This family already exists");
        }
Exemplo n.º 4
0
 protected Family MapToEntity(CreateFamilyDto input)
 {
     return(_objectMapper.Map <Family>(input));
 }