Exemple #1
0
        /// <summary>
        /// Output error messages to ModelState
        /// </summary>
        /// <param name="controller">Current Controller</param>
        public static void OutputModelMessage(this AbpController controller)
        {
            if (controller.TempData["ModelState"] != null)
            {
                controller.ViewBag.HasMessage = true;
                var dics = controller.TempData["ModelState"] as ModelStateDictionary;
                if (dics != null)
                {
                    var msd = dics.Dereference <ModelStateDictionary>();
                    foreach (var item in msd)
                    {
                        if (item.Value != null)
                        {
                            foreach (var error in item.Value.Errors)
                            {
                                var strKey = item.Key;
                                if (string.IsNullOrEmpty(strKey))
                                {
                                    strKey = Md5Cipher.GetMd5Str(error.ErrorMessage);
                                }

                                if (!controller.ModelState.ContainsKey(strKey))
                                {
                                    controller.ModelState.AddModelError(strKey, error.ErrorMessage);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void Md5Cipher_Encryption_Test()
        {
            var encryption = Md5Cipher.Encryption("VeyselMUTLU");

            Assert.AreEqual("8533488b2ce8d362b44ed19f29fe2480", encryption); // Resource https://wmaraci.com/md5-sha1-sifre-olusturucu
        }