public void Initialize()
        {
            InitializeMock();

            contactBenefitModelSuccess = new ContactBenefitModel()
            {
                ContactID      = 1,
                ContactPayorID = 1,
                GroupName      = "A-Trinity HCS",
                PayorAddressID = 2,
                PayorGroupID   = 2,
                PayorID        = 117,
                PayorName      = "A-Trinity HCS",
                PayorPlanID    = 2,
                PlanName       = "A-Trinity HCS",
                PolicyID       = "3253"
            };

            contactBenefitModelFailure = new ContactBenefitModel()
            {
                ContactID      = -1,
                ContactPayorID = 1,
                GroupName      = "A-Trinity HCS",
                PayorAddressID = 2,
                PayorGroupID   = 2,
                PayorID        = 117,
                PayorName      = "A-Trinity HCS",
                PayorPlanID    = 2,
                PlanName       = "A-Trinity HCS",
                PolicyID       = "3253"
            };
        }
        public void UpdateContactBenefit_Failure()
        {
            //Arrange
            var url = baseRoute + "UpdateContactBenefit";
            var updateContactBenefit = new ContactBenefitModel
            {
                ContactID      = 1,
                ContactPayorID = 1,
                GroupName      = "A-Trinity HCS1",
                PayorAddressID = 600,
                PayorGroupID   = 0,
                PayorID        = 7896,
                PayorName      = "A-B",
                PayorPlanID    = 0,
                PlanName       = "A-B",
                PolicyID       = "3253",
                EffectiveDate  = System.DateTime.MinValue,
                ForceRollback  = true
            };

            //Act
            var response = communicationManager.Put <ContactBenefitModel, Response <ContactBenefitModel> >(updateContactBenefit, url);

            //Assert
            Assert.IsNotNull(response, "Response can't be null.");
            Assert.IsTrue(response.ResultCode != 0, "Contact benefit got updated for invalid data.");
            Assert.IsNull(response.DataItems, "Contact benefit got updated.");
        }
        public void UpdateContactBenefit_Failure()
        {
            // Arrange
            var updateContactBenefit = new ContactBenefitModel
            {
                ContactID      = -1,
                ContactPayorID = -1,
                GroupName      = "A-Trinity HCS1",
                PayorAddressID = 2,
                PayorGroupID   = 2,
                PayorID        = 117,
                PayorName      = "A-Trinity HCS1",
                PayorPlanID    = 2,
                PlanName       = "A-Trinity HCS1",
                PolicyID       = "3253"
            };

            PrepareResponse(contactBenefitModelSuccess);
            mock.Setup(r => r.UpdateContactBenefit(It.IsAny <ContactBenefitModel>()))
            .Callback((ContactBenefitModel contactBenefitModel) => contactBenefitList.Add(updateContactBenefit))
            .Returns(contactBenefitResponse);

            //Act
            var updateContactBenefitResult = contactBenefitController.UpdateContactBenefit(updateContactBenefit);
            var response = updateContactBenefitResult as HttpResult <Response <ContactBenefitModel> >;

            //Assert
            Assert.IsNotNull(response, "Response can't be null");
            Assert.IsTrue(response.Value.ResultCode == 0, "Contact Benefit updated.");
            Assert.IsTrue(response.Value.RowAffected == 0, "Contact Benefit updated.");
        }
        public void AddContactBenefit_Failure()
        {
            //Arrange
            var url = baseRoute + "AddContactBenefit";
            var addContactBenefit = new ContactBenefitModel
            {
                ContactID      = -1,
                ContactPayorID = -1,
                GroupName      = "A-Trinity HCS1",
                PayorAddressID = 2,
                PayorGroupID   = 2,
                PayorID        = 117,
                PayorName      = "A-Trinity HCS1",
                PayorPlanID    = 2,
                PlanName       = "A-Trinity HCS1",
                PolicyID       = "3253",
                ForceRollback  = true
            };

            //Act
            var response = communicationManager.Post <ContactBenefitModel, Response <ContactBenefitModel> >(addContactBenefit, url);

            //Assert
            Assert.IsNotNull(response, "Response can't be null.");
            Assert.IsTrue(response.ResultCode != 0, "Contact Benefit created with invalid data.");
        }
        public void UpdateContactBenefit_Success()
        {
            //Arrange
            var url = baseRoute + "UpdateContactBenefit";
            var updateContactBenefit = new ContactBenefitModel
            {
                ContactID      = 1,
                ContactPayorID = 1,
                GroupName      = "A-Trinity HCS1",
                PayorAddressID = 2,
                PayorGroupID   = 10,
                PayorID        = 109,
                PayorName      = "A-Trinity HCS1",
                PayorPlanID    = 2,
                PlanName       = "A-Trinity HCS1",
                PolicyID       = "3253",
                ForceRollback  = true
            };

            //Act
            var response = communicationManager.Put <ContactBenefitModel, Response <ContactBenefitModel> >(updateContactBenefit, url);

            //Assert
            Assert.IsNotNull(response, "Response can't be null.");
            Assert.IsTrue(response.ResultCode == 0, "Contact benefit could not be updated.");
        }
예제 #6
0
        /// <summary>
        /// Updates the contact benefit.
        /// </summary>
        /// <param name="contact">The contact.</param>
        /// <returns></returns>
        public Response <ContactBenefitModel> UpdateContactBenefit(ContactBenefitModel contact)
        {
            var contactBenefitParameters = BuildContactBenefitSpParams(contact);
            var contactBenefitRepository = unitOfWork.GetRepository <ContactBenefitModel>(SchemaName.Registration);

            return(contactBenefitRepository.ExecuteNQStoredProc("usp_UpdateContactBenefit", contactBenefitParameters));
        }
예제 #7
0
 /// <summary>
 /// Adds the contact benefit.
 /// </summary>
 /// <param name="contact">The contact.</param>
 /// <returns></returns>
 public Response <ContactBenefitModel> AddContactBenefit(ContactBenefitModel contact)
 {
     //TODO: Remove this hack!!
     if (contact.AddressTypeID == 0)
     {
         contact.AddressTypeID = 1;
     }
     return(contactBenefitService.AddContactBenefit(contact));
 }
        /// <summary>
        /// Prepares the response.
        /// </summary>
        /// <param name="contactBenefitModel">The contact benefit model.</param>
        private void PrepareResponse(ContactBenefitModel contactBenefitModel)
        {
            contactBenefitList = new List <ContactBenefitModel>();
            contactBenefitList.Add(contactBenefitModel);

            contactBenefitResponse = new Response <ContactBenefitModel>()
            {
                DataItems = contactBenefitList
            };
        }
예제 #9
0
        /// <summary>
        /// Builds the contact benefit sp parameters.
        /// </summary>
        /// <param name="contactBenefit">The contact benefit.</param>
        /// <returns></returns>
        private List <SqlParameter> BuildContactBenefitSpParams(ContactBenefitModel contactBenefit)
        {
            var spParameters = new List <SqlParameter>
            {
                new SqlParameter("ContactPayorID", (object)contactBenefit.ContactPayorID ?? DBNull.Value),
                new SqlParameter("ContactID", (object)contactBenefit.ContactID ?? DBNull.Value),
                new SqlParameter("PolicyHolderID", (object)contactBenefit.PolicyHolderID ?? DBNull.Value),
                new SqlParameter("PolicyHolderName", (object)contactBenefit.PolicyHolderName ?? DBNull.Value),

                new SqlParameter("PolicyHolderFirstName", (object)contactBenefit.PolicyHolderFirstName ?? DBNull.Value),
                new SqlParameter("PolicyHolderMiddleName", (object)contactBenefit.PolicyHolderMiddleName ?? DBNull.Value),
                new SqlParameter("PolicyHolderLastName", (object)contactBenefit.PolicyHolderLastName ?? DBNull.Value),
                new SqlParameter("PolicyHolderEmployer", (object)contactBenefit.PolicyHolderEmployer ?? DBNull.Value),
                new SqlParameter("PolicyHolderSuffixID", (object)contactBenefit.PolicyHolderSuffixID ?? DBNull.Value),

                new SqlParameter("BillingFirstName", (object)contactBenefit.BillingFirstName ?? DBNull.Value),
                new SqlParameter("BillingMiddleName", (object)contactBenefit.BillingMiddleName ?? DBNull.Value),
                new SqlParameter("BillingLastName", (object)contactBenefit.BillingLastName ?? DBNull.Value),
                new SqlParameter("BillingSuffixID", (object)contactBenefit.BillingSuffixID ?? DBNull.Value),
                new SqlParameter("AdditionalInformation", (object)contactBenefit.AdditionalInformation ?? DBNull.Value),


                new SqlParameter("PolicyID", (object)contactBenefit.PolicyID ?? DBNull.Value),
                new SqlParameter("Deductible", (object)contactBenefit.Deductible ?? DBNull.Value),
                new SqlParameter("CoPay", (object)contactBenefit.Copay ?? DBNull.Value),
                new SqlParameter("CoInsurance", (object)contactBenefit.CoInsurance ?? DBNull.Value),
                new SqlParameter("EffectiveDate", (object)contactBenefit.EffectiveDate ?? DBNull.Value),
                new SqlParameter("ExpirationDate", (object)contactBenefit.ExpirationDate ?? DBNull.Value),
                new SqlParameter("PayorExpirationReasonID", (object)contactBenefit.PayorExpirationReasonID ?? DBNull.Value),
                new SqlParameter("ExpirationReason", (object)contactBenefit.ExpirationReason ?? DBNull.Value),
                new SqlParameter("AddRetroDate", (object)contactBenefit.AddRetroDate ?? DBNull.Value),
                new SqlParameter("ContactPayorRank", (object)contactBenefit.ContactPayorRank ?? DBNull.Value),

                new SqlParameter("PayorID", (object)contactBenefit.PayorID ?? DBNull.Value),
                new SqlParameter("PlanID", (object)contactBenefit.PlanID ?? DBNull.Value),
                new SqlParameter("GroupID", (object)contactBenefit.GroupID ?? DBNull.Value),

                new SqlParameter("PayorPlanID", (object)contactBenefit.PayorPlanID ?? DBNull.Value),
                new SqlParameter("PayorGroupID", (object)contactBenefit.PayorGroupID ?? DBNull.Value),
                new SqlParameter("PayorAddressID", (object)contactBenefit.PayorAddressID ?? DBNull.Value),
                new SqlParameter("HasPolicyHolderSameCardName", contactBenefit.HasPolicyHolderSameCardName),


                new SqlParameter("ModifiedOn", contactBenefit.ModifiedOn ?? DateTime.Now)
            };

            return(spParameters);
        }
 public IHttpActionResult AddContactBenefit(ContactBenefitModel contact)
 {
     if (ModelState.IsValid)
     {
         return(new HttpResult <Response <ContactBenefitModel> >(contactBenefitRuleEngine.AddContactBenefit(contact), Request));
     }
     else
     {
         var errorMessage       = ModelState.ParseError();
         var validationResponse = new Response <ContactBenefitModel>()
         {
             DataItems = new List <ContactBenefitModel>(), ResultCode = -1, ResultMessage = errorMessage
         };
         return(new HttpResult <Response <ContactBenefitModel> >(validationResponse, Request));
     }
 }
        public void AddContactBenefit_Failure()
        {
            // Arrange
            PrepareResponse(contactBenefitModelSuccess);
            contactBenefitResponse.ResultCode = -1;
            mock.Setup(r => r.AddContactBenefit(It.IsAny <ContactBenefitModel>()))
            .Callback((ContactBenefitModel contactBenefitModel) => contactBenefitList.Add(contactBenefitModel))
            .Returns(contactBenefitResponse);

            //Act
            var addContactBenefit = new ContactBenefitModel
            {
                ContactID      = -1,
                ContactPayorID = -22,
                GroupName      = "A-BS",
                PayorAddressID = 2,
                PayorGroupID   = 4,
                PayorID        = 117,
                PayorName      = "A-BS",
                PayorPlanID    = 4,
                PlanName       = "A-BS",
                PolicyID       = "1111",
                Copay          = 20,
                Deductible     = 90,
                AddressID      = 2,
                AddressTypeID  = 1,
                IsActive       = true,
                ModifiedBy     = 5,
                ModifiedOn     = DateTime.Now,
                ForceRollback  = true
            };

            var addContactBenefitResult = contactBenefitController.AddContactBenefit(addContactBenefit);
            var response = addContactBenefitResult as HttpResult <Response <ContactBenefitModel> >;

            //Assert
            Assert.IsNotNull(response, "Response can't be null");
            Assert.IsTrue(response.Value.ResultCode != 0, "Contact Benefit created.");
            Assert.IsTrue(response.Value.RowAffected == 0, "Contact Benefit created.");
        }
 public IHttpActionResult UpdateContactBenefit(ContactBenefitModel contact)
 {
     return(new HttpResult <Response <ContactBenefitModel> >(contactBenefitDataProvider.UpdateContactBenefit(contact), Request));
 }
예제 #13
0
 /// <summary>
 /// Updates the contact benefit.
 /// </summary>
 /// <param name="contact">The contact.</param>
 /// <returns></returns>
 public Response <ContactBenefitModel> UpdateContactBenefit(ContactBenefitModel contact)
 {
     return(contactBenefitService.UpdateContactBenefit(contact));
 }
예제 #14
0
        /// <summary>
        /// Updates the contact benefit.
        /// </summary>
        /// <param name="contact">The contact.</param>
        /// <returns></returns>
        public Response <ContactBenefitModel> UpdateContactBenefit(ContactBenefitModel contact)
        {
            const string apiUrl = BaseRoute + "UpdateContactBenefit";

            return(communicationManager.Put <ContactBenefitModel, Response <ContactBenefitModel> >(contact, apiUrl));
        }
        /// <summary>
        /// To the view model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static ContactBenefitViewModel ToViewModel(this  ContactBenefitModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new ContactBenefitViewModel
            {
                ContactPayorID          = entity.ContactPayorID,
                ContactID               = entity.ContactID,
                PayorID                 = entity.PayorID,
                PayorPlanID             = entity.PayorPlanID,
                PayorGroupID            = entity.PayorGroupID,
                PolicyHolderID          = entity.PolicyHolderID,
                PolicyHolderName        = entity.PolicyHolderName,
                PayorAddressID          = entity.PayorAddressID,
                PolicyID                = entity.PolicyID,
                Deductible              = entity.Deductible,
                Copay                   = entity.Copay,
                CoInsurance             = entity.CoInsurance,
                EffectiveDate           = entity.EffectiveDate,
                ExpirationDate          = entity.ExpirationDate,
                PayorExpirationReasonID = entity.PayorExpirationReasonID,
                ExpirationReason        = entity.ExpirationReason,
                AddRetroDate            = entity.AddRetroDate,
                ContactPayorRank        = entity.ContactPayorRank,

                AddressID     = entity.AddressID,
                AddressTypeID = entity.AddressTypeID,
                Line1         = entity.Line1,
                Line2         = entity.Line2,
                City          = entity.City,
                StateProvince = entity.StateProvince,
                County        = entity.County,
                Zip           = entity.Zip,

                PlanName = entity.PlanName,
                PlanID   = entity.PlanID,

                GroupName = entity.GroupName,
                GroupID   = entity.GroupID,

                PolicyHolderFirstName  = entity.PolicyHolderFirstName,
                PolicyHolderMiddleName = entity.PolicyHolderMiddleName,
                PolicyHolderLastName   = entity.PolicyHolderLastName,
                PolicyHolderEmployer   = entity.PolicyHolderEmployer,
                PolicyHolderSuffixID   = entity.PolicyHolderSuffixID,
                PayorName                   = entity.PayorName,
                PayorCode                   = entity.PayorCode,
                ModifiedOn                  = entity.ModifiedOn,
                BillingFirstName            = entity.BillingFirstName,
                BillingMiddleName           = entity.BillingMiddleName,
                BillingLastName             = entity.BillingLastName,
                BillingSuffixID             = entity.BillingSuffixID,
                AdditionalInformation       = entity.AdditionalInformation,
                ElectronicPayorID           = entity.ElectronicPayorID,
                HasPolicyHolderSameCardName = entity.HasPolicyHolderSameCardName
            };

            return(model);
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static ContactBenefitModel ToModel(this ContactBenefitViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new ContactBenefitModel
            {
                ContactPayorID          = model.ContactPayorID,
                ContactID               = model.ContactID,
                PayorID                 = model.PayorID,
                PayorPlanID             = model.PayorPlanID,
                PayorGroupID            = model.PayorGroupID,
                PolicyHolderID          = model.PolicyHolderID,
                PolicyHolderName        = model.PolicyHolderName,
                PayorAddressID          = model.PayorAddressID,
                PolicyID                = model.PolicyID,
                Deductible              = model.Deductible,
                Copay                   = model.Copay,
                CoInsurance             = model.CoInsurance,
                EffectiveDate           = model.EffectiveDate,
                ExpirationDate          = model.ExpirationDate,
                PayorExpirationReasonID = model.PayorExpirationReasonID,
                ExpirationReason        = model.ExpirationReason,
                AddRetroDate            = model.AddRetroDate,
                ContactPayorRank        = model.ContactPayorRank,

                AddressID     = model.AddressID,
                AddressTypeID = model.AddressTypeID,
                Line1         = model.Line1,
                Line2         = model.Line2,
                City          = model.City,
                StateProvince = model.StateProvince,
                County        = model.County,
                Zip           = !string.IsNullOrEmpty(model.Zip) ? model.Zip : null,
                PlanName      = model.PlanName,
                PlanID        = model.PlanID,

                GroupName = model.GroupName,
                GroupID   = model.GroupID,

                PolicyHolderFirstName  = model.PolicyHolderFirstName,
                PolicyHolderMiddleName = model.PolicyHolderMiddleName,
                PolicyHolderLastName   = model.PolicyHolderLastName,
                PolicyHolderEmployer   = model.PolicyHolderEmployer,
                PolicyHolderSuffixID   = model.PolicyHolderSuffixID,

                PayorName                   = model.PayorName,
                PayorCode                   = model.PayorCode,
                ForceRollback               = model.ForceRollback,
                ModifiedOn                  = model.ModifiedOn,
                BillingFirstName            = model.BillingFirstName,
                BillingMiddleName           = model.BillingMiddleName,
                BillingLastName             = model.BillingLastName,
                BillingSuffixID             = model.BillingSuffixID,
                AdditionalInformation       = model.AdditionalInformation,
                ElectronicPayorID           = model.ElectronicPayorID,
                HasPolicyHolderSameCardName = model.HasPolicyHolderSameCardName
            };

            return(entity);
        }