示例#1
0
        public Recent Insert(Recent newObject)
        {
            var databaseObject = newObject.ToDBModel();

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

            return(databaseObject.ToRepositoryModel());
        }
示例#2
0
        public Recent Delete(Recent deleteObject)
        {
            var databaseObject = deleteObject.ToDBModel();
            var original       = DatabaseManager.Instance.Recent.Find(databaseObject.RecentId);

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

            return(databaseObject.ToRepositoryModel());
        }
示例#3
0
文件: Events.cs 项目: kicka5h/Lorry
        public void uxDeleteEditedPoem_Click(object sender, RoutedEventArgs e)
        {
            Lorry.Repository.IDatabaseRepository <Repository.Recents.Recent> getRecent = new Lorry.Repository.Recents.RecentRepository();
            Main.Recent deleteRecent = MainViewModel.Recents.Where(t => t.RecentContent == classContent).SingleOrDefault();

            Repository.Recents.Recent finallyDelete = deleteRecent.ToRepositoryModel();
            getRecent.Delete(finallyDelete);

            this.Close();
        }
示例#4
0
文件: Events.cs 项目: kicka5h/Lorry
        public void uxButtonGenerateCouplet_Click(object sender, RoutedEventArgs e)
        {
            string returnRecent = GenerateRandom.RandomCouplet;

            Lorry.Repository.Recents.Recent newRecent = new Repository.Recents.Recent();
            newRecent.RecentContent = returnRecent;
            newRecent.RecentDate    = DateTime.Now.ToString("MM.dd.yyyy");
            newRecent.RecentType    = "couplet";

            Lorry.Repository.IDatabaseRepository <Repository.Recents.Recent> addRecent = new Lorry.Repository.Recents.RecentRepository();
            addRecent.Insert(newRecent);
        }
示例#5
0
文件: Events.cs 项目: kicka5h/Lorry
        public void uxButtonAddCustomCouplet_Click(object sender, RoutedEventArgs e)
        {
            string inputRead = new Lorry.Helpers.GetInput.InputBox("Add your own").ShowDialog();

            Lorry.Repository.Recents.Recent newRecent = new Repository.Recents.Recent();
            newRecent.RecentContent = inputRead;
            newRecent.RecentDate    = DateTime.Now.ToString("MM.dd.yyyy");
            newRecent.RecentType    = "couplet";

            Lorry.Repository.IDatabaseRepository <Repository.Recents.Recent> addRecent = new Lorry.Repository.Recents.RecentRepository();
            addRecent.Insert(newRecent);
        }
示例#6
0
        public Recent Update(Recent inputObject)
        {
            var updated  = inputObject.ToDBModel();
            var original = DatabaseManager.Instance.Recent.Find(updated.RecentId);

            if (original != null)
            {
                DatabaseManager.Instance.Entry(original).CurrentValues.SetValues(updated);
                DatabaseManager.Instance.SaveChanges();
                return(updated.ToRepositoryModel());
            }
            return(original.ToRepositoryModel());
        }
示例#7
0
文件: Events.cs 项目: kicka5h/Lorry
        public void uxButtonGenerateHaiku_Click(object sender, RoutedEventArgs e)
        {
            string      returnRecent = GenerateRandom.RandomHaiku;
            HaikuWindow haikuWindow  = new HaikuWindow();
            MainWindow  mainWindow   = new MainWindow();

            Lorry.Repository.Recents.Recent newRecent = new Repository.Recents.Recent();
            newRecent.RecentContent = returnRecent;
            newRecent.RecentDate    = DateTime.Now.ToString("MM.dd.yyyy");
            newRecent.RecentType    = "haiku";

            Lorry.Repository.IDatabaseRepository <Repository.Recents.Recent> addRecent = new Lorry.Repository.Recents.RecentRepository();
            addRecent.Insert(newRecent);

            Application.Current.MainWindow         = haikuWindow;
            mainWindow.uxExpanderRecent.IsExpanded = true;
        }
示例#8
0
        public void uxCoupletList_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (MessageBox.Show($"Are you sure you'd like to delete this poem?", "", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                MainWindow mainWindow = new MainWindow();
                Lorry.Repository.IDatabaseRepository <Repository.Recents.Recent> getRecent = new Lorry.Repository.Recents.RecentRepository();

                Main.Recent item    = (Main.Recent)mainWindow.uxCoupletList.Items.CurrentItem;
                string      content = item.RecentContent;

                Main.Recent deleteRecent = MainViewModel.Recents.Where(t => t.RecentContent == content).SingleOrDefault();
                Repository.Recents.Recent finallyDelete = deleteRecent.ToRepositoryModel();

                getRecent.Delete(finallyDelete);

                MessageBox.Show("Okay, poem has been deleted.");
            }
            else
            {
            };
        }