private void btnCommit_Click(object sender, EventArgs e) { //【1】Checksum input //【2】Encapsulation objects Member objMember = new Member() { MemberId = lblMemberId.Text, MemberName = txtMemberName.Text.Trim(), MemberCardId = txtMemberCardId.Text.Trim(), MemberLevel = Convert.ToInt32(cboMemberLevel.SelectedValue), IdType = cboIdType.Text, IdNumber = txtIdCardNumber.Text.Trim(), Gender = rbMale.Checked == true ? "Male" : "Female", TelNo = txtTelNo.Text.Trim(), HomeAddress = txtHomeAddress.Text.Trim(), Birthday = Convert.ToDateTime(dtpBirthday.Text), CardStatus = cboCardStatus.Text, CardClosingDate = Convert.ToDateTime(dtpCardClosingDate.Text), PayMethod = cboPayMethod.Text, IsReturnDeposit = false, LoginId = Program.currentUser.LoginId, OperatingTime = DateTime.Now, ReMarks = txtRemarks.Text, }; //Picture if (pbCurrentImage.BackgroundImage == null) { objMember.MemberPhoto = null; } else { objMember.MemberPhoto = new Common.SerializeObjectToString().SerializeObject(pbCurrentImage.BackgroundImage); } //【3】Submit switch (actionFlag) { case 2: //Add try { if (objMemberServices.AddMember(objMember) == 1) { //Notice Successful! MessageBox.Show("Successful addition of membership information!", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); //Close Close(); //Back OK to main interface this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show("Failed to add member information! Specific reasons:" + ex.Message, "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case 3: //Modify try { if (objMemberServices.UpdateMember(objMember) == 1) { //Notice Successful! MessageBox.Show("Modify Information Successful", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); //Close Close(); //Back OK to main interface this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show("Failed to modify membership information! Specific reasons:" + ex.Message, "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } }
private string ProvisionRoles(IProvisioningModel model, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.AddMemberUrl = ApplicationResource.ActionAddMember; service.UserAgentVersion = ApplicationResource.UserAgent; try { foreach (MemberListViewItemModel item in model.Members.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.AddMember(new MemberData() { Email = item.Email, FirstName = item.FirstName, LastName = item.LastName, SendWelcomeEmail = model.SendWelcomeEmail, ProvisionStatus = item.ProvisionStatus, RoleName = model.SelectedRole }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { if (response.Message.Contains("success")) { item.ProvisionStatus = "Provisioned successfully."; presenter.UpdateProgressInfo(string.Format("Added Member: {0}: {1} {2}", item.Email, item.FirstName, item.LastName)); } if (response.Message.Contains("team_license_limit")) { item.ProvisionStatus = "Team is already full.The organization has no available licenses."; presenter.UpdateProgressInfo("Team is already full. The organization has no available licenses."); } if (response.Message.Contains("free_team_member_limit_reached")) { item.ProvisionStatus = "Team is already full. The free team member limit has been reached."; presenter.UpdateProgressInfo("Team is already full. The free team member limit has been reached."); } if (response.Message.Contains("user_already_on_team")) { item.ProvisionStatus = "User is already on this team. The provided email address is associated with a user who is already a member of (including in recoverable state) or invited to the team."; presenter.UpdateProgressInfo("User is already on this team. The provided email address is associated with a user who is already a member of (including in recoverable state) or invited to the team."); } if (response.Message.Contains("user_on_another_team")) { item.ProvisionStatus = "User is already on another team. The provided email address is associated with a user that is already a member or invited to another team."; presenter.UpdateProgressInfo("User is already on another team. The provided email address is associated with a user that is already a member or invited to another team."); } if (response.Message.Contains("user_already_paired")) { item.ProvisionStatus = "User is already paired."; presenter.UpdateProgressInfo("User is already paired."); } if (response.Message.Contains("user_migration_failed")) { item.ProvisionStatus = "User migration has failed."; presenter.UpdateProgressInfo("User migration has failed."); } if (response.Message.Contains("duplicate_external_member_id")) { item.ProvisionStatus = "A user with the given external member ID already exists on the team (including in recoverable state)."; presenter.UpdateProgressInfo("A user with the given external member ID already exists on the team (including in recoverable state)."); } if (response.Message.Contains("user_creation_failed")) { item.ProvisionStatus = "User creation has failed."; presenter.UpdateProgressInfo("User creation has failed."); } }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_ADD_MEMBER; } } } catch (Exception) { // error message. SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_ADD_MEMBER, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } return errorMessage; }
public IActionResult Add(MemberVm memberVm) { int id = MemberServices.AddMember(memberVm.Member); return(RedirectToAction("Edit", "Member", new { @id = id })); }