Ejemplo n.º 1
0
        string IContactRepository.InsertContact(ContactSystemViewModel input)
        {
            BsonValue bsonValue;

            using (var db = new LiteDatabase(@"ContactSystem.db"))
            {
                var collection = db.GetCollection <ContactSystemViewModel>("ContactEntrySystem");
                bsonValue = collection.Insert(input);
                return(bsonValue.AsString);
                //collection.EnsureIndex(x => x.Id);
            }
        }
Ejemplo n.º 2
0
        bool IContactRepository.UpdateContactById(string id, ContactSystemViewModel input)
        {
            bool isUpdated = false;

            using (var db = new LiteDatabase(@"ContactSystem.db"))
            {
                var collection = db.GetCollection <ContactSystemViewModel>("ContactEntrySystem");
                var result     = collection.Find(x => x.Id == Guid.Parse(id)).FirstOrDefault();
                result    = input;
                isUpdated = collection.Update(input);
            }
            return(isUpdated);
        }