public Account Login(string username, string password) { UserServiceReference.User user = Services.Instance.UserClient().Login(username, password); if (string.IsNullOrEmpty(user.LoginToken.SecureToken)) { return(null); } return(Find(user.LoginToken.SecureToken)); }
public ShowTaskForm(BookingServiceReference.Booking booking, BookingServiceReference.SupportTask supportTask) { InitializeComponent(); lblStartDate.Text = booking.StartDate.ToString(); lblEndDate.Text = booking.EndDate.ToString(); UserServiceReference.User user = userService.GetUser(booking.User_Id); lblCreatedBy.Text = user.FirstName + " " + user.LastName; lblName.Text = supportTask.Name.ToString(); txtDescription.Text = supportTask.Description.ToString(); }
public bool Login(LoginModel loginModel) { var login = new UserServiceReference.User() { Email = loginModel.Email, Password = loginModel.Password }; var query = clientServiceClient.LoginClient(login); if (query) { return(true); } else { return(false); } }
public Account Find(string token) { //Get user with the token Account ac = new Account(); UserServiceReference.User user = Services.Instance.UserClient().GetUserByToken(token); ac.Username = user.UserName; ac.Password = user.Password; ac.Token = token; if (user.Admin) { ac.Roles = new string[] { "Admin", "User" }; } else { ac.Roles = new string[] { "User" }; } return(ac); }
public ShowReadyToGoForm(BookingServiceReference.Booking booking, BookingServiceReference.ReadyToGo readyToGo) { InitializeComponent(); lblStartDate.Text = booking.StartDate.ToString(); lblEndDate.Text = booking.EndDate.ToString(); UserServiceReference.User user = userService.GetUser(booking.User_Id); lblCreatedBy.Text = user.FirstName + " " + user.LastName; lblProductNr.Text = readyToGo.ProductNr.ToString(); lblAppendixNr.Text = readyToGo.AppendixNr.ToString(); if (readyToGo.Contract == true) { lblHasContract.Text = "Ja"; } else { lblHasContract.Text = "Nej"; } lblAdditionalServices.Text = readyToGo.AdditionalServices; }
public ActionResult Register(FormCollection collection) { if (IsUserLoggedIn(Request, Response)) { return(Redirect("~/")); } var username = collection["username"]; var name = collection["name"]; var birth = collection["birthday"]; var phone = collection["phone"]; var email = collection["email"]; var password = collection["password"]; var zip = collection["zip"]; var address = collection["address"]; var gender = collection["gender"]; var zipId = collection["zip"]; #region validation var valid = true; var usernameMinLength = 3; var usernameMaxLength = 30; var passwordMinLenth = 5; var passwordMaxLength = 100; var nameMinLength = 2; var nameMaxLenth = 30; var phoneMinLength = 5; var phoneMaxLength = 40; var addressMinLength = 3; var addressMaxLength = 100; if (string.IsNullOrWhiteSpace(username)) { ViewBag.usernameError = "Username is a required field"; valid = false; } else if (username.Length < usernameMinLength) { ViewBag.usernameError = $"Username must contain {usernameMinLength} or more characters"; valid = false; } else if (username.Length > usernameMaxLength) { ViewBag.usernameError = $"Username can not contain more than {usernameMaxLength} characters"; valid = false; } if (string.IsNullOrWhiteSpace(password)) { ViewBag.passwordError = "Password is a required field"; valid = false; } else if (password.Length < passwordMinLenth) { ViewBag.passwordError = $"Password must contain {passwordMinLenth} or more characters"; valid = false; } else if (password.Length > passwordMaxLength) { ViewBag.passwordError = $"Password can not contain more than {passwordMaxLength} characters"; valid = false; } else if (!password.Any(c => char.IsLower(c))) { ViewBag.passwordError = "Password must contain at least one lowercased letter"; valid = false; } else if (!password.Any(c => char.IsUpper(c))) { ViewBag.passwordError = "Password must contain at least one capital letter"; valid = false; } else if (!password.Any(c => char.IsDigit(c))) { ViewBag.passwordError = "Password must contain at least one digit"; valid = false; } if (string.IsNullOrWhiteSpace(name)) { ViewBag.nameError = "Name is a required field"; valid = false; } else if (name.Length < nameMinLength) { ViewBag.nameError = $"Name must contain {nameMinLength} or more characters"; valid = false; } else if (name.Length > nameMaxLenth) { ViewBag.nameError = $"Name can not contain more than {nameMaxLenth} characters"; valid = false; } if (!string.IsNullOrWhiteSpace(birth)) { try { if (DateTime.Now.Year - DateTime.Parse(birth).Year < 18) { ViewBag.birthError = "Users with age less than 18 can not register"; valid = false; } } catch (Exception) { ViewBag.birthError = "Birthday does not match the format. Ex: 5-8-2017 (5 August 2017)"; valid = false; } } else { ViewBag.birthError = "Birth date is a required field"; valid = false; } if (!string.IsNullOrWhiteSpace(phone)) { if (phone.Length < phoneMinLength) { ViewBag.phoneError = $"Mobile phone must contain {phoneMinLength} or more characters"; valid = false; } else if (phone.Length > phoneMaxLength) { ViewBag.phoneError = $"Mobile phone can not contain more than {phoneMaxLength} characters"; valid = false; } } if (string.IsNullOrWhiteSpace(address)) { ViewBag.addressError = $"Address is a required field"; valid = false; } else if (address.Length < addressMinLength) { ViewBag.addressError = $"Address must contain {addressMinLength} or more characters"; valid = false; } else if (address.Length > addressMaxLength) { ViewBag.addressError = $"Address can not contain more than {addressMaxLength} characters"; valid = false; } #endregion if (valid) { var user = new UserServiceReference.User { Username = username, Password = password, Name = name, Address = address, Email = email, Phone = phone, DateOfBirth = DateTime.Parse(birth), Gender = gender == "0" ? UserServiceReference.Gender.Male : UserServiceReference.Gender.Female, ZipId = int.Parse(zip), Coins = 0 }; try { wcfUserService.CreateUser(user); return(Redirect("/")); } catch (Exception e) { ViewBag.massError = e; return(View("Register")); } } else { ViewBag.zips = wcfZipService.GetAllZips(); ViewBag.selectedZipId = zipId; ViewBag.username = username; ViewBag.password = password; ViewBag.name = name; ViewBag.email = email; ViewBag.phone = phone; ViewBag.birthday = birth; ViewBag.zip = zip; ViewBag.address = address; ViewBag.gender = gender; return(View("Register")); } }
public System.Threading.Tasks.Task <bool> UpdateAsync(string id, UserServiceReference.User entity) { return(base.Channel.UpdateAsync(id, entity)); }
public System.Threading.Tasks.Task <UserServiceReference.User> AddAsync(UserServiceReference.User entity) { return(base.Channel.AddAsync(entity)); }