public void CreateAccount(string username, string password, string cPassword, string firstname, string lastname, RegistrationDataProvider registrationData) { registrationData.ResetData(); // Jei buvo paliktas bent vienas tuscias laukas, programa meta errora if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(cPassword) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(lastname)) { registrationData.emptyFields = true; } // Jei passwordai nevienodi programa meta errora else if (password != cPassword) { registrationData.passwordsDontMatch = true; } // Jei visi laukai irasyti ir slaptazodziai sutampa, tuomet programa i DB iraso naujo vartuotojo duomenis else { //Nusiskaitomos reikšmės iš textboxų user.UserName = username.Trim(); user.Password = password.Trim(); if (!CheckPassword(password.Trim())) { registrationData.passwordIsNotCorrect = true; return; } else { user.FirstName = firstname.Trim(); user.LastName = lastname.Trim(); //Pridedamas useris į DB SQLConnection.AddNewItem(user); } } }
public void Add(string bookName, string isbn13, string isbn10, string author, string genre, string publisher, string published, string listPrice, string coverLink, OnError <String> onError, OnSuccess onSucess) { string error = ""; BookItem book = new BookItem(); if (bookName.Length == 0) { error += "Book Name is mandatory field\n"; } book.Name = bookName; book.ISBN13 = isbn13; if (!CheckExtension.CheckISBN13(isbn13)) { error += "Wrong ISBN-13 Code. No spaces, letters, punctuations. ISBN must have 13 numbers\n"; } book.ISBN10 = isbn10; if (!CheckExtension.CheckISBN10(isbn10)) { error += "Wrong ISBN-10 Code. No spaces, letters, punctuations. ISBN must have 10 numbers\n"; } if (author.Length == 0) { error += "Author is mandatory field\n"; } book.Author = author; if (genre.Length == 0) { error += "Genre is mandatory field\n"; } book.Genre = genre; book.Publisher = publisher; if (!CheckExtension.CheckPublished(published)) { error += "Wrong Published Date format. Example: 2018\n"; } else { book.Published = int.Parse(published); } if (!CheckExtension.CheckListPrice(listPrice)) { error += "Wrong ListPrice format\n"; } else { double.TryParse(listPrice, out double x); book.ListPrice = x; } book.CoverLink = coverLink; if (error.Length == 0) { SQLConnection.AddNewItem(book); onSucess(); } else { onError(error); } }