public void UpdateCollateral_Failure()
        {
            // Arrange
            PrepareResponse(colleteralDataForFailure);

            mock.Setup(r => r.UpdateCollateral(It.IsAny <CollateralModel>()))
            .Callback((CollateralModel collateralModel) => collaterals.Add(collateralModel))
            .Returns(collateralResponse);

            //Act
            var updateCollateralFailure = new CollateralModel
            {
                ParentContactID         = 0,
                ContactID               = -1,
                ContactTypeID           = 4,
                FirstName               = "firstName1",
                LastName                = "lastName1",
                LivingWithClientStatus  = false,
                ReceiveCorrespondenceID = 2,
                ContactRelationshipID   = 2,
                RelationshipTypeID      = 3,
                IsActive                = true,
                ModifiedBy              = 5,
                ModifiedOn              = DateTime.Now,
                ForceRollback           = true
            };
            var updateCollateralResult = collateralController.UpdateCollateral(updateCollateralFailure);
            var response = updateCollateralResult as HttpResult <Response <CollateralModel> >;

            //Assert
            Assert.IsNotNull(response, "Response can't be null");
            Assert.IsTrue(response.Value.ResultCode != 0, "Collateral updated.");
            Assert.IsTrue(response.Value.RowAffected == 0, "Collateral updated.");
        }
Beispiel #2
0
        public void UpdateCollateral_Failure()
        {
            //Act
            Mock_Collateral_Failure();
            var updateCollateralFailure = new CollateralModel
            {
                ParentContactID         = 0,
                ContactID               = -1,
                ContactTypeID           = 4,
                FirstName               = "firstName1",
                LastName                = "lastName1",
                LivingWithClientStatus  = false,
                ReceiveCorrespondenceID = 2,
                ContactRelationshipID   = 2,
                RelationshipTypeID      = 3,
                IsActive                = true,
                ModifiedBy              = 5,
                ModifiedOn              = DateTime.Now,
                ForceRollback           = true
            };
            var updateCollateralResult = collateralController.Updatecollateral(updateCollateralFailure);
            var response   = updateCollateralResult as HttpResult <Response <CollateralModel> >;
            var collateral = response.Value;

            //Assert
            Assert.IsTrue(collateral.ResultCode != 0, "Collateral updated.");
        }
Beispiel #3
0
        public void UpdateCollateral_Failure()
        {
            //Arrange
            var url = baseRoute + "updateCollateral";

            //Update Additional Demographic
            var updateCollateralFailure = new CollateralModel
            {
                ParentContactID         = 0,
                ContactID               = -1,
                ContactTypeID           = 4,
                FirstName               = "firstName1",
                LastName                = "lastName1",
                LivingWithClientStatus  = false,
                ReceiveCorrespondenceID = 2,
                ContactRelationshipID   = 2,
                RelationshipTypeID      = 3,
                IsActive                = true,
                ModifiedBy              = 5,
                ModifiedOn              = DateTime.Now,
                ForceRollback           = true
            };

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

            //Assert
            Assert.IsTrue(response.ResultCode != 0, "Collateral updated.");
        }
        public void UpdateCollateral_Success()
        {
            //Arrange
            var url = baseRoute + "updateCollateral";

            //Update Additional Demographic
            var updateCollateral = new CollateralModel
            {
                ContactID               = 11,
                ContactTypeID           = 4,
                FirstName               = "firstName1",
                LastName                = "lastName1",
                LivingWithClientStatus  = false,
                ReceiveCorrespondenceID = 2,
                ContactRelationshipID   = 2,
                RelationshipTypeID      = 3,
                IsActive                = true,
                ModifiedBy              = 5,
                ModifiedOn              = DateTime.Now,
                ForceRollback           = true
            };

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

            //Assert
            Assert.IsNotNull(response, "Response can't be null.");
            Assert.IsTrue(response.ResultCode == 0, "Collateral could not be updated.");
            Assert.IsTrue(response.RowAffected > 0, "Collateral could not be updated.");
        }
        public void AddCollateral_Failure()
        {
            // Arrange
            PrepareResponse(colleteralDataForFailure);

            mock.Setup(r => r.AddCollateral(It.IsAny <CollateralModel>()))
            .Callback((CollateralModel collateralModel) => collaterals.Add(collateralModel))
            .Returns(collateralResponse);

            //Act
            var contactAddressModel = new List <ContactAddressModel>();

            contactAddressModel.Add(new ContactAddressModel {
                AddressID = 1, AddressTypeID = 2, Line1 = "Address Line1", Line2 = "AddressLine2", City = "Colorado", County = 1, StateProvince = 2, Zip = "zipCode"
            });

            var contactPhoneModel = new List <ContactPhoneModel>();

            contactPhoneModel.Add(new ContactPhoneModel {
                ContactPhoneID = 1, PhoneID = 1, PhoneTypeID = 2, PhonePermissionID = 3, Number = "9876458125"
            });

            var contactEmailModel = new List <ContactEmailModel>();

            contactEmailModel.Add(new ContactEmailModel {
                Email = "*****@*****.**"
            });

            var addCollateralFailure = new CollateralModel
            {
                ContactID               = -1,
                ContactTypeID           = -1,
                FirstName               = null,
                LastName                = null,
                DriverLicense           = "driverLicense",
                DriverLicenseStateID    = 8,
                ContactRelationshipID   = 2,
                LivingWithClientStatus  = false,
                ReceiveCorrespondenceID = 2,
                GenderID                = 1,
                DOB                = DateTime.Now,
                SuffixID           = 2,
                RelationshipTypeID = 2,
                Addresses          = contactAddressModel,
                Phones             = contactPhoneModel,
                IsActive           = true,
                ModifiedBy         = 5,
                ModifiedOn         = DateTime.Now,
                ForceRollback      = true
            };

            var addCollateralResult = collateralController.AddCollateral(addCollateralFailure);
            var response            = addCollateralResult as HttpResult <Response <CollateralModel> >;

            //Assert
            Assert.IsNotNull(response, "Response can't be null");
            Assert.IsTrue(response.Value.ResultCode != 0, "Collateral created.");
            Assert.IsTrue(response.Value.RowAffected == 0, "Collateral created.");
        }
Beispiel #6
0
        public void AddCollateral_Failure()
        {
            //Arrange
            var url = baseRoute + "addCollateral";

            //Add Emergency Contact
            var contactAddressModel = new List <ContactAddressModel>();

            contactAddressModel.Add(new ContactAddressModel {
                AddressID = 1, AddressTypeID = 2, Line1 = "Address Line1", Line2 = "AddressLine2", City = "Colorado", County = 1, StateProvince = 2, Zip = "zipCode"
            });

            var contactPhoneModel = new List <ContactPhoneModel>();

            contactPhoneModel.Add(new ContactPhoneModel {
                ContactPhoneID = 1, PhoneID = 1, PhoneTypeID = 2, PhonePermissionID = 3, Number = "9876458125"
            });

            var contactEmailModel = new List <ContactEmailModel>();

            contactEmailModel.Add(new ContactEmailModel {
                Email = "*****@*****.**"
            });

            var addCollateralFailure = new CollateralModel
            {
                ParentContactID         = -1,
                ContactID               = -1,
                ContactTypeID           = -1,
                DriverLicense           = "driverLicense",
                DriverLicenseStateID    = 10,
                ContactRelationshipID   = 1,
                LivingWithClientStatus  = true,
                ReceiveCorrespondenceID = 1,
                FirstName               = "firstName11",
                LastName           = "lastName11",
                GenderID           = 1,
                DOB                = DateTime.Now,
                SuffixID           = 2,
                RelationshipTypeID = 2,
                Addresses          = contactAddressModel,
                Phones             = contactPhoneModel,
                Emails             = contactEmailModel,
                IsActive           = true,
                ModifiedBy         = 5,
                ModifiedOn         = DateTime.Now,
                ForceRollback      = true
            };

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

            //Assert
            Assert.IsTrue(response.ResultCode != 0);
            Assert.IsTrue(response.RowAffected == 0, "Collateral created.");
        }
        /// <summary>
        /// Prepares the response.
        /// </summary>
        /// <param name="collateralData">The collateral data.</param>
        private void PrepareResponse(CollateralModel collateralData)
        {
            collaterals = new List <CollateralModel>();
            collaterals.Add(collateralData);

            collateralResponse = new Response <CollateralModel>()
            {
                DataItems = collaterals
            };
        }
Beispiel #8
0
        public void AddCollateral_Success()
        {
            //Act
            Mock_Collateral_Success();

            var contactAddressModel = new List <ContactAddressModel>();

            contactAddressModel.Add(new ContactAddressModel {
                AddressID = 1, AddressTypeID = 2, Line1 = "Address Line1", Line2 = "AddressLine2", City = "Colorado", County = 1, StateProvince = 2, Zip = "zipCode"
            });

            var contactPhoneModel = new List <ContactPhoneModel>();

            contactPhoneModel.Add(new ContactPhoneModel {
                ContactPhoneID = 1, PhoneID = 1, PhoneTypeID = 2, PhonePermissionID = 3, Number = "9876458125"
            });

            var contactEmailModel = new List <ContactEmailModel>();

            contactEmailModel.Add(new ContactEmailModel {
                Email = "*****@*****.**"
            });

            var addCollateral = new CollateralModel
            {
                ParentContactID         = 2,
                ContactID               = 0,
                ContactTypeID           = 4,
                DriverLicense           = "driverLicense",
                DriverLicenseStateID    = 8,
                ContactRelationshipID   = 2,
                LivingWithClientStatus  = false,
                ReceiveCorrespondenceID = 2,
                FirstName               = "firstName11",
                LastName           = "lastName11",
                GenderID           = 1,
                DOB                = DateTime.Now,
                SuffixID           = 2,
                RelationshipTypeID = 2,
                Addresses          = contactAddressModel,
                Phones             = contactPhoneModel,
                IsActive           = true,
                ModifiedBy         = 5,
                ModifiedOn         = DateTime.Now,
                ForceRollback      = true
            };

            var addCollateralResult = collateralController.Addcollateral(addCollateral);
            var response            = addCollateralResult as HttpResult <Response <CollateralModel> >;
            var collateral          = response.Value;

            //Assert
            Assert.IsNotNull(collateral);
            Assert.IsTrue(collateral.ResultCode == 0, "Collateral could not be created.");
        }
        /// <summary>
        /// Converting CollateralViewModel to CollateralModel
        /// </summary>
        /// <param name="model">model</param>
        /// <returns></returns>
        public static CollateralModel ToModel(this CollateralViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new CollateralModel
            {
                ParentContactID          = model.ParentContactID,
                ContactID                = model.ContactID,
                FirstName                = model.FirstName,
                LastName                 = model.LastName,
                Middle                   = model.Middle,
                SuffixID                 = model.SuffixID,
                DOB                      = model.DOB,
                GenderID                 = model.GenderID,
                Addresses                = model.Addresses,
                Emails                   = model.Emails,
                Phones                   = model.Phones,
                ClientAlternateIDs       = model.ClientAlternateIDs,
                RelationshipTypeID       = model.RelationshipTypeID,
                ContactTypeID            = model.ContactTypeID,
                ContactRelationshipID    = model.ContactRelationshipID,
                LivingWithClientStatus   = model.LivingWithClientStatus,
                ReceiveCorrespondenceID  = model.ReceiveCorrespondenceID,
                SSN                      = model.SSN,
                DriverLicense            = model.DriverLicense,
                DriverLicenseStateID     = model.DriverLicenseStateID,
                IsActive                 = model.IsActive,
                ModifiedBy               = model.ModifiedBy,
                ModifiedOn               = model.ModifiedOn,
                ForceRollback            = model.ForceRollback,
                EmergencyContact         = model.EmergencyContact,
                CopyContactAddress       = model.CopyContactAddress,
                EmploymentStatusID       = model.EmploymentStatusID,
                EducationStatusID        = model.EducationStatusID,
                SchoolAttended           = model.SchoolAttended,
                SchoolBeginDate          = model.SchoolBeginDate,
                SchoolEndDate            = model.SchoolEndDate,
                VeteranStatusID          = model.VeteranStatusID,
                RelationshipGroupID      = model.RelationshipGroupID,
                OtherRelationship        = model.OtherRelationship,
                IsPolicyHolder           = model.IsPolicyHolder,
                CollateralEffectiveDate  = model.CollateralEffectiveDate,
                CollateralExpirationDate = model.CollateralExpirationDate,
                Relationships            = model.Relationships,
                CollateralTypes          = model.CollateralTypes
            };

            return(entity);
        }
        public void Initialize()
        {
            InitializeMock();

            colleteralDataForSuccess = new CollateralModel()
            {
                ParentContactID         = 1,
                ContactID               = 1,
                ContactTypeID           = 4,
                DriverLicense           = "driverLicense",
                DriverLicenseStateID    = 10,
                ContactRelationshipID   = 1,
                LivingWithClientStatus  = true,
                ReceiveCorrespondenceID = 1,
                FirstName               = "firstName",
                LastName           = "lastName",
                GenderID           = 1,
                DOB                = DateTime.Now,
                SuffixID           = 2,
                RelationshipTypeID = 2,
                IsActive           = true,
                ModifiedBy         = 5,
                ModifiedOn         = DateTime.Now,
                ForceRollback      = true
            };

            colleteralDataForFailure = new CollateralModel()
            {
                ParentContactID         = -1,
                ContactID               = -1,
                ContactTypeID           = -1,
                DriverLicense           = "driverLicense",
                DriverLicenseStateID    = 10,
                ContactRelationshipID   = 1,
                LivingWithClientStatus  = true,
                ReceiveCorrespondenceID = 1,
                FirstName               = "firstName",
                LastName           = "lastName",
                GenderID           = 1,
                DOB                = DateTime.Now,
                SuffixID           = 2,
                RelationshipTypeID = 2,
                IsActive           = true,
                ModifiedBy         = 5,
                ModifiedOn         = DateTime.Now,
                ForceRollback      = true
            };
        }
 public IHttpActionResult Updatecollateral(CollateralModel collateralModel)
 {
     if (ModelState.IsValid)
     {
         return(new HttpResult <Response <CollateralModel> >(collateralRuleEngine.UpdateCollateral(collateralModel), Request));
     }
     else
     {
         var errorMessage       = ModelState.ParseError();
         var validationResponse = new Response <CollateralModel>()
         {
             DataItems = new List <CollateralModel>(), ResultCode = -1, ResultMessage = errorMessage
         };
         return(new HttpResult <Response <CollateralModel> >(validationResponse, Request));
     }
 }
        public HttpResponseMessage GetCollateralCategoryWithType(HttpRequestMessage request, int categoryId)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                var item = new CollateralModel();

                CollateralCategory collateralCategory = _LoanService.GetCollateralCategory(categoryId);
                CollateralTypeData[] collateralTypes = _LoanService.GetCollateralTypeByCategory(collateralCategory.Code);

                item.CollateralCategory = collateralCategory;
                item.CollateralType = collateralTypes;

                // notice no need to create a seperate model object since CollateralCategory entity will do just fine
                response = request.CreateResponse <CollateralModel>(HttpStatusCode.OK, item);

                return response;
            }));
        }
        /// <summary>
        /// Converting List CollateralModel to List of ViewModel
        /// </summary>
        /// <param name="entity">entity</param>
        /// <returns></returns>
        public static Response <CollateralViewModel> ToViewModel(this Response <CollateralModel> entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model      = entity.CloneResponse <CollateralViewModel>();
            var collateral = new List <CollateralViewModel>();

            if (entity.DataItems != null)
            {
                entity.DataItems.ForEach(delegate(CollateralModel CollateralModel)
                {
                    var transformedModel = CollateralModel.ToViewModel();
                    collateral.Add(transformedModel);
                });

                model.DataItems = collateral;
            }
            return(model);
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (txtDuration.Text == "")
            {
                MetroFramework.MetroMessageBox.Show(this, "Warning! Please Fill-up All Required Fields.", "Loan", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error, this.Height / 2);
                return;
            }
            if (!isGenerated)
            {
                MetroFramework.MetroMessageBox.Show(this, "Warning! Invalid Loan Details", "Loan", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error, this.Height / 2);
                return;
            }
            if (int.Parse(txtDuration.Text) > 100)
            {
                MetroFramework.MetroMessageBox.Show(this, "Warning! Duration exceeds the limit", "Loan", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error, this.Height / 2);
                return;
            }
            if (!ValidateLoan())
            {
                MetroFramework.MetroMessageBox.Show(this, "Warning! Invalid Loan Details", "Loan",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Error, this.Height / 2);
                return;
            }
            if (ifEmpty(gName.Text, gAddress.Text, gContacts.Text, gRelation.Text, cValue.Text, cItem.Text, cDescription.Text))
            {
                MetroFramework.MetroMessageBox.Show(this, "Warning! Please Fill Up All Fields.", "Loan",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Error, this.Height / 2);
                return;
            }
            if (!ValidateNumeric(cValue.Text))
            {
                MetroFramework.MetroMessageBox.Show(this, "Warning! Collateral Value Must Be a Number.", "Loan",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Error, this.Height / 2);
                return;
            }

            GuarantorModel guarantor = new GuarantorModel()
            {
                Name          = gName.Text.ToUpper(),
                Address       = gAddress.Text.ToUpper(),
                ContactNumber = gContacts.Text,
                Relationship  = gRelation.Text.ToUpper()
            };

            CollateralModel collateral = new CollateralModel()
            {
                Item        = cItem.Text.ToUpper(),
                Description = cDescription.Text.ToUpper(),
                Value       = int.Parse(cValue.Text)
            };

            if (operation != "edit" && operation != "view")
            {
                if (await loans.Add(loan, guarantor, collateral))
                {
                    await SaveLedger(loans.loanId);

                    MetroFramework.MetroMessageBox.Show(this, loans.msg, "Loan", MessageBoxButtons.OK, MessageBoxIcon.Question, this.Height / 2);
                    btnSave.Enabled = false;
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, loans.msg, "Loan", MessageBoxButtons.OK, MessageBoxIcon.Error, this.Height / 2);
                }
            }
            else
            {
                string token = txtLoanId.Text.Substring(4);
                loan.Id = int.Parse(token);
                if (await loans.Update(loan, guarantor, collateral))
                {
                    string token2 = txtLoanId.Text.Substring(4);
                    int    id     = int.Parse(token2);

                    MetroFramework.MetroMessageBox.Show(this, loans.msg, "Loan", MessageBoxButtons.OK, MessageBoxIcon.Question, this.Height / 2);
                    btnSave.Enabled = false;

                    groupBox1.Enabled = false;
                    groupBox3.Enabled = false;
                    btnSave.Enabled   = false;
                    btnUpdate.Enabled = true;
                    btnDelete.Enabled = true;

                    operation = "view";
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, loans.msg, "Loan", MessageBoxButtons.OK, MessageBoxIcon.Error, this.Height / 2);
                }
            }
        }
        /// <summary>
        /// To update collateral
        /// </summary>
        /// <param name="collateralModel"></param>
        /// <returns></returns>
        public Response <CollateralModel> UpdateCollateral(CollateralModel collateralModel)
        {
            const string apiUrl = BaseRoute + "UpdateCollateral";

            return(communicationManager.Put <CollateralModel, Response <CollateralModel> >(collateralModel, apiUrl));
        }
Beispiel #16
0
 /// <summary>
 /// To add new collateral for contact
 /// </summary>
 /// <param name="collateralModel"></param>
 /// <returns></returns>
 public Response <CollateralModel> AddCollateral(CollateralModel collateralModel)
 {
     return(collateralService.AddCollateral(collateralModel));
 }
Beispiel #17
0
 /// <summary>
 /// To update collateral for contact
 /// </summary>
 /// <param name="collateralModel"></param>
 /// <returns></returns>
 public Response <CollateralModel> UpdateCollateral(CollateralModel collateralModel)
 {
     return(collateralService.UpdateCollateral(collateralModel));
 }
Beispiel #18
0
 public IHttpActionResult UpdateCollateral(CollateralModel collateralModel)
 {
     return(new HttpResult <Response <CollateralModel> >(collateralDataProvider.UpdateCollateral(collateralModel), Request));
 }
        public void AddCollateral_Success()
        {
            //Arrange
            var url = baseRoute + "addCollateral";

            var contactAddressModel = new List <ContactAddressModel>();

            contactAddressModel.Add(new ContactAddressModel
            {
                AddressTypeID    = 2,
                Line1            = "Address Line1",
                Line2            = "AddressLine2",
                City             = "Colorado",
                County           = 1,
                StateProvince    = 2,
                Zip              = "zipCode",
                MailPermissionID = 1
            });

            var contactPhoneModel = new List <ContactPhoneModel>();

            contactPhoneModel.Add(new ContactPhoneModel
            {
                PhoneTypeID       = 2,
                PhonePermissionID = 3,
                Number            = "9992225553"
            });

            var contactEmailModel = new List <ContactEmailModel>();

            contactEmailModel.Add(new ContactEmailModel
            {
                Email = "*****@*****.**"
            });

            var addCollateral = new CollateralModel
            {
                ParentContactID         = 3,
                ContactID               = 0,
                ContactTypeID           = 4,
                DriverLicense           = "123456",
                DriverLicenseStateID    = 10,
                ContactRelationshipID   = 1,
                LivingWithClientStatus  = true,
                ReceiveCorrespondenceID = 1,
                FirstName               = "firstName",
                LastName           = "lastName",
                GenderID           = 1,
                DOB                = DateTime.Now,
                SuffixID           = 2,
                RelationshipTypeID = 2,
                Addresses          = contactAddressModel,
                Phones             = contactPhoneModel,
                IsActive           = true,
                ModifiedBy         = 5,
                ModifiedOn         = DateTime.Now,
                ForceRollback      = true
            };

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

            //Assert
            Assert.IsNotNull(response, "Response can't be null.");
            Assert.IsTrue(response.ResultCode == 0, "Collateral could not be created.");
            Assert.IsTrue(response.RowAffected > 0, "Collateral could not be created.");
        }