Esempio n. 1
0
        public async void AddAddress()
        {
            using (ILoggerFactory logFact = new LoggerFactory())
            {
                using (var db = createNewDataContextInstance())
                {
                    IContactService crsrv       = new ContactDBService(db, logFact);
                    var             contactList = await crsrv.ListByNameAsync(contactName, true);

                    var ct = contactList.FirstOrDefault();
                    ct.AddAddress("Home", "52D rue des Crets", "74200 Allinges");
                    await crsrv.UpdateAsync(ct);
                }
            }
        }
Esempio n. 2
0
        public async void CreateContactAsync()
        {
            using (ILoggerFactory logFact = new LoggerFactory())
            {
                using (TAPIDataContext db = createNewDataContextInstance())
                {
                    db.Database.EnsureDeleted();
                    db.Database.EnsureCreated();

                    IContactService csrv        = new ContactDBService(db, logFact);
                    var             contactList = await csrv.ListByNameAsync(contactName, true);

                    var ct = contactList.FirstOrDefault();

                    if (ct == null)
                    {
                        ct = new Contact(contactName);
                        await csrv.AddAsync(ct);
                    }
                }
            }
        }