Sfoglia il codice sorgente

M: Add of null checks

Maksutka 5 mesi fa
parent
commit
4c42ffd5df

+ 6 - 1
CheckArticlesForSpam/ViewModels/ProfileUserViewModel.cs

@@ -39,7 +39,12 @@ namespace CheckArticlesForSpam.ViewModels
 
         public User SaveChanges()
         {
-            if (!Regex.IsMatch(Phone, @"^(?:\+7|8)\d{10}$"))
+            if (string.IsNullOrEmpty(Login) || string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Phone))
+            {
+                Message = "Çàïîëíèòå âñå ïîëÿ";
+                return null;
+            }
+            else if (!Regex.IsMatch(Phone, @"^(?:\+7|8)\d{10}$"))
             {
                 Message = "Ââåäèòå êîððåêòíûé òåëåôîí";
                 return null;

+ 1 - 1
CheckArticlesForSpam/ViewModels/RegistrationPageViewModel.cs

@@ -37,7 +37,7 @@ namespace CheckArticlesForSpam.ViewModels
 
         public User AddUserInDataBase()
         {
-            if (NewUser.Login == null || NewUser.Username == null || NewUser.Password == null || RepeatInputPassword == null || NewUser.Phone == null)
+            if (string.IsNullOrEmpty(NewUser.Login) || string.IsNullOrEmpty(NewUser.Username) || string.IsNullOrEmpty(NewUser.Password) || string.IsNullOrEmpty(RepeatInputPassword) || string.IsNullOrEmpty(NewUser.Phone))
             {
                 Message = "Заполните все поля";
                 return null;