コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserMap"/> class.
        /// </summary>
        public UserMap()
        {
            this.Map(x => x.FirstName).Length(100).Not.Nullable();
            this.Map(x => x.LastName).Length(100).Nullable();
            this.Map(x => x.Password).Length(100).Nullable();
            this.Map(x => x.Email).Nullable();
            this.Map(x => x.SessionToken).Nullable();
            this.Map(x => x.SessionTokenExpirationDate).Nullable();
            this.Map(x => x.DateCreated).Not.Nullable();
            this.Map(x => x.DateModified).Not.Nullable();
            this.Map(x => x.Status).Default(1.ToString());
            this.References(x => x.Logo).Nullable().LazyLoad().Column("logoId");
            this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <User>(x => x.ModifiedBy)));

            this.HasMany(x => x.Activations).Cascade.Delete().Inverse().ExtraLazyLoad();
            this.HasMany(x => x.ACSessions).Cascade.Delete().Inverse().ExtraLazyLoad();
            this.HasMany(x => x.LoginHistory).Cascade.Delete().Inverse().ExtraLazyLoad();
            this.HasMany(x => x.Files).Cascade.Delete().Inverse().ExtraLazyLoad().KeyColumn("createdBy");
            this.HasMany(x => x.DistractorsCreated).ExtraLazyLoad().KeyColumn("createdBy");
            this.HasMany(x => x.DistractorsModified).ExtraLazyLoad().KeyColumn("modifiedBy");

            this.HasMany(x => x.ThemeAttributesCreated).ExtraLazyLoad().KeyColumn("createdBy");
            this.HasMany(x => x.ThemeAttributesModified).ExtraLazyLoad().KeyColumn("modifiedBy");

            this.HasMany(x => x.SubModuleCategories).Cascade.Delete().Inverse().ExtraLazyLoad().KeyColumn("userId");
            this.HasMany(x => x.SubModuleCategoriesModified).ExtraLazyLoad().KeyColumn("modifiedBy");

            this.References(x => x.UserRole).Not.Nullable();
            this.References(x => x.Company).Not.Nullable().LazyLoad();
            this.References(x => x.Language).Not.Nullable().LazyLoad();
            this.References(x => x.TimeZone).Not.Nullable().LazyLoad();
            this.Map(x => x.IsUnsubscribed).Nullable();
        }
コード例 #2
0
        private bool UpdateFileWithStatus(string connectionString, Guid id, UploadFileStatus status, ILogger log)
        {
            var    typeName            = typeof(Domain.Entities.File).Name;
            string updateStatusCommand = string.Format("update [{0}] set {1} = @status where {2} = @id", typeName,
                                                       Inflector.Uncapitalize(Lambda.Property <Domain.Entities.File>(x => x.UploadFileStatus)),
                                                       Inflector.Uncapitalize(typeName + Lambda.Property <Domain.Entities.File>(x => x.Id)));

            using (var con = new SqlConnection(connectionString))
            {
                try
                {
                    con.Open();
                    using (var cmd = new SqlCommand(updateStatusCommand, con))
                    {
                        cmd.Parameters.AddWithValue("@status", (int)status);
                        cmd.Parameters.AddWithValue("@id", id);
                        int effected = cmd.ExecuteNonQuery();
                        return(effected == 1);
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        log.Error("Converter. Failed to update status of file: id=" + id + ", status=" + (int)status, ex);
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch
                    {
                    }
                }
            }

            return(false);
        }
コード例 #3
0
 public void Uncapitalize()
 {
     foreach (var pair in TestData)
     {
         Assert.AreEqual(Inflector.Uncapitalize(pair.Key), pair.Value);
     }
 }
コード例 #4
0
 /// <summary>
 /// The get key name.
 /// </summary>
 /// <param name="property">
 /// The property.
 /// </param>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <returns>
 /// The <see cref="string"/>.
 /// </returns>
 protected override string GetKeyName(Member property, Type type)
 {
     return(property != null && this.exceptions.Contains(property.Name)
                ? Inflector.Uncapitalize(property.Name)
                : string.Format(
                CultureInfo.InvariantCulture,
                FluentConfiguration.ForeignKeyNameTemplate,
                Inflector.Uncapitalize(type.Name)));
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThemeMap"/> class.
 /// </summary>
 public ThemeMap()
 {
     this.Map(x => x.ThemeName).Length(50).Not.Nullable();
     this.Map(x => x.DateCreated).Not.Nullable();
     this.Map(x => x.DateModified).Not.Nullable();
     this.Map(x => x.IsActive).Nullable();
     this.References(x => x.CreatedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Theme>(x => x.CreatedBy)));
     this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Theme>(x => x.ModifiedBy)));
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompanyMap"/> class.
 /// </summary>
 public CompanyMap()
 {
     this.Map(x => x.CompanyName).Length(50).Not.Nullable();
     this.Map(x => x.Status).Not.Nullable();
     this.Map(x => x.DateCreated).Not.Nullable();
     this.Map(x => x.UseEventMapping).Not.Nullable();
     this.Map(x => x.DateModified).Not.Nullable();
     this.References(x => x.Address).Nullable().Cascade.Delete();
     this.References(x => x.Theme).Nullable().Cascade.Delete();
     this.References(x => x.PrimaryContact).Nullable().Column(Inflector.Uncapitalize(Lambda.Property <Company>(x => x.PrimaryContact)) + "Id");
     this.HasMany(x => x.Users).Cascade.Delete().Inverse();
     this.HasMany(x => x.Licenses).Cascade.Delete().Inverse();
 }
コード例 #7
0
        /// <summary>
        /// The apply.
        /// </summary>
        /// <param name="instance">
        /// The instance.
        /// </param>
        public void Apply(IPropertyInstance instance)
        {
            const string NamePattern      = "Name";
            bool         isEntityTypeName = !Exceptions.Contains(instance.Property.Name) &&
                                            instance.Property.Name.EndsWith(NamePattern) &&
                                            instance.Property.Name == instance.EntityType.Name + NamePattern;
            string column = string.Format(
                CultureInfo.InvariantCulture,
                FluentConfiguration.ColumnNameTemplate,
                Inflector.Uncapitalize(isEntityTypeName ? instance.EntityType.Name : instance.Property.Name));

            instance.Column(column);
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SubModuleCategoryMap"/> class.
        /// </summary>
        public SubModuleCategoryMap()
        {
            this.Map(x => x.CategoryName).Length(255).Nullable();
            this.Map(x => x.IsActive).Nullable();
            this.Map(x => x.DateModified).Not.Nullable();
            this.Map(x => x.LmsCourseId).Nullable();
            this.Map(x => x.CompanyLmsId).Nullable();

            this.HasMany(x => x.SubModuleItems).ExtraLazyLoad().Cascade.Delete().Inverse();

            this.References(x => x.User);
            this.References(x => x.SubModule);
            this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <SubModuleCategory>(x => x.ModifiedBy)));
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompanyLicenseMap"/> class.
 /// </summary>
 public CompanyLicenseMap()
 {
     this.Map(x => x.Domain).Nullable();
     this.Map(x => x.LicenseStatus).CustomType <CompanyLicenseStatus>().Not.Nullable();
     this.Map(x => x.ExpiryDate);
     this.Map(x => x.LicenseNumber).Length(50).Not.Nullable();
     this.Map(x => x.TotalLicensesCount).Not.Nullable().Default("(1)");
     this.Map(x => x.TotalParticipantsCount).Not.Nullable().Default("(100)");
     this.Map(x => x.DateStart).Not.Nullable();
     this.Map(x => x.DateCreated).Not.Nullable();
     this.Map(x => x.DateModified).Not.Nullable();
     this.References(x => x.Company).Nullable();
     this.References(x => x.CreatedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <CompanyLicense>(x => x.CreatedBy)));
     this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <CompanyLicense>(x => x.ModifiedBy)));
     this.Map(x => x.HasApi).Not.Nullable();
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThemeAttributeMap"/> class.
 /// </summary>
 public ThemeAttributeMap()
 {
     this.References(x => x.Theme).Not.Nullable();
     this.Map(x => x.ThemeOrder).Nullable();
     this.Map(x => x.BgColor).Length(6).Nullable();
     this.Map(x => x.TitleColor).Length(6).Nullable();
     this.Map(x => x.CategoryColor).Length(6).Nullable();
     this.Map(x => x.SelectionColor).Length(6).Nullable();
     this.Map(x => x.QuestionHintColor).Length(6).Nullable();
     this.Map(x => x.QuestionTextColor).Length(6).Nullable();
     this.Map(x => x.QuestionInstructionColor).Length(6).Nullable();
     this.Map(x => x.ResponseCorrectColor).Length(6).Nullable();
     this.Map(x => x.ResponseIncorrectColor).Length(6).Nullable();
     this.Map(x => x.DistractorTextColor).Length(6).Nullable();
     this.Map(x => x.DateCreated).Not.Nullable();
     this.Map(x => x.DateModified).Not.Nullable();
     this.Map(x => x.IsActive).Nullable();
     this.References(x => x.CreatedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Theme>(x => x.CreatedBy)));
     this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Theme>(x => x.ModifiedBy)));
 }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SubModuleItemMap"/> class.
        /// </summary>
        public SubModuleItemMap()
        {
            this.Map(x => x.IsActive).Nullable();
            this.Map(x => x.IsShared).Nullable();
            this.Map(x => x.DateModified).Not.Nullable();
            this.Map(x => x.DateCreated).Not.Nullable();

            this.HasMany(x => x.AppletItems).ExtraLazyLoad().Cascade.Delete().Inverse();
            this.HasMany(x => x.Questions).ExtraLazyLoad().Cascade.Delete().Inverse();
            this.HasMany(x => x.Quizes).LazyLoad().Cascade.Delete().Inverse();
            this.HasMany(x => x.Surveys).LazyLoad().Cascade.Delete().Inverse();
            this.HasMany(x => x.Tests).ExtraLazyLoad().Cascade.Delete().Inverse();
            this.HasMany(x => x.SNProfiles).ExtraLazyLoad().Cascade.Delete().Inverse();
            this.HasMany(x => x.ACSessions).ExtraLazyLoad().Cascade.Delete().Inverse();
            this.HasMany(x => x.Themes).Cascade.Delete().Inverse();

            this.References(x => x.SubModuleCategory);
            this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <SubModuleItem>(x => x.ModifiedBy)));
            this.References(x => x.CreatedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <SubModuleItem>(x => x.CreatedBy)));
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DistractorMap"/> class.
        /// </summary>
        public DistractorMap()
        {
            this.Map(x => x.DistractorName).Not.Nullable();
            this.Map(x => x.DistractorOrder).Not.Nullable();
            this.Map(x => x.Score).Length(50).Nullable();
            this.Map(x => x.IsCorrect).Nullable();
            this.Map(x => x.IsActive).Nullable();
            this.Map(x => x.DistractorType).Nullable();
            this.Map(x => x.DateCreated).Not.Nullable();
            this.Map(x => x.DateModified).Not.Nullable();
            this.Map(x => x.LmsAnswer).Length(100).Nullable();
            this.Map(x => x.LmsAnswerId).Nullable();
            this.Map(x => x.LmsProviderId).Nullable();

            this.References(x => x.Question).Nullable();
            this.References(x => x.Image).Column("imageId").Nullable();
            this.References(x => x.LeftImage).Column("leftImageId").Nullable();
            this.References(x => x.RightImage).Column("rightImageId").Nullable();
            this.References(x => x.CreatedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Distractor>(x => x.CreatedBy)));
            this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Distractor>(x => x.ModifiedBy)));
        }
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QuestionMap"/> class.
        /// </summary>
        public QuestionMap()
        {
            this.Map(x => x.QuestionName).Length(2000).Not.Nullable();
            this.Map(x => x.HtmlText).Length(2000).Nullable();
            this.Map(x => x.QuestionOrder).Not.Nullable();
            this.Map(x => x.Instruction).Nullable();
            this.Map(x => x.CorrectMessage).Nullable();
            this.Map(x => x.CorrectReference).Length(2000).Nullable();
            this.Map(x => x.IncorrectMessage).Nullable();
            this.Map(x => x.Hint).Nullable();
            this.Map(x => x.IsActive).Nullable();
            this.Map(x => x.ScoreValue).Not.Nullable().Default(0.ToString(CultureInfo.InvariantCulture));
            this.Map(x => x.DateModified).Not.Nullable();
            this.Map(x => x.DateCreated).Not.Nullable();
            this.Map(x => x.LmsQuestionId).Nullable();
            this.Map(x => x.RandomizeAnswers).Nullable();
            this.Map(x => x.Rows).Nullable();
            this.Map(x => x.LmsProviderId).Nullable().Column("lmsProviderId");

            this.HasMany(x => x.QuizQuestionResults).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.SurveyQuestionResults).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.TestQuestionResults).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.Distractors).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.LikertQuestions).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.RateQuestions).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.TrueFalseQuestions).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.WeightBucketQuestions).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.OpenAnswerQuestions).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();
            this.HasMany(x => x.SingleMultipleChoiceQuestions).ExtraLazyLoad().Cascade.DeleteOrphan().Inverse();

            this.References(x => x.QuestionType);
            this.References(x => x.SubModuleItem);
            this.References(x => x.Image).Column("imageId");
            this.References(x => x.ModifiedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Question>(x => x.ModifiedBy)));
            this.References(x => x.CreatedBy).Nullable().LazyLoad().Column(Inflector.Uncapitalize(Lambda.Property <Question>(x => x.CreatedBy)));
        }
コード例 #14
0
 /// <summary>
 /// The apply.
 /// </summary>
 /// <param name="instance">
 /// The instance.
 /// </param>
 public void Apply(IIdentityInstance instance)
 {
     instance.Column(Inflector.Uncapitalize(instance.EntityType.Name) + "Id");
 }