/
SignupPageViewModel.cs
51 lines (43 loc) · 1.51 KB
/
SignupPageViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using PetBellies.BLL.Helper;
using PetBellies.Model;
using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace PetBellies.BLL.ViewModel
{
public class SignupPageViewModel
{
public async Task<string> SignUpAsync(User user)
{
if (string.IsNullOrEmpty(user.Email) || string.IsNullOrEmpty(user.FirstName) ||
string.IsNullOrEmpty(user.LastName) || string.IsNullOrEmpty(user.Password))
{
return English.YouHaveToFillAllEntries();
}
if (user.Password.Length < 6 || user.Password.Length > 16)
{
return English.BadPasswordLength();
}
user.Email = user.Email.ToLower();
var isItAUser = GlobalVariables.databaseConnection.GetUserByEmail(user.Email);
if (isItAUser is null || string.IsNullOrEmpty(isItAUser.Email))
{
GlobalVariables.InitializeGlobalCasualImage();
user.ProfilePicture = GlobalVariables.GlobalCasualImage;
user.Password = new Segédfüggvények().EncryptPassword(user.Password);
var success = GlobalVariables.databaseConnection.AddUser(user);
if (success)
{
return English.Empty();
}
}
else
{
return English.ThisEmailIsExist();
}
return English.SomethingWentWrong();
}
}
}