public void Test_MissingFirstName1()
        {
            //setup
            var request = new UpdateProviderRequest();
            request.FirstName = string.Empty;
            request.ProviderId = 1;
            request.LastName = "Cerfolio";
            var handler = CreateHandler();

            //act
            var response = HandleRequest<UpdateProviderResponse>(handler, request);
        }
        public void Test_LongName()
        {
            //setup
            var request = new UpdateProviderRequest();
            request.ProviderId = 1;
            request.FirstName = "Robert";
            request.LastName = new string('*', 36);
            var handler = CreateHandler();

            //act
            var response = HandleRequest<UpdateProviderResponse>(handler, request);
        }
        public void Test()
        {
            //setup
            DateTime? updatedDate;
            using (var context = _objectContextFactory.CreateObjectContext())
            {
                var provider = context.CreateObjectSet<Provider>().Single(p => p.Id == 1);
                updatedDate = provider.UpdatedDate;
            }
            var request = new UpdateProviderRequest();
            request.ProviderId = 1;
            request.FirstName = "Bob";
            request.LastName = "Cerfolio";
            request.CustomKeywords = "custom1,custom2";
            request.Custom1 = "newCustom1";
            request.Custom2 = "newCustom2";
            request.Custom3 = "newCustom3";
            request.GenderId = 1;
            var handler = CreateHandler();

            //act
            var response = HandleRequest<UpdateProviderResponse>(handler, request);

            //assert
            using (var context = _objectContextFactory.CreateObjectContext())
            {
                context.ContextOptions.LazyLoadingEnabled = true;
                context.ContextOptions.ProxyCreationEnabled = true;
                var provider = context.CreateObjectSet<Provider>().Single(p => p.Id == 1);
                Assert.AreEqual("Bob", provider.FirstName);
                Assert.IsNotNull(provider.UpdatedDate);
                Assert.Greater(provider.UpdatedDate.Value, updatedDate);
                Assert.LessOrEqual(provider.UpdatedDate.Value, DateTime.UtcNow); // using LessOrEqual in case precision isn't high
                Assert.AreEqual("bob-cerfolio-cardiology", provider.DirectUrl);
                Assert.AreEqual("custom1,custom2", provider.CustomKeywords);
                Assert.AreEqual("cardiology,custom1,custom2,dermatology,oncology,pediatrics", provider.Keywords);
                Assert.AreEqual("newCustom1", provider.Custom1);
                Assert.AreEqual("newCustom2", provider.Custom2);
                Assert.AreEqual("newCustom3", provider.Custom3);
            }
        }
Ejemplo n.º 4
0
        private void Save(ConvertServiceRequest request)
        {
            var originalImageUrl = _viewModel.ImageUrl;

            _providerId = int.Parse(GetFieldValue(_viewModel.Fields, _id), CultureInfo.InvariantCulture);

            Validate();

            if (_providerId == 0)
            {
                // Add - Main Provider Record
                var addRequest = new AddProviderRequest();
                PopulateRequestFieldValues(addRequest);

                _providerId = ProcessRequest<AddProviderResponse>(addRequest).Id;

                // Create response
                var detailResponse = QueryData(request);

                _viewModel.PageHeader = "Provider - " + detailResponse.Provider.FullName;
                _viewModel.SubHeader = "Edit Provider Information";
                _viewModel.SubEntities = BuildSubEntities();
                _viewModel.Fields = BuildFields(detailResponse.Provider, false);
            }
            else
            {
                //Update - Main Provider Record
                var updateRequest = new UpdateProviderRequest { ProviderId = _providerId };

                PopulateRequestFieldValues(updateRequest);
                ProcessRequest<UpdateProviderResponse>(updateRequest);

                // Create response
                var detailResponse = QueryData(request);

                _viewModel.PageHeader = "Provider - " + detailResponse.Provider.FullName;
                _viewModel.SubHeader = "Edit Provider Information";

                // Subentities
                foreach (var subentity in _viewModel.SubEntities)
                {
                    if (subentity.EntityName == _providerLanguageSubEntity)
                        ProviderLanguagesHelper.Save(this, subentity, _providerId);
                    if (subentity.EntityName == _providerClinicalInterestSubEntity)
                        ProviderClinicalInterestsHelper.Save(this, subentity, _providerId);
                    if (subentity.EntityName == _providerTypesSubEntity)
                        ProviderTypesHelper.Save(this, subentity, _providerId);
                    if (subentity.EntityName == _providerSpecialtySubEntity)
                        ProviderSpecialtiesHelper.Save(this, subentity, _providerId);
                    if (subentity.EntityName == _providerOrgUnitSubEntity)
                        ProviderLocationsHelper.Save(this, subentity, _providerId);
                    if (subentity.EntityName == _providerEducationsSubEntity)
                        ProviderEducationsHelper.Save(this, subentity, _providerId);
                    if (subentity.EntityName == _providerCertificationSubEntity)
                        ProviderCertificationsHelper.Save(this, subentity, _providerId);
                    if (subentity.EntityName == _directUrlHistorySubEntity)
                        DirectUrlHistoryHelper.Save(this, subentity, _providerId);
                }
            }

            // Upload provider's image if needed
            if (DigitalAssetManager.IsRawImageData(originalImageUrl))
                DigitalAssetManager.UploadImageAsset(Constants.ProviderProfileImagePath + "/" + CalculateProfileImageName(originalImageUrl, _providerId), originalImageUrl);

            ProcessOneWayRequest(new UpdateProviderG2RecordRequest() { ProviderId = _providerId });
        }