コード例 #1
0
ファイル: ShortLinkModel.cs プロジェクト: SIN-NIN/vctr
        // ------------------------------------------------
        // -- Model Functions

        /// <summary>
        ///
        /// Sanitizes the model when it is getting passed
        /// as request body model to be saved in the
        /// database.
        ///
        /// On invokation, the set <i>ShortIdent</i>
        /// will be lowercased.
        ///
        /// If <i>asNew</i> is set to true, properties
        /// which are not settable by the user will be
        /// set to a default value.
        ///
        /// </summary>
        /// <param name="asNew"></param>
        public void Sanitize(bool asNew = false)
        {
            if (asNew)
            {
                AccessCount  = 0;
                CreationDate = DateTime.Now;
                LastAccess   = default;
                LastModified = DateTime.Now;
            }

            ShortIdent = ShortIdent.ToLower();
        }
コード例 #2
0
ファイル: ShortLinkModel.cs プロジェクト: SIN-NIN/vctr
 /// <summary>
 ///
 /// Returns if the set <i>ShortIdent</i>
 /// is not mepty, does not consists of a
 /// blacklisted ident or matches the
 /// defined pattern of a valid short ident.
 ///
 /// </summary>
 /// <returns>is valid state</returns>
 public bool ValidateIdent() =>
 !ShortIdent.IsEmpty() &&
 !ShortIdentBlacklist.Contains(ShortIdent) &&
 ShortIdentPattern.IsMatch(ShortIdent);