コード例 #1
0
        public ActionResult DeleteConfirmed(int?id)
        {
            PaymentType paymentType = _paymentTypeRepository.Get(id);

            _paymentTypeRepository.Remove(paymentType);
            //db.PaymentType.Find(id);
            //db.PaymentType.Remove(paymentType);
            //db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult DeletePaymentType(int id)
        {
            //PaymentType paymentType = db.PaymentType.Find(id);
            PaymentType paymentType = _paymentTypeRepository.Get(id);

            if (paymentType == null)
            {
                return(NotFound());
            }

            //db.PaymentType.Remove(paymentType);
            //db.SaveChanges();

            _paymentTypeRepository.Remove(paymentType);

            return(Ok(paymentType));
        }
コード例 #3
0
        public void PaymentType_Crud_Test()
        {
            //Arrange
            var paymentType = new PaymentType
            {
                Amount = 100,
                Type   = "One-Time"
            };

            //Act
            var addedItem = _paymentTypeRepository.Save(paymentType);

            //Assert
            Assert.AreEqual(paymentType.Type, addedItem.Type);
            Assert.AreEqual(paymentType.Amount, addedItem.Amount);

            //Act
            var item = _paymentTypeRepository.FindById(addedItem.Id);

            //Assert
            Assert.IsNotNull(item);
            Assert.AreEqual(paymentType.Type, item.Type);
            Assert.AreEqual(addedItem.Id, item.Id);

            //Arrange
            item.Type = "OneTime";

            //Act
            var updatedItem = _paymentTypeRepository.Save(item);

            //Assert
            Assert.AreEqual(item.Id, updatedItem.Id);
            Assert.AreEqual(item.Type, updatedItem.Type);

            //Act
            _paymentTypeRepository.Remove(item.Id);
            var removedItem = _paymentTypeRepository.FindById(item.Id);

            //Assert
            Assert.IsNull(removedItem);
            Assert.AreNotEqual(item.Id, removedItem?.Id);
        }
コード例 #4
0
 public virtual void Remove(Guid id)
 {
     _paymentTypeRepository.Remove(id);
 }