public async Task <int> Create(DependentDataModel dependent)
        {
            using (IDbConnection db = new SqlConnection(connectionStrings.ConnBenefitsPac))
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@DependentName", dependent.DependentName);
                parameters.Add("@DiscountAmount", dependent.BenefitCost.DiscountAmount);
                parameters.Add("@BaseDeductionCost", dependent.BenefitCost.BaseDeductionCost);
                parameters.Add("@EmployeeId", dependent.EmployeeId);
                parameters.Add("@RESULT", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);

                await db.ExecuteAsync("CreateDependent",
                                      parameters,
                                      commandType : CommandType.StoredProcedure);

                return(parameters.Get <int>("@RESULT"));
            }
        }
        public void Constructor_CanHandleNulls()
        {
            int                discountAmount        = 0;
            decimal            expBaseCost           = 500;
            DependentDataModel expDependentDataModel = new DependentDataModel()
            {
                DependentName = string.Empty
            };

            DependentDataModel sut = new DependentDataModel(null, 0);

            Assert.AreEqual(expDependentDataModel.EmployeeId, sut.EmployeeId);
            Assert.AreEqual(expDependentDataModel.DependentId, sut.DependentId);
            Assert.AreEqual(expDependentDataModel.DependentName, sut.DependentName);
            Assert.IsTrue(sut.BenefitCost.IsDependent);
            Assert.IsFalse(sut.BenefitCost.IsEmployee);
            Assert.AreEqual(discountAmount, sut.BenefitCost.DiscountAmount);
            Assert.AreEqual(expBaseCost, sut.BenefitCost.BaseDeductionCost);
        }
Beispiel #3
0
 public DependentModel(DependentDataModel dependent)
 {
     EmployeeId    = dependent?.EmployeeId ?? 0;
     DependentId   = dependent?.DependentId ?? 0;
     DependentName = dependent?.DependentName ?? string.Empty;
 }