public string Create([FromForm] FormUserObject form) { bool everyThingIsFilledIn = false; bool Emailexist = true; WPLClassLibTeam02.Entity.User user = new WPLClassLibTeam02.Entity.User(); user.voornaam = form.FirstName; user.naam = form.LastName; user.emailadres = form.Email; user.adres = form.Adress; int postcode = 0; int.TryParse(form.PostalCode, out postcode); user.postcode = postcode; user.country = form.Country; user.password = form.Password; if (user.naam == null || user.voornaam == null || user.emailadres == null || user.adres == null || user.postcode == 0 || user.country == null || user.password == null) { } else { everyThingIsFilledIn = true; user.password = EncryptionTool.Crypt(user.password); var dt = EntityData.User.GetEmail(user.emailadres); if (dt.Rows.Count > 0) { string email2 = dt.Rows[0][0].ToString(); if (user.emailadres.Equals(email2)) { Emailexist = true; } } else { EntityData.User.Insert(user); Emailexist = false; } } string JsonString = string.Empty; bool[] array = new bool[2]; array[0] = everyThingIsFilledIn; array[1] = Emailexist; JsonString = JsonConvert.SerializeObject(array); return(JsonString); }
public string Put([FromForm] FormEditObject form) { bool editSucces = false; bool emailExist = false; bool[] array = new bool[2]; string JsonString = string.Empty; string oldemail = form.oldemail; int postcode = 0; int.TryParse(form.postcode, out postcode); User user = new User(form.email, form.password, form.naam, form.voornaam, form.country, form.adres, postcode); user.password = EncryptionTool.Crypt(user.password); //kijken of veld leeg is if (user.naam == null || user.voornaam == null || user.emailadres == null || user.adres == null || user.postcode == 0 || user.country == null || user.password == null) { } else { editSucces = true; var dt = EntityData.User.GetEmail(user.emailadres); //kijken of email al bestaat if (dt.Rows.Count > 0) { string email2 = dt.Rows[0][0].ToString(); if (user.emailadres.Equals(email2)) { emailExist = true; } } else { emailExist = false; EntityData.Edit.Update(user, oldemail); } } //bools returnen array[0] = editSucces; array[1] = emailExist; JsonString = JsonConvert.SerializeObject(array); return(JsonString); }
public String Post([FromForm] FormLoginObject form) { string email = form.email; string password1 = form.password; password1 = EncryptionTool.Crypt(password1); var dt = EntityData.User.GetPassword(email); bool result = false; //kijken of email bestaat en zoja, of geëncrypteerde wachtwoorden matchen if (dt.Rows.Count > 0) { string password2 = dt.Rows[0][0].ToString(); if (password1.Equals(password2)) { result = true; } } return(JsonConvert.SerializeObject(result)); }