public void EditAndSaveEntry()
 {
     if (!string.IsNullOrWhiteSpace(this.tb_Name.Text))
     {
         var entryLogic = new EntryLogic();
         entryLogic.UpdateEntry(this.entry_id.Value, new EntryUpdateParam {
             Name = this.tb_Name.Text, Comment = this.tb_Description.Text
         });
         entryLogic.Dispose();
         this.Close();
     }
 }
        private void btn_DeleteEntry_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var result = MessageBox.Show(ResourceStringManager.GetResourceByKey("ConfirmDeleteMessage"), ResourceStringManager.GetResourceByKey("ConfirmDeleteTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                var entryLogic = new EntryLogic();
                entryLogic.DeleteEntry(SelectedEntry.Id);
                entryLogic.Dispose();
            }
            Load();
            this.RefreshBindings(this.PagingManager.CurrentPage);
        }
        public void GetEntryById_Test()
        {
            // ARRANGE
            CreateEntries();
            var entryLogic = new EntryLogic();

            // ACT
            var entry = entryLogic.GetEntryById(1);

            entryLogic.Dispose();

            // ASSERT
            Assert.IsNotNull(entry);
        }
        public void GetAllEntries_Test()
        {
            // ARRANGE
            CreateEntries();
            var entryLogic = new EntryLogic();

            // ACT
            var entries = entryLogic.GetAllEntries().ToList();

            entryLogic.Dispose();

            // ASSERT
            Assert.IsNotNull(entries);
            Assert.IsTrue(entries.Count() == 3);
        }
        public void DeleteEntry_Test()
        {
            // ARRANGE
            CreateEntries();
            var entryLogic = new EntryLogic();

            // ACT
            entryLogic.DeleteEntry(1);
            entryLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var deletedEntry = this.uow.Entries.Get(1);

            Assert.IsNull(deletedEntry);
        }
        private void LoadEntriesWhereFiltersHit()
        {
            var entryLogic = new EntryLogic();

            this.EntryViewModels = entryLogic.GetAllEntries()
                                   .OrderByDescending(e => e.Created)
                                   .Select(e => new EntryViewModel(e))
                                   .ToList();
            entryLogic.Dispose();

            Func <EntryViewModel, bool> projectCondition    = e => e != null;
            Func <EntryViewModel, bool> assignmentCondition = e => e != null;
            Func <EntryViewModel, bool> subtaskCondition    = e => e != null;

            if (this.SelectedProject != null)
            {
                if (this.SelectedProject.Id != 0)
                {
                    projectCondition = e => e.ProjectId == this.SelectedProject.Id;
                }
            }

            if (this.SelectedAssignment != null)
            {
                if (this.SelectedAssignment.Id != 0)
                {
                    assignmentCondition = e => e.Subtask.Assignment_Id == this.SelectedAssignment.Id;
                }
            }

            if (this.SelectedSubtask != null)
            {
                if (this.SelectedSubtask.Id != 0)
                {
                    subtaskCondition = e => e.Subtask.Id == this.SelectedSubtask.Id;
                }
            }

            this.FilteredViewModels = this.EntryViewModels;
            this.FilteredViewModels = this.EntryViewModels.Where(projectCondition).ToList();
            this.FilteredViewModels = this.FilteredViewModels.Where(assignmentCondition).ToList();
            this.FilteredViewModels = this.FilteredViewModels.Where(subtaskCondition).ToList();
        }
        public void UpdateEntry_Test()
        {
            // ARRANGE
            CreateEntries();
            var entryLogic  = new EntryLogic();
            var updateParam = new EntryUpdateParam
            {
                Comment = "Test comment updated",
                Name    = "Test name updated"
            };

            // ACT
            entryLogic.UpdateEntry(1, updateParam);
            entryLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var updatedEntry = this.uow.Entries.Get(1);

            Assert.IsNotNull(updatedEntry);
            Assert.AreEqual("Test comment updated", updatedEntry.Comment);
            Assert.AreEqual("Test name updated", updatedEntry.Name);
        }