Functions.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. namespace PartsWarehouse
  8. {
  9. public class Functions
  10. {
  11. // Валидация логина и пароля при входе
  12. public static bool IsValidLogAndPass(string login, string password)
  13. {
  14. if (login == "" || password == "")
  15. return false;
  16. else
  17. return true;
  18. }
  19. // Валидация логина и пароля
  20. public static bool IsLogEqualPass(string login, string password)
  21. {
  22. if (login == password)
  23. return false;
  24. else
  25. return true;
  26. }
  27. // Валидация логина и пароля
  28. public static bool IsValidLength(string str)
  29. {
  30. if (str.Length < 5)
  31. return false;
  32. else
  33. return true;
  34. }
  35. // Проверка на правильность введеных данных при входе
  36. public static bool LoginCheck(string login, string password)
  37. {
  38. if (cnt.db.User.Select(item => item.Login + item.Password).Contains(login + Encrypt.GetHash(password)))
  39. return true;
  40. else
  41. return false;
  42. }
  43. // Проверка на уникальность логина
  44. public static bool IsLoginAlreadyTaken(string login)
  45. {
  46. return cnt.db.User.Select(item => item.Login).Contains(login);
  47. }
  48. // Проверка на наличие чата
  49. public static bool IsChatAlreadyCreated(string chatName)
  50. {
  51. //return cnt.db.Chat.Select(item => item.Name).Contains(chatName);
  52. return false;
  53. }
  54. // Получение id чата по его названию
  55. public static int GetIdChat(string chatName)
  56. {
  57. //return cnt.db.Chat.Where(item => item.Name == chatName).Select(item => item.IdChat).FirstOrDefault();
  58. return 0;
  59. }
  60. }
  61. }