public void MaintTaskEnsurePropertiesWork()
        {
            //Begin Arrange
            MaintTask m_task = new MaintTask
            {
                Title = "Change Air Filters",
                CreatedAt = DateTime.Now,
                CompleteBy = DateTime.Now + new TimeSpan(10, 10, 10, 10),
                Completed = false,
                Frequency = "Every Year",
                Notes = "Buy big filters",
                RemindMeOn = DateTime.Parse("2015-12-30"),
                RemindMeBy = "Phone",
            };
            //End Arrange

            //Begin Act
            //End Act

            //Begin Assert
            Assert.AreEqual("Change Air Filters", m_task.Title);
            Assert.AreEqual(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_task.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss"));
            Assert.AreEqual((DateTime.Now + new TimeSpan(10, 10, 10, 10)).ToString("yyyy-MM-dd HH:mm:ss"), m_task.CompleteBy.ToString("yyyy-MM-dd HH:mm:ss"));
            Assert.AreEqual(false, m_task.Completed);
            Assert.AreEqual("Every Year", m_task.Frequency);
            Assert.AreEqual("Buy big filters", m_task.Notes);
            Assert.AreEqual(DateTime.Parse("2015-12-30"), m_task.RemindMeOn);
            Assert.AreEqual("Phone", m_task.RemindMeBy);
            //End Assert
        }
        public MaintTask CreateMaintTask(string title, ApplicationUser owner)
        {
            MaintTask my_maintTask = new MaintTask { Title = title, Owner = owner };
            context.MaintTasks.Add(my_maintTask);
            context.SaveChanges(); // This saves something to the Database

            return my_maintTask;
        }
        public void MaintTaskRepositoryEnsureICanAddAMaintTask()
        {
            MaintTaskRepository maintTask_repo = new MaintTaskRepository(mock_context.Object);
            MaintTask list = new MaintTask { Title = "Change Air Filters", MaintTaskId = 1, Frequency = "Every Year" };
            my_maintTasks.Add(new MaintTask { Title = "My First Task", Owner = user1 });

            ConnectMocksToDataSource();

            bool actual = maintTask_repo.AddMaintTask(list);

            Assert.AreEqual(1, maintTask_repo.GetAllMaintTasks().Count);
            Assert.IsTrue(actual);
        }
 public bool AddMaintTask(MaintTask _task)
 {
     bool result = true;
     try
     {
         context.MaintTasks.Add(_task);
         context.SaveChanges();
     }
     catch (InvalidOperationException)
     {
         result = false;
     }
     catch (ArgumentNullException)
     {
         result = false;
     }
     return result;
 }
 public MaintTask UpdateMaintTask(MaintTask updatedMaintTask)
 {
     var query = (from mt in context.MaintTasks
                  where mt.MaintTaskId == updatedMaintTask.MaintTaskId
                  select mt);
     var mTaskToUpdate = query.First();
     mTaskToUpdate.Title = updatedMaintTask.Title;
     mTaskToUpdate.Notes = updatedMaintTask.Notes;
     mTaskToUpdate.Frequency = updatedMaintTask.Frequency;
     mTaskToUpdate.RemindMeBy = updatedMaintTask.RemindMeBy;
     mTaskToUpdate.RemindMeOn = updatedMaintTask.RemindMeOn;
     context.SaveChanges();
     return mTaskToUpdate;
 }
        public ActionResult Edit(MaintTask input)
        {
            if (TryValidateModel(input))
            {
                input.CreatedAt = DateTime.Now;
                input.RemindMeBy = "Phone";
                db.Entry(input).State = EntityState.Modified;
                db.SaveChanges();
                //return PartialView("dataRowView", (MaintTask)input);
                return RedirectToAction("Index");
            }

            Response.StatusCode = 400;
            return PartialView("ModalPartial", (MaintTask)input);
            /*
            public int MaintTaskId { get; set; }
            public string Title { get; set; }
            public DateTime CreatedAt { get; set; }
            public DateTime CompleteBy { get; set; }
            public bool Completed { get; set; }
            public string Frequency { get; set; }
            public string Notes { get; set; }
            public DateTime RemindMeOn { get; set; }
            public string RemindMeBy { get; set; }
            public string Category { get; set; }
            public ApplicationUser Owner { get; set; }
            */
        }
 public void MaintTaskEnsureICanCreateAnInstance()
 {
     MaintTask m_task = new MaintTask();
     Assert.IsNotNull(m_task);
 }
        public void MaintTaskRepositoryEnsureICanDeleteAMaintTask()
        {
            // Arrange
            MaintTaskRepository maintTask_repo = new MaintTaskRepository(mock_context.Object);
            MaintTask m_task1 = new MaintTask()
            {
                MaintTaskId = 1,
                Title = "my maint task",
                Frequency = "Every Year"
            };
            MaintTask m_task2 = new MaintTask()
            {
                MaintTaskId = 2,
                Title = "my maint task 2",
                Frequency = "Every Year"
            };

            my_maintTasks.Add(m_task1);
            my_maintTasks.Add(m_task2);

            ConnectMocksToDataSource();

            // Act
            bool success = maintTask_repo.DeleteMaintTask(m_task1.MaintTaskId);
            MaintTask m_task_found1 = maintTask_repo.GetMaintTaskById(m_task1.MaintTaskId);
            MaintTask m_task_found2 = maintTask_repo.GetMaintTaskById(m_task2.MaintTaskId);

            // Assert
            Assert.IsTrue(success);
            //Assert.IsNull(m_task_found1);
            //Assert.AreEqual(1, maintTask_repo.GetAllMaintTasks().Count);
            Assert.AreEqual(1, maintTask_repo.MaintTasks.Count());
            Assert.AreEqual("my maint task 2", m_task_found2.Title);
        }
 public void MaintTaskRepositoryEnsureICanCreateAMaintTask()
 {
     MaintTask maintTask = new MaintTask();
     Assert.IsNotNull(maintTask);
 }
        public void MaintTaskRepositoryEnsurePropertiesWork()
        {
            //Begin Arrange
            MaintTask maintTaskContent = new MaintTask { MaintTaskId = 1, Title = "Change Air Filters", Frequency = "Every Year" };

            //End Arrange

            //Begin Act
            //End Act

            //Begin Assert
            Assert.AreEqual(1, maintTaskContent.MaintTaskId);
            Assert.AreEqual("Change Air Filters", maintTaskContent.Title);
            Assert.AreEqual("Every Year", maintTaskContent.Frequency);
            //End Assert
        }
        public void MaintTaskRepositoryEnsureICanEditAMaintTask()
        {
            // Arrange
            MaintTaskRepository maintTask_repo = new MaintTaskRepository(mock_context.Object);
            MaintTask m_task1 = new MaintTask { MaintTaskId = 1, Title = "My Maint Task" };
            MaintTask m_task2 = new MaintTask { MaintTaskId = 2, Title = "My Maint Task 2" };

            my_maintTasks.Add(m_task1);
            my_maintTasks.Add(m_task2);

            ConnectMocksToDataSource();

            // Act
            var newTitle1 = "My Maint Task NEW 1";
            var newTitle2 = "My Maint Task NEW 2";
            m_task1.Title = newTitle1;
            m_task2.Title = newTitle2;
            var mt_success1 = maintTask_repo.UpdateMaintTask(m_task1);
            var mt_success2 = maintTask_repo.UpdateMaintTask(m_task2);
            var actual1 = maintTask_repo.GetMaintTaskById(m_task1.MaintTaskId);
            var actual2 = maintTask_repo.GetMaintTaskById(m_task2.MaintTaskId);

            // Assert
            Assert.AreEqual(newTitle1, actual1.Title);
            Assert.AreEqual(newTitle2, actual2.Title);
        }