Пример #1
0
        public Haiku Insert(Haiku newObject)
        {
            var databaseObject = newObject.ToDbModel();

            DatabaseManager.Instance.Haiku.Add(databaseObject);
            DatabaseManager.Instance.SaveChanges();

            return(databaseObject.ToRepositoryModel());
        }
Пример #2
0
        public Haiku Delete(Haiku deleteObject)
        {
            var databaseObject = deleteObject.ToDbModel();
            var original       = DatabaseManager.Instance.Recent.Find(databaseObject.HaikuId);

            DatabaseManager.Instance.Recent.Remove(original);
            DatabaseManager.Instance.SaveChanges();

            return(databaseObject.ToRepositoryModel());
        }
Пример #3
0
        public Haiku Update(Haiku inputObject)
        {
            var updated  = inputObject.ToDbModel();
            var original = DatabaseManager.Instance.Haiku.Find(updated.HaikuId);

            if (original != null)
            {
                DatabaseManager.Instance.Entry(original).CurrentValues.SetValues(updated);
                DatabaseManager.Instance.SaveChanges();
                return(updated.ToRepositoryModel());
            }

            return(original.ToRepositoryModel());
        }