コード例 #1
0
        public DBBobestyrer MapModelBebostyreTilDBBebostyre(Models.DomainModels.Bobestyrer bobestyrer)
        {
            DBBobestyrer dBBobestyrer = new DBBobestyrer()
            {
                Navn    = bobestyrer.Navn,
                Adresse = bobestyrer.Adresse,
                By      = bobestyrer.By,
                Kommentarer_til_bobestyrer = bobestyrer.Kommentarer_til_bobestyrer,
                Postnummer = bobestyrer.Postnummer
            };

            return(dBBobestyrer);
        }
コード例 #2
0
        public void saveYderligereInfo_step3(bool Vil_i_indsaette_en_bobestyrer, DBBobestyrer bobestyrer, string sessionid)
        {
            using (dinearvningerEntities dbContext = new dinearvningerEntities())
            {
                var result = dbContext.Testamenta_form.SingleOrDefault(x => x.Session_Id == sessionid);

                if (result != null)
                {
                    var testamentFormId = result.Id;

                    var bobestyrerResult = dbContext.Bobestyrer.SingleOrDefault(x => x.TestamentId == testamentFormId);

                    if (bobestyrerResult == null)
                    {
                        Bobestyrer bobestyrerObj = new Bobestyrer
                        {
                            TestamentId = testamentFormId,
                            Navn        = bobestyrer.Navn,
                            Adresse     = bobestyrer.Adresse,
                            Bynavn      = bobestyrer.By,
                            Postnummer  = bobestyrer.Postnummer,
                            Kommentarer_til_bobestyrer = bobestyrer.Kommentarer_til_bobestyrer
                        };

                        dbContext.Bobestyrer.Add(bobestyrerObj);
                        dbContext.SaveChanges();
                        result.bobestyrerId = bobestyrerObj.Id;
                    }
                    else
                    {
                        bobestyrerResult.TestamentId = testamentFormId;
                        bobestyrerResult.Navn        = bobestyrer.Navn;
                        bobestyrerResult.Adresse     = bobestyrer.Adresse;
                        bobestyrerResult.Bynavn      = bobestyrer.By;
                        bobestyrerResult.Postnummer  = bobestyrer.Postnummer;
                        bobestyrerResult.Kommentarer_til_bobestyrer = bobestyrer.Kommentarer_til_bobestyrer;
                    }

                    result.Vil_i_indsaette_en_bobestyrer = Vil_i_indsaette_en_bobestyrer;
                }

                dbContext.SaveChanges();
            }
            //throw new NotImplementedException();
        }