public void TestAddFamily()
        {
            OrphanageDataModel.RegularData.Name nameF = TestDataStore.GetName(), nameM = TestDataStore.GetName();
            nameM.Last = "asdasd";

            OrphanageDataModel.RegularData.Address addressM = TestDataStore.GetAddress(), addressFam = TestDataStore.GetAddress();
            OrphanageDataModel.RegularData.Family  fam = new OrphanageDataModel.RegularData.Family()
            {
                Father = new OrphanageDataModel.Persons.Father()
                {
                    Birthday           = new DateTime(1980, 1, 1),
                    DateOfDeath        = DateTime.Now,
                    Name               = nameF,
                    RegDate            = DateTime.Now,
                    UserId             = 1,
                    IdentityCardNumber = "04554681365"
                },
                Mother = new OrphanageDataModel.Persons.Mother()
                {
                    Name               = nameM,
                    Address            = addressM,
                    Birthday           = new DateTime(1980, 1, 1),
                    HasSheOrphans      = true,
                    IdentityCardNumber = "65298748546",
                    IsDead             = false,
                    IsMarried          = false,
                    RegDate            = DateTime.Now,
                    UserId             = 1
                },
                PrimaryAddress  = addressFam,
                UserId          = 1,
                RegDate         = DateTime.Now,
                FinncialStatus  = "TestFinnacialStatus",
                IsBailed        = false,
                IsExcluded      = false,
                IsTheyRefugees  = false,
                ResidenceStatus = "TestResidenceStatus",
                ResidenceType   = "TestResidenceType"
            };
            try
            {
                var famId = _familyDbService.AddFamily(fam).Result;
                famId.Id.ShouldBeGreaterThan(0);
                _familyDbService.DeleteFamily(fam.Id).Result.ShouldBe(true);
            }
            catch (DbEntityValidationException exc)
            {
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        public async Task <HttpResponseMessage> Post(OrphanageDataModel.RegularData.Family family)
        {
            OrphanageDataModel.RegularData.Family ret = null;

            ret = await _FamilyDBService.AddFamily(family);

            if (ret != null)
            {
                return(Request.CreateResponse(System.Net.HttpStatusCode.Created, ret));
            }
            else
            {
                return(_httpMessageConfiguerer.NothingChanged());
            }
        }