Example #1
0
        public void UpdateEmergencyContact_Success()
        {
            //Act
            Mock_EmergencyContact_Success();
            var updateEmergencyContact = new EmergencyContactModel
            {
                ParentContactID       = 3,
                ContactID             = 2,
                ContactTypeID         = 3,
                FirstName             = "firstName11",
                LastName              = "lastName11",
                GenderID              = 1,
                DOB                   = DateTime.Now,
                SuffixID              = 2,
                ContactRelationshipID = 2,
                RelationshipTypeID    = 4,
                IsActive              = true,
                ModifiedBy            = 5,
                ModifiedOn            = DateTime.Now,
                ForceRollback         = true
            };
            var updateEmergencyContactResult = emergencyContactController.UpdateEmergencyContact(updateEmergencyContact);
            var response         = updateEmergencyContactResult as HttpResult <Response <EmergencyContactModel> >;
            var emergencyContact = response.Value.DataItems;
            var count            = emergencyContact.Count();

            //Assert
            Assert.IsNotNull(emergencyContact);
            Assert.IsTrue(count > 0, "Emergency Contact could not be updated.");
        }
Example #2
0
        public void UpdateEmergencyContact_Failure()
        {
            //Arrange
            var url = baseRoute + "updateEmergencyContact";

            //Update Additional Demographic
            var updateEmergencyContact = new EmergencyContactModel
            {
                ParentContactID       = 3,
                ContactID             = -1,
                ContactTypeID         = 3,
                FirstName             = "firstName11",
                LastName              = "lastName11",
                ContactRelationshipID = 3,
                RelationshipTypeID    = 4,
                IsActive              = true,
                ModifiedBy            = 5,
                ModifiedOn            = DateTime.Now,
                ForceRollback         = true
            };

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

            //Assert
            Assert.IsTrue(response.RowAffected == 0, "Emergency Contact updated.");
        }
Example #3
0
        public void UpdateEmergencyContact_Failure()
        {
            //Act
            Mock_EmergencyContact_Failure();
            var updateEmergencyContactFailure = new EmergencyContactModel
            {
                ParentContactID       = 3,
                ContactID             = -1,
                ContactTypeID         = 3,
                FirstName             = "firstName11",
                LastName              = "lastName11",
                GenderID              = 1,
                DOB                   = DateTime.Now,
                SuffixID              = 2,
                ContactRelationshipID = 2,
                RelationshipTypeID    = 4,
                IsActive              = true,
                ModifiedBy            = 5,
                ModifiedOn            = DateTime.Now,
                ForceRollback         = true
            };
            var updateEmergencyContactResult = emergencyContactController.UpdateEmergencyContact(updateEmergencyContactFailure);
            var response = updateEmergencyContactResult as HttpResult <Response <EmergencyContactModel> >;

            //Assert
            var emergencyContact = response.Value;

            //Assert
            Assert.IsNotNull(emergencyContact);
            Assert.IsTrue(emergencyContact.RowAffected == 0, "Emergency Contact updated.");
        }
        /// <summary>
        /// Converting EmergencyContactViewModel to EmergencyContactModel
        /// </summary>
        /// <param name="model">model</param>
        /// <returns></returns>
        public static EmergencyContactModel ToModel(this EmergencyContactViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new EmergencyContactModel
            {
                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,
                RelationshipTypeID       = model.RelationshipTypeID,
                ContactTypeID            = model.ContactTypeID,
                ContactRelationshipID    = model.ContactRelationshipID,
                LivingWithClientStatusID = model.LivingWithClientStatusID,
                SSN                      = model.SSN,
                DriverLicense            = model.DriverLicense,
                AlternateID              = model.AlternateID,
                IsActive                 = model.IsActive,
                ModifiedBy               = model.ModifiedBy,
                ModifiedOn               = model.ModifiedOn,
                ForceRollback            = model.ForceRollback
            };

            return(entity);
        }
        public ActionResult Update(EmergencyContactModel vm)
        {
            ApiResult <EmergencyContact> apiResult;

            if (ModelState.IsValid)
            {
                if (vm.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var emergencyContact = new EmergencyContact
                        {
                            Name         = vm.Name,
                            Relationship = vm.Relationship,
                            Phone        = vm.Phone,
                            EmployeeId   = vm.EmployeeId,
                            Mobile       = vm.Mobile,
                            WorkPhone    = vm.WorkPhone,
                            Address      = vm.Address,
                            Email        = vm.Email,
                            Id           = vm.Id,
                        };
                        _emergencyContactRepository.Update(emergencyContact);
                        _unitOfWork.Commit();
                        return(emergencyContact);
                    }, "Emergency Contact updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        var emergencyContact = new EmergencyContact
                        {
                            Name         = vm.Name,
                            Relationship = vm.Relationship,
                            Phone        = vm.Phone,
                            EmployeeId   = vm.EmployeeId,
                            Mobile       = vm.Mobile,
                            WorkPhone    = vm.WorkPhone,
                            Address      = vm.Address,
                            Email        = vm.Email,
                            Id           = vm.Id
                        };
                        _emergencyContactRepository.Create(emergencyContact);
                        _unitOfWork.Commit();
                        return(emergencyContact);
                    }, "Emergency Contact created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <EmergencyContact>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public void AddEmergencyContact_Failure()
        {
            //Arrange
            var url = baseRoute + "addEmergencyContact";

            //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 addEmergencyContact = new EmergencyContactModel
            {
                ParentContactID       = -1,
                ContactID             = -1,
                ContactTypeID         = -1,
                FirstName             = "firstName1",
                LastName              = "lastName1",
                GenderID              = 1,
                DOB                   = DateTime.Now,
                SuffixID              = 2,
                ContactRelationshipID = 1,
                RelationshipTypeID    = 2,
                Addresses             = contactAddressModel,
                Phones                = contactPhoneModel,
                Emails                = contactEmailModel,
                IsActive              = true,
                ModifiedBy            = 5,
                ModifiedOn            = DateTime.Now,
                ForceRollback         = true
            };

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

            //Assert
            Assert.IsTrue(response.ResultCode != 0);
            Assert.IsTrue(response.RowAffected == 0, "Emergency Contact created.");
        }
Example #7
0
        public void AddEmergencyContact_Failure()
        {
            //Act
            Mock_EmergencyContact_Failure();

            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 addEmergencyContactFailure = new EmergencyContactModel
            {
                ParentContactID       = -1,
                ContactID             = -1,
                ContactTypeID         = -1,
                FirstName             = null,
                LastName              = null,
                GenderID              = 1,
                DOB                   = DateTime.Now,
                SuffixID              = 2,
                ContactRelationshipID = 0,
                RelationshipTypeID    = 0,
                Addresses             = contactAddressModel,
                Phones                = contactPhoneModel,
                Emails                = contactEmailModel,
                IsActive              = true,
                ModifiedBy            = 5,
                ModifiedOn            = DateTime.Now,
                ForceRollback         = true
            };

            var addEmergencyContactResult = emergencyContactController.AddEmergencyContact(addEmergencyContactFailure);
            var response         = addEmergencyContactResult as HttpResult <Response <EmergencyContactModel> >;
            var emergencyContact = response.Value;

            //Assert
            Assert.IsNotNull(emergencyContact);
            Assert.IsTrue(emergencyContact.RowAffected == 0, "Emergency contact created.");
        }
        /// <summary>
        /// To update emergency contact
        /// </summary>
        /// <param name="emergencyContactModel">Emergency Contact Model</param>
        /// <returns>Response of type EmergencyContactModel</returns>
        public Response <EmergencyContactModel> UpdateEmergencyContact(EmergencyContactModel emergencyContactModel)
        {
            const string apiUrl = BaseRoute + "UpdateEmergencyContact";

            return(communicationManager.Put <EmergencyContactModel, Response <EmergencyContactModel> >(emergencyContactModel, apiUrl));
        }
Example #9
0
 public IHttpActionResult UpdateEmergencyContact(EmergencyContactModel emergencyContactModel)
 {
     return(new HttpResult <Response <EmergencyContactModel> >(emergencyContactDataProvider.UpdateEmergencyContact(emergencyContactModel), Request));
 }
Example #10
0
 /// <summary>
 /// To update existing Emergency Contact
 /// </summary>
 /// <param name="emergencyContactModel">Emergency Contact Model</param>
 /// <returns>Response tpe Emergency Contact Model</returns>
 public Response <EmergencyContactModel> UpdateEmergencyContact(EmergencyContactModel emergencyContactModel)
 {
     return(emergencyContactService.UpdateEmergencyContact(emergencyContactModel));
 }
Example #11
0
 /// <summary>
 /// To add Emergency Contact
 /// </summary>
 /// <param name="emergencyContactModel">Emergency Contact Model</param>
 /// <returns>Response tpe Emergency Contact Model</returns>
 public Response <EmergencyContactModel> AddEmergencyContact(EmergencyContactModel emergencyContactModel)
 {
     return(emergencyContactService.AddEmergencyContact(emergencyContactModel));
 }
Example #12
0
 public IHttpActionResult UpdateEmergencyContact(EmergencyContactModel emergencyContactModel)
 {
     return(new HttpResult <Response <EmergencyContactModel> >(emergencyContactRuleEngine.UpdateEmergencyContact(emergencyContactModel), Request));
 }