public ActionResult VerifyReseracher(VerifyResearcherModel verifyResearcherModel) { IUserHandler ush = new UserHandler(new bachelordbContext()); if (ModelState.IsValid) { try { DbStatus verifyResearcherStatus = ush.VerifyResearcherDB(verifyResearcherModel.researcherID); if (verifyResearcherStatus.success) { return(RedirectToAction("Index", "VerifyResearcher")); } else { ModelState.AddModelError("researcherID", verifyResearcherStatus.errormessage); } } catch (Exception) { throw; } } VerifyResearcherHelper verifyResearcherHelper = new VerifyResearcherHelper(); verifyResearcherModel = verifyResearcherHelper.CreateVerifyResearcherModel(); return(View("VerifyResearcher", verifyResearcherModel)); }
public ActionResult UnverifyResearcher(VerifyResearcherModel verifyResearcherModel) { IUserHandler ush = new UserHandler(new bachelordbContext()); if (ModelState.IsValid) { try { DbStatus unverifyResearcherStatus = ush.UnverifyResearcherDB(verifyResearcherModel.researcherID); if (unverifyResearcherStatus.success) { return(RedirectToAction("Index", "VerifyResearcher")); } else { ModelState.AddModelError("researcherID", unverifyResearcherStatus.errormessage); } } catch (Exception) { throw; } } verifyResearcherModel.UnverifiedResearchers = ush.GetUnverifiedResearchersDB(); verifyResearcherModel.AllResearchers = ush.GetAllVerifiedResearchersDB(); return(View("VerifyResearcher", verifyResearcherModel)); }
private async void YesButton_Click(object sender, RoutedEventArgs e) { Doctor doctor = Mapping.Mapper.Map <Doctor>(doctorViewModel); DbStatus status = await doctorService.Delete(doctor); this.Close(); }
public async Task <IActionResult> RetrieveResearcher(RetrieveModel loginModel) { if (ModelState.IsValid) { IRetrieveAccountHandler retrieveAccountHandler = new RetrieveAccountHandler(new bachelordbContext()); DbStatus status = retrieveAccountHandler.VerifyResearcherDB(loginModel.Email); if (status.success) { //ResetPassword. IManageProfileHandler mph = new ManageProfileHandler(new bachelordbContext()); var oldPassword = status.researcher.Password; status.researcher.Password = SecureString.RandomString(6); var changePasswordStatus = mph.ChangePasswordResearcherDB(status.researcher, oldPassword); //Sending the email EmailHelper emailh = new EmailHelper(); await emailh.RetrieveAccount(status.researcher.Email, status.researcher.Password); return(RedirectToAction("Researcher", "Welcome")); } else { var err = status.errormessage; this.ModelState.AddModelError("Email", err.ToString()); } } return(View("Researcher")); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(NameBox.Text)) { ShowMessage("Name is required!", "Error"); } else { Category updatedCategory = new Category() { Name = NameBox.Text, IdCategory = category.IdCategory }; DbStatus status = await categoryService.Update(updatedCategory); if (status == DbStatus.NOT_FOUND) { ShowMessage("Not found!", "Error"); } else if (status == DbStatus.EXISTS) { ShowMessage("Already exists!", "Error"); } else { ShowMessage("Successfully updated!", "Success"); this.Close(); } } }
public DbStatus LoginAdmin(string email, string password) { DbStatus status = new DbStatus(); Admin Admin = _context.admin.FirstOrDefault(admin => admin.Email == email); if (Admin != null) { if (Admin.Password == password) { //Successfull login status.success = true; status.adminuser = Admin; } else { //Wrong password status.errormessage = "Wrong password"; } } else { //No participant with this email exists in database status.errormessage = "No user with this email exists"; } return(status); }
private async void YesButton_Click(object sender, RoutedEventArgs e) { DbStatus status = await doctorService.Delete(Mapping.Mapper.Map <Doctor>(doctorViewModel)); OperationStatus = StatusHandler.Handle(OperationType.Delete, status); Close(); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { MedicalRecord medicalRecord = new MedicalRecord() { Name = NameBox.Text, LastName = LastNameBox.Text, BirthDate = BirthDatePicker.SelectedDate.Value, BirthPlace = BirthPlaceBox.Text, FathersFullName = FathersNameBox.Text, MothersFullName = MothersNameBox.Text, FathersProfession = FathersProfessionBox.Text, MothersProfession = MothersProfessionBox.Text, Gender = (sbyte)(MaleCheckBox.IsChecked.Value ? 0 : 1), MarriageStatus = (sbyte)(MarriedCheckBox.IsChecked.Value ? 0 : 1), Jmb = JmbBox.Text, InsuranceNumber = InsuranceNumberBox.Text, IdResidence = ((PlaceViewModel)(ResidancePlaceComboBox.SelectedItem)).IdPlace }; DbStatus status = await medicalRecordService.Add(medicalRecord); if (status == DbStatus.SUCCESS) { WindowHelper.WriteMessage(language.AddingSuccess, MessageLabel, true); } else if (status == DbStatus.EXISTS) { WindowHelper.WriteMessage(language.EntityExists, MessageLabel, false); } else if (status == DbStatus.DATABASE_ERROR) { WindowHelper.WriteMessage(language.DatabaseError, MessageLabel, false); } SaveButton.IsEnabled = false; }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (!AreSamePasswords()) { FieldValidation.WriteMessage(ErrorLabel, language.PasswordsDontMatch); return; } if (IsValidForm()) { LocalAccount localAccount = new LocalAccount() { IdLocalAccount = localAccountViewModel.IdLocalAccount, FullName = FullNameBox.Text, Email = EmailBox.Text, PasswordHash = PasswordBox.Password, }; ObservableCollection <RoleViewModel> roles = RolesComboBox.SelectedItems as ObservableCollection <RoleViewModel>; localAccount.SetRoles(roles.Select(x => Mapping.Mapper.Map <Role>(x)).ToList()); DbStatus status = await localAccountService.Update(localAccount); OperationStatus = StatusHandler.Handle(OperationType.Edit, status); Close(); } else { FieldValidation.WriteMessage(ErrorLabel, language.SelectValues); } }
private async void YesButton_Click(object sender, RoutedEventArgs e) { LocalAccount localAccount = Mapping.Mapper.Map <LocalAccount>(localAccountViewModel); DbStatus status = await localAccountService.Delete(localAccount); this.Close(); }
public ActionResult RemoveParticipant(ManageParticipantModel mpModel) { IManageParticipantHandler mph = new ManageParticipantHandler(new bachelordbContext()); if (ModelState.IsValid) { try { DbStatus manageParticipantStatus = mph.RemoveParticipantFromStudyDB(mpModel.participantID, mpModel.studyID); if (manageParticipantStatus.success) { return(RedirectToAction("ManageParticipants", "ManageParticipants", new { studyID = mpModel.studyID, studyName = mpModel.nameOfStudy })); } else { ModelState.AddModelError("ParticipantID", manageParticipantStatus.errormessage); } } catch (Exception) { throw; } } mpModel.participants = mph.GetParticipantsInStudyDB(mpModel.studyID); return(View("ManageParticipants", mpModel)); }
private async void SubmitButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(NameBox.Text)) { ShowMessage("Name is required!", "Error"); } else { Category category = new Category() { Name = NameBox.Text }; DbStatus status = await categoryService.Add(category); if (status == DbStatus.EXISTS) { ShowMessage("Already exists!", "Error"); } else { ShowMessage("Successfully added!", "Success"); this.Close(); } } }
public void ChangePassword_Invalid_Old_Password() { //Arrange uut = new ManageProfileHandler(mockContext.Object); Participant participant = new Participant { Email = "*****@*****.**", Age = DateTime.Now.Date, English = true, Gender = true, IdParticipant = 0, Password = "******", }; string oldPassword = "******"; //Act DbStatus status = uut.ChangePasswordParticipantDB(participant, oldPassword); Participant newParticipant = mockContext.Object.Participant.FirstOrDefault(part => part.IdParticipant == participant.IdParticipant); //Assert Assert.That(newParticipant.Password != participant.Password); Assert.That(status.success == false); Assert.That(status.errormessage == "The old password was incorrect. Please try again"); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { Clinic clinic = new Clinic() { Name = NameBox.Text, IdPlace = ((PlaceViewModel)PlaceComboBox.SelectedItem).IdPlace }; DbStatus status = await clinicService.Add(clinic); if (status == DbStatus.SUCCESS) { WindowHelper.WriteMessage(language.AddingSuccess, MessageLabel, true); } else if (status == DbStatus.EXISTS) { WindowHelper.WriteMessage(language.EntityExists, MessageLabel, false); } else if (status == DbStatus.DATABASE_ERROR) { WindowHelper.WriteMessage(language.DatabaseError, MessageLabel, false); } SaveButton.IsEnabled = false; }
public async Task <DbStatus> Update(Event entity) { try { Event existingEvent = await GetByPrimaryKey(entity); if (existingEvent == null) { return(DbStatus.NOT_FOUND); } Event eventWithSameUniqueAtributes = await GetByUniqueIdentifiers(new string[] { "Name", "ScheduledOn", "IdAddress", "IdCity" }, entity); if (eventWithSameUniqueAtributes != null) { return(DbStatus.EXISTS); } DbCommand <Event> updateCommand = new UpdateCommand <Event>(); DbStatus status = await ServiceHelper <Event> .ExecuteCRUDCommand(updateCommand, entity); return(status); } catch (Exception) { return(DbStatus.DATABASE_ERROR); } }
private async void YesButton_Click(object sender, RoutedEventArgs e) { DbStatus status = await medicalTitleService.Delete(Mapping.Mapper.Map <MedicalTitle>(medicalTitle)); OperationStatus = StatusHandler.Handle(OperationType.Delete, status); Close(); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { Place place = new Place() { IdPlace = placeViewModel.IdPlace, Name = NameBox.Text, CountryName = CountryNameBox.Text, PostalCode = PostalCodeBox.Text, FoodQuality = (int)FoodQualityComboBox.SelectedItem, AirQuality = (int)AirQualityComboBox.SelectedItem, DrinkingWaterQuality = (int)DrinkingWaterComboBox.SelectedItem, RecreationalWaterQuality = (int)RecreationalWaterComboBox.SelectedItem, TerrainQuality = (int)TerrainQualityComboBox.SelectedItem, InlandWaterQuality = (int)InlandWaterQualityComboBox.SelectedItem, MedicalVasteInformation = (int)MedicalVasteComboBox.SelectedItem, NoiseInformation = (int)NoiseInformationComboBox.SelectedItem, Radiation = (int)RadiationComboBox.SelectedItem }; DbStatus status = await placeService.Update(place); if (status == DbStatus.SUCCESS) { WindowHelper.WriteMessage(language.UpdatingSuccess, MessageLabel, true); } else if (status == DbStatus.NOT_FOUND) { WindowHelper.WriteMessage(language.EntityExists, MessageLabel, false); } else if (status == DbStatus.DATABASE_ERROR) { WindowHelper.WriteMessage(language.DatabaseError, MessageLabel, false); } SaveButton.IsEnabled = false; }
private async void YesButton_Click(object sender, RoutedEventArgs e) { DbStatus status = await localAccountService.Delete(Mapping.Mapper.Map <LocalAccount>(localAccountViewModel)); OperationStatus = StatusHandler.Handle(OperationType.Delete, status); Close(); }
protected void ctlDelete_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow row in ctlStatusGrid.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked)) { try { short id = UIHelper.ParseShort(ctlStatusGrid.DataKeys[row.RowIndex].Value.ToString()); DbStatus status = DbStatusService.FindByIdentity(id); DbStatusService.Delete(status); } catch (Exception ex) { if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData", "alert('This data is now in use.');", true); ctlStatusGrid.DataCountAndBind(); } } } } StatusLangGridViewFinish(); ctlStatusGrid.DataCountAndBind(); ctlUpdatePanelGridView.Update(); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { LocalAccount localAccount = new LocalAccount() { FullName = FullNameBox.Text, Email = EmailBox.Text, PasswordHash = PasswordBox.Password, IdLocalAccount = localAccountViewModel.IdLocalAccount }; ObservableCollection <RoleViewModel> roles = selectedItems.SelectedItems as ObservableCollection <RoleViewModel>; localAccount.SetRoles(roles.Select(x => Mapping.Mapper.Map <Role>(x)).ToList()); DbStatus status = await localAccountService.Update(localAccount); if (status == DbStatus.SUCCESS) { WindowHelper.WriteMessage(language.UpdatingSuccess, MessageLabel, true); } else if (status == DbStatus.NOT_FOUND) { WindowHelper.WriteMessage(language.EntityNotFound, MessageLabel, false); } else { WindowHelper.WriteMessage(language.DatabaseError, MessageLabel, false); } }
private async void YesButton_Click(object sender, RoutedEventArgs e) { MedicalRecord medicalRecord = Mapping.Mapper.Map <MedicalRecord>(medicalRecordViewModel); DbStatus status = await medicalRecordService.Delete(medicalRecord); this.Close(); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (FormIsValid()) { Place place = new Place() { Name = NameBox.Text, CountryName = CountryNameBox.Text, PostalCode = PostalCodeBox.Text, FoodQuality = (int)FoodQualityComboBox.SelectedItem, AirQuality = (int)AirQualityComboBox.SelectedItem, DrinkingWaterQuality = (int)DrinkingWaterComboBox.SelectedItem, RecreationalWaterQuality = (int)RecreationalWaterComboBox.SelectedItem, TerrainQuality = (int)TerrainQualityComboBox.SelectedItem, InlandWaterQuality = (int)InlandWaterQualityComboBox.SelectedItem, MedicalVasteInformation = (int)MedicalVasteComboBox.SelectedItem, NoiseInformation = (int)NoiseInformationComboBox.SelectedItem, Radiation = (int)RadiationComboBox.SelectedItem }; DbStatus status = await placeService.Add(place); OperationStatus = StatusHandler.Handle(OperationType.Create, status); Close(); } else { FieldValidation.WriteMessage(ErrorLabel, language.SelectValues); } }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (FormIsValid()) { MedicalRecord medicalRecord = new MedicalRecord() { IdMedicalRecord = medicalRecordViewModel.IdMedicalRecord, Name = FirstNameBox.Text, LastName = LastNameBox.Text, BirthDate = BirthDatePicker.SelectedDate.Value, BirthPlace = BirthPlaceBox.Text, FathersFullName = FathersNameBox.Text, MothersFullName = MothersNameBox.Text, FathersProfession = FathersProfessionBox.Text, MothersProfession = MothersProfessionBox.Text, Gender = (sbyte)(MaleCheckBox.IsChecked.Value ? 0 : 1), MarriageStatus = (sbyte)(MarriedCheckBox.IsChecked.Value ? 0 : 1), Jmb = UNBBox.Text, InsuranceNumber = InsuranceNumberBox.Text, IdResidence = ((PlaceViewModel)ResidancePlaceComboBox.SelectedItem).IdPlace }; DbStatus status = await medicalRecordService.Update(medicalRecord); OperationStatus = StatusHandler.Handle(OperationType.Edit, status); Close(); } else { FieldValidation.WriteMessage(ErrorLabel, language.SelectValues); } }
public async Task <DbStatus> Add(Address entity) { // Execute insert command in table Address DbCommand <Address> insertCommand = new InsertCommand <Address>(); DbStatus statusOfExecution = await ServiceHelper <Address> .ExecuteCRUDCommand(insertCommand, entity); return(statusOfExecution); }
public DbManager(ForumsRepository repository, TaskManager taskManager) { status = DbStatus.Initilizing; required_threads = Config.ThreadsBeforeWrite; this.repository = repository; this.taskManager = taskManager; timer = new Timer(Poll, null, timeout, Timeout.Infinite); }
/// <summary> /// 阻塞式停止数据库,等待数据库调用队列清空 /// </summary> /// <remarks>本方法不检查数据库回调队列,调用前应确保不再使用本数据库</remarks> public void Stop() { while (!IsWorkItemEmpty) { Thread.Sleep(100); } m_Status = DbStatus.Stoped; }
/// <summary> /// Returns database status response. /// </summary> /// <typeparam name="T">The type in context.</typeparam> /// <param name="status">Current response status.</param> /// <returns>Status Data information.</returns> public static StatusData <T> GetStatusData <T>(this DbStatus status) { var response = new StatusData <T> { Status = (SystemDbStatus)status.DbStatusCode, SubStatus = status.DbSubStatusCode, Message = status.DbStatusMsg }; return(response); }
private static OperationStatus HandleDeleteOperation(DbStatus status) { switch (status) { case DbStatus.SUCCESS: return(new OperationStatus(language.DeletingSuccess, AlertType.Success)); case DbStatus.NOT_FOUND: return(new OperationStatus(language.EntityNotFound, AlertType.Error)); case DbStatus.DATABASE_ERROR: return(new OperationStatus(language.DatabaseError, AlertType.Error)); default: return(new OperationStatus(language.DatabaseError, AlertType.Error)); } }
private static OperationStatus HandleCreateOperation(DbStatus status) { switch (status) { case DbStatus.SUCCESS: return(new OperationStatus(language.AddingSuccess, AlertType.Success)); case DbStatus.EXISTS: return(new OperationStatus(language.EntityExists, AlertType.Error)); case DbStatus.DATABASE_ERROR: return(new OperationStatus(language.DatabaseError, AlertType.Error)); default: return(new OperationStatus(language.DatabaseError, AlertType.Error)); } }
public static OperationStatus Handle(OperationType operation, DbStatus status) { switch (operation) { case OperationType.Create: return(HandleCreateOperation(status)); case OperationType.Edit: return(HandleEditOperation(status)); case OperationType.Delete: return(HandleDeleteOperation(status)); default: return(new OperationStatus(string.Empty, AlertType.Error)); } }
private static string DatabaseStatusToString(DbStatus dbStatus) { switch (dbStatus) { case DbStatus.Invalid: return Properties.Resources.DatabaseStatus_Invalid; case DbStatus.NotAvailable: return Properties.Resources.DatabaseStatus_NotAvailable; case DbStatus.NotExists: return Properties.Resources.DatabaseStatus_NotExists; case DbStatus.Ok: return Properties.Resources.DatabaseStatus_OK; case DbStatus.Unknown: return Properties.Resources.DatabaseStatus_Unknown; case DbStatus.Outdated: return Properties.Resources.DatabaseStatus_Outdated; case DbStatus.NoSchema: return Properties.Resources.DatabaseStatus_NoSchema; default: throw new ArgumentOutOfRangeException("dbStatus"); } }