Ejemplo n.º 1
0
        public IActionResult DeleteNote(Note note)
        {
            noteContext.Delete(note.Id);
            noteContext.Commit();

            return(RedirectToAction("Notes"));
        }
        public void Should_delete_data_when_call_Delete()
        {
            var resultBeforeDelete = _sqlDataProvider.Get(new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"));

            _sqlDataProvider.Delete(new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"));

            var resultAfterDelete = _sqlDataProvider.Get(new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"));

            Assert.NotNull(resultBeforeDelete);
            Assert.Null(resultAfterDelete);
        }
Ejemplo n.º 3
0
        public void Should_delete_data_when_call_Delete()
        {
            var validId = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3");

            _sqlHelperMock.Setup(s => s.ExcuteNonQuery(It.IsAny <string>(), It.IsAny <IDictionary <string, object> >()));

            _sqlDataProvider.Delete(validId);

            _sqlHelperMock.Verify(s => s.ExcuteNonQuery(
                                      It.Is <string>(txt => txt == _deleteSqlCommand),
                                      It.Is <IDictionary <string, object> >(ps => ps.Count == 1 && (Guid)ps["@Id"] == validId)),
                                  Times.Once());
        }
Ejemplo n.º 4
0
        public ActionResult ConfirmDelete(string Id)
        {
            Product productToDelete = context.Find(Id);

            if (productToDelete == null)
            {
                return(HttpNotFound());
            }
            else
            {
                context.Delete(Id);
                context.Commit();
                return(RedirectToAction("Index"));
            }
        }