예제 #1
0
        public void RequestAccess(string url, AccessRequestItem record, string createdBy)
        {
            MasterServiceType serviceType = null;

            if (record.ServiceType != "Other")
            {
                var masterServiceTypeManager = this.container.GetInstance <MasterServiceTypeManager>();
                serviceType = masterServiceTypeManager.GetByName(record.ServiceType);
            }

            if (serviceType == null && string.IsNullOrWhiteSpace(record.MasterServiceTypeOtherComment))
            {
                throw new Exception("If Service Type is 'Other', Service Type Other Comment is required.");
            }

            var appSettingManager = this.container.GetInstance <ApplicationSettingManager>();
            var supervisor        = appSettingManager.GetByName(Constants.ApplicationSettings.CoordinatorSupervisorEmail);
            var factAdminEmail    = appSettingManager.GetByName(Constants.ApplicationSettings.AutoCcEmailAddress);

            var manager = this.container.GetInstance <AccessRequestManager>();

            manager.Add(factAdminEmail.Value, supervisor.Value, url, record, serviceType, createdBy);
        }
예제 #2
0
        public void Add(string factPortalEmailAddress, string supervisorEmailAddress, string url, AccessRequestItem item, MasterServiceType masterServiceType, string createdBy)
        {
            if (masterServiceType == null && string.IsNullOrWhiteSpace(item.MasterServiceTypeOtherComment))
            {
                throw new Exception("Both Service Type and Service Type Comment cannot be null");
            }

            var accessRequest = new AccessRequest
            {
                Guid                          = Guid.NewGuid().ToString(),
                OrganizationName              = item.OrganizationName,
                DirectorName                  = item.DirectorName,
                DirectorEmailAddress          = item.DirectorEmailAddress,
                PrimaryContactName            = item.PrimaryContactName,
                PrimaryContactEmailAddress    = item.PrimaryContactEmailAddress,
                PrimaryContactPhoneNumber     = item.PrimaryContactPhoneNumber,
                OrganizationAddress           = item.OrganizationAddress,
                MasterServiceTypeId           = masterServiceType?.Id,
                MasterServiceTypeOtherComment = item.MasterServiceTypeOtherComment,
                OtherComments                 = item.OtherComments,
                CreatedBy                     = createdBy ?? "New",
                CreatedDate                   = DateTime.Now
            };

            base.Repository.Add(accessRequest);

            var getUrl = url + "app/email.templates/requestAccess.html";

            var html = WebHelper.GetHtml(getUrl);

            html = string.Format(html, item.OrganizationName, item.DirectorName, item.DirectorEmailAddress,
                                 item.PrimaryContactName, item.PrimaryContactEmailAddress, item.PrimaryContactPhoneNumber,
                                 item.OrganizationAddress, item.ServiceType, item.MasterServiceTypeOtherComment, item.OtherComments);

            EmailHelper.Send(new List <string> {
                factPortalEmailAddress
            }, new List <string> {
                supervisorEmailAddress
            }, "Request For New Organization Access", html);
        }