public FormTransaction(Client pCurrentClient, Transaction pTransaction, UserTagViewModel pUserTagViewModel) { InitializeComponent(); _currentClient = pCurrentClient; _transaction = pTransaction; _userTagId = pUserTagViewModel.UserTagId; }
//===================\\ // The functions \\ //===================\\ #region Functions //checks if the entered nuid exists private async void nuidValidation(String pNuid) { _httpRequest = new HttpRequest("UserTagItems", pNuid); ReturnObject returnedObject = await HttpRequest.GetUserTagAsync(_httpRequest.createUrl()); _userTagView = returnedObject.ReturnUserTag; if (returnedObject.StatusCode == 3)//if pass does not exist { //the new client UserTag newUserTag = new UserTag { PassId = pNuid }; Client newClient = new Client(); _currentClient = newClient; //opens a new form to add the new user using (SetClientDialogBox clientForm = new SetClientDialogBox(_currentClient, newUserTag)) { //opens a new form to add the new client to the database if (clientForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { myPort.WriteLine("R"); } } } else if (returnedObject.StatusCode == 0)//if the pass exists and is not blocked { _httpRequest = new HttpRequest("ClientItems", _userTagView.UserTagId.ToString()); _currentClient = await HttpRequest.GetClientAsync(_httpRequest.createUrl()); //sends command to arduino to read the keypad myPort.WriteLine("P"); _loggedOut = false; //update the shown text on screen updateText(_currentClient); } else if (returnedObject.StatusCode == 2)//the user pass is blocked { //error, pass is blocked Helper.showMessage("Helaas, Uw pas is geblokkeerd", MessageBoxIcon.Error); myPort.WriteLine("R"); } //update the form if (_currentClient != null) { UpdateForm(_currentClient); } }
public IActionResult Question(int questionId, string title) { int lintUserId = HttpContext.Session.GetInt32("UserId") ?? 0; QuestionViewModel questionViewModel = new QuestionViewModel(); using (var unitOfWork = new UnitOfWork(new CuriousDriveContext())) { Question question = unitOfWork.Questions.GetQuestionDetails(questionId); questionViewModel.questionId = question.QuestionId; questionViewModel.questionTitle = question.QuestionTitle; questionViewModel.questionHtml = question.QuestionHtml; questionViewModel.createdDate = question.CreatedDate; questionViewModel.userDetailsViewModel = new UserDetailsViewModel(); questionViewModel.userDetailsViewModel.userId = question.User.UserId; questionViewModel.userDetailsViewModel.displayName = question.User.DisplayName; questionViewModel.userDetailsViewModel.urlTitle = Utility.GetURLTitle(question.User.DisplayName); questionViewModel.userDetailsViewModel.profilePictureViewModel = new ProfilePictureViewModel(); questionViewModel.userTagListViewModel = new List <UserTagViewModel>(); foreach (Tag tag in question.Tag) { foreach (TagDetail tagDetail in tag.TagDetail) { UserTagViewModel userTagViewModel = new UserTagViewModel(); userTagViewModel.userId = tagDetail.TaggedUser.UserId; userTagViewModel.userTag = tagDetail.TaggedUser.DisplayName; questionViewModel.userTagListViewModel.Add(userTagViewModel); } } questionViewModel.commentsViewModel = new List <CommentViewModel>(); foreach (Comment comment in question.Comment) { CommentViewModel commentViewModel = new CommentViewModel(); commentViewModel.commentId = comment.CommentId; commentViewModel.commentHtml = comment.CommentHtml; commentViewModel.userId = comment.User.UserId; commentViewModel.displayName = comment.User.DisplayName; commentViewModel.urlTitle = Utility.GetURLTitle(comment.User.DisplayName); questionViewModel.commentsViewModel.Add(commentViewModel); } questionViewModel.questionAnswersViewModel = new List <QuestionAnswerViewModel>(); foreach (QuestionAnswer questionAnswer in question.QuestionAnswer) { QuestionAnswerViewModel questionAnswerViewModel = new QuestionAnswerViewModel(); questionAnswerViewModel.questionId = question.QuestionId; questionAnswerViewModel.questionAnswerId = questionAnswer.QuestionAnswerId; questionAnswerViewModel.answerHtml = questionAnswer.AnswerHtml; questionAnswerViewModel.createdDate = questionAnswer.CreatedDate; questionAnswerViewModel.commentsViewModel = new List <CommentViewModel>(); foreach (Comment comment in questionAnswer.Comment) { CommentViewModel commentViewModel = new CommentViewModel(); commentViewModel.commentId = comment.CommentId; commentViewModel.commentHtml = comment.CommentHtml; commentViewModel.userId = comment.User.UserId; commentViewModel.displayName = comment.User.DisplayName; commentViewModel.urlTitle = Utility.GetURLTitle(comment.User.DisplayName); questionAnswerViewModel.commentsViewModel.Add(commentViewModel); } questionAnswerViewModel.userDetailsViewModel = new UserDetailsViewModel(); questionAnswerViewModel.userDetailsViewModel.userId = questionAnswer.UserId; questionAnswerViewModel.userDetailsViewModel.displayName = questionAnswer.User.DisplayName; questionAnswerViewModel.userDetailsViewModel.urlTitle = Utility.GetURLTitle(questionAnswer.User.DisplayName); questionAnswerViewModel.userDetailsViewModel.profilePictureViewModel = new ProfilePictureViewModel(); questionViewModel.questionAnswersViewModel.Add(questionAnswerViewModel); } questionViewModel.questionClassesViewModel = new List <QuestionClassViewModel>(); foreach (QuestionClass questionClass in question.QuestionClass) { QuestionClassViewModel questionClassViewModel = new QuestionClassViewModel(); questionClassViewModel.classId = questionClass.ClassId; questionClassViewModel.className = questionClass.Class.ClassName; questionViewModel.questionClassesViewModel.Add(questionClassViewModel); } } return(View(questionViewModel)); }
private async void btnOk_Click(object sender, EventArgs e) { Boolean validInput = false; checkInput = new CheckValidUserInput(_currentClient); if (!string.IsNullOrWhiteSpace(tbUserName.Text) && !string.IsNullOrWhiteSpace(tbUserPassword.Text)) { if (tbUserPassword.Text.Length == 4) { validInput = true; } } else { validInput = false; } validInput = checkInput.validInput(tbUserPassword.Text, validInput); if (validInput && checkInput.validUserInput) { HttpRequest httpRequest; username = tbUserName.Text; password = new string(checkInput.checkInput); password = password.Replace("\n", ""); password = password.Replace("\r", ""); //create a new usertag _newUserId.Password = password; httpRequest = new HttpRequest("UserTagItems"); Object response = await HttpRequest.CreateAsync(_newUserId, httpRequest.createUrl()); //get the new usertag httpRequest = new HttpRequest("UserTagItems", _newUserId.PassId); ReturnObject returnedObject = await HttpRequest.GetUserTagAsync(httpRequest.createUrl()); UserTagViewModel createdUser = returnedObject.ReturnUserTag; //create a new user, and link the user and the usertag with the usertagId _currentClient.Name = username; _currentClient.UserTagId = createdUser.UserTagId; httpRequest = new HttpRequest("ClientItems"); response = await HttpRequest.CreateAsync(_currentClient, httpRequest.createUrl()); Helper.showMessage("U bent succesvol toegevoegd."); this.DialogResult = DialogResult.OK; this.Close(); } else { if (!validInput) { if (!checkInput.validUserInput && checkInput.inputLength == 4) { Helper.showMessage("Uw wachtwoord mag alleen bestaan uit: '0, 1, 2, 3, 4, 5, 6, 7, 8, 9' ", MessageBoxIcon.Error); } else if (checkInput.inputLength < 4 || checkInput.inputLength > 4) { Helper.showMessage("Uw wachtwoord moet bestaan uit 4 karakters. U hebt er nu: " + checkInput.inputLength, MessageBoxIcon.Error); } else { Helper.showMessage("Gelieve AL de velden invullen.", MessageBoxIcon.Error); } } } }