public void Post_InvalidObjectPassed()
        {
            try
            {
                // Arrange
                var BillingDetailItem = new BillingDetailModel()
                {
                    BillingCycleId = 1,
                    Id             = 1,
                    CreatedDate    = DateTime.Now,
                    UserId         = 1
                };
                _controller.ModelState.AddModelError("amount", "Required");

                // Act
                _controller.Post(BillingDetailItem);

                // Assert
                Assert.True(true);
            }
            catch (Exception)
            {
                // Assert
                Assert.True(true);
            }
        }
        public void Put_ValidObjectPassed()
        {
            try
            {
                // Arrange
                var BillingDetailItem = new BillingDetailModel()
                {
                    BillingCycleId = 1,
                    Id             = 1,
                    CreatedDate    = DateTime.Now,
                    UserId         = 1,
                    Amount         = 50
                };

                // Act
                _controller.Put(BillingDetailItem);

                // Assert
                Assert.True(true);
            }
            catch (Exception)
            {
                // Assert
                Assert.True(true);
            }
        }
 /// <summary>
 /// Saves the billing details
 /// </summary>
 /// <param name="billingDetails">billing class object model</param>
 public void Post(BillingDetailModel billingDetails)
 {
     // check if the amount is not given in the model.
     if (billingDetails.Amount == 0)
     {
         throw new Exception("Invalid Model state.");
     }
     _billingDetails.Add(billingDetails);
 }
 /// <summary>
 /// Saves the billing details
 /// </summary>
 /// <param name="billingDetails">billing class object model</param>
 public void Post(BillingDetailModel billingDetails)
 {
     iBillingRepository.Save(new DataServices.Table.BillingDetails {
         Amount         = billingDetails.Amount,
         BillingCycleId = billingDetails.BillingCycleId,
         CreatedDate    = billingDetails.CreatedDate,
         UserId         = billingDetails.UserId,
     });
 }
        /// <summary>
        /// Update the billing details
        /// </summary>
        /// <param name="billingDetails">billing class object model</param>
        public void Put(BillingDetailModel billingDetails)
        {
            //check of the given id of billing is not present in the mock data
            var existing = _billingDetails.Where(a => a.Id == billingDetails.Id).FirstOrDefault();

            if (existing == null)
            {
                throw new Exception("Invalid Model state.");
            }
            existing.Amount = billingDetails.Amount;
        }
Esempio n. 6
0
 public void Put(BillingDetailModel billingDetailModel)
 {
     IBillingDetails.Put(billingDetailModel);
 }