/// <summary> /// 新增一筆會員 /// </summary> /// <param name="member"></param> public ExecuteResult createMember(MemberDTO member) { var entity = DataContext.Members.FirstOrDefault(x => x.UID == member.UID); if (entity == null) { try { DataContext.Members.Add(new Member() { Id = member.Id, Budget = member.Budget, UID = member.UID, CreDate = member.CreDate, Name = member.Name }); DataContext.SaveChanges(); return(new ExecuteResult() { Status = (char)Code.Y }); } catch { return(new ExecuteResult() { Status = (char)Code.N, ErrMsg = "資料異常" }); } } else { return(new ExecuteResult() { ErrMsg = "此帳號已被註冊過", Status = (char)Code.N }); } }
public MemberSubscriptions(MemberDTO member) { MemberSubscriptionViewModel.Errors = 0; InitializeComponent(); Messenger.Default.Send <MemberDTO>(member); Messenger.Reset(); }
public async Task WhenGetMemberAsyncCalled_UserIsMappedToMemberDtoAsync() { /* * * UNIT TESTING WITH DEPENDENCY INJECTION & API * * **/ // - - - ARRANGE - - - //create mock version of Interface (to fake dependency injection) var mockRepo = new Mock <IAppUserRepository>(); //Fake the return value of a Mock Dependency mockRepo.Setup(x => x.GetUser(It.IsAny <int>())).ReturnsAsync(fakeUser); //Initialize AutoMapper for Unit Tests (not faked/mocked) var config = new MapperConfiguration(x => x.AddProfile <AutoMapperProfile>()); //pass mocked interface to fake dependency injection var service = new AppUserService(mockRepo.Object, config.CreateMapper()); // - - - ACT - - - MemberDTO result = await service.GetMemberAsync(1); // - - - ASSERT - - - Assert.NotNull(result); Assert.AreEqual("faketown", result.City); }
public PervisitSubscriptions(MemberDTO pervisit) { PervisitSubscriptionViewModel.Errors = 0; InitializeComponent(); Messenger.Default.Send <MemberDTO>(pervisit); Messenger.Reset(); }
public bool AddMember(MemberDTO member) { string maQueQuan = member.getMaQueQuan().ToString(); string maLoaiQuanHe = member.getMaQuanHe().ToString(); string maNgheNghiep = member.getMaNgheNghiep().ToString(); string queryString = "INSERT INTO THANHVIEN(MAQUEQUAN, MALOAIQUANHE, MANGHENGHIEP, TENTHANHVIEN, THANHVIENCU, NGAYPHATSINH, GIOITINH, DIACHI, NGAYGIOSINH, TRANGTHAIMAT, DOI)" + "VALUES(" + maQueQuan + "," + maLoaiQuanHe + "," + maNgheNghiep + "," + "'" + member.getTenThanhVien() + "'," + "'" + member.getThanhVienCu() + "'," + "'" + DateTime.Now.ToString("yyyy/MM/dd") + "'," + member.getGioiTinh().ToString() + "," + "'" + member.getDiaChi().ToString() + "'," + "'" + member.getNgaySinh().ToString("yyyy/MM/dd") + "'," + member.getTrangThaiMat().ToString() + "," + member.getDoi().ToString() + ");"; Console.WriteLine(queryString); this.command.CommandText = queryString; try { this.command.ExecuteNonQuery(); }catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } return(true); }
public HttpResponseMessage Get(int id) { MemberDTO member = this.member.Get(id); member.ProfileImage = getImage(member.ProfileImage); return(Request.CreateResponse(HttpStatusCode.OK, member)); }
// GET: Article/Posts public ActionResult Posts(int?page) { List <ArticleVM> article; List <ArticleListVM> articleList = new List <ArticleListVM>(); var pageNum = page ?? 1; using (Db db = new Db()) { article = db.Articles.ToArray() .Select(x => new ArticleVM(x)).ToList(); foreach (var post in article) { MemberDTO member = db.Members.Where(x => x.UID == post.UID).FirstOrDefault(); articleList.Add(new ArticleListVM() { ArticleId = post.ArticleId, Title = post.Title, Author = member.Account, CreateTime = post.CreateTime, Watch = post.Watch }); } } var onePageOfPost = articleList.ToPagedList(pageNum, 10); ViewBag.OnePageOfPost = onePageOfPost; return(View(articleList)); }
private void txbId_TextChanged(object sender, EventArgs e) { string id = ""; id = txbId.Text.ToString(); MemberDTO memberDTO = MemberDAO.Instance.GetMembertById(id); if (memberDTO != null) { txbDisplayName.Text = memberDTO.FirstName + " " + memberDTO.LastName; if (memberDTO.Status == true) { txbStatus.Text = "Bình thường"; btnLogin.Enabled = true; } else { txbStatus.Text = "Đã bị khóa!"; } } else { txbDisplayName.Text = ""; txbStatus.Text = ""; } }
public IActionResult GetToken([FromBody] MemberDTO memberDTO) { var member = memberService.GetMember(memberDTO.Email, memberDTO.Password); if (member != null) { var createToken = HBAuthManager.GenerateToken(member.Firstname.ToString(), member.Id); var response = new AuthResponse { IsSuccess = true, Token = createToken, MemberId = member.Id, ExpiresOn = DateTime.UtcNow.AddDays(30), Message = "mesegge", ShowInfoBox = true }; return(Ok(response)); } return(Unauthorized()); }
private MemberDTO GetMemberUIData() { MemberDTO memberDto = new MemberDTO(); memberDto.MemberId = maskedTextBoxMemberId.Text.Trim(); memberDto.FullName = txtFullName.Text.Trim(); memberDto.FatherName = txtFatherName.Text.Trim(); memberDto.Address = txtAddress.Text.Trim(); memberDto.Mobile = maskedTextBoxmobilenumber.Text.Trim(); memberDto.Dob = dtDOB.Value; memberDto.MarriageDate = dtMaarriage.Value; memberDto.EducationQualification = txtQualification.Text.Trim(); if (pbMember.Image != null) { //MemoryStream ms1 = new MemoryStream(); //pbMember.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.Jpeg); //pbMember.Image.Save(appPath + @"\" + filename + ".jpg", ImageFormat.Jpeg); var memberImageName = AppHelper.GetMemberImageFullPathToSave() + memberDto.MemberId + "_" + memberDto.FullName + AppHelper.GetMemberImageExtensionForSave(); pbMember.Image.Save(memberImageName, ImageFormat.Jpeg); memberDto.ImageLocation = memberDto.MemberId + "_" + memberDto.FullName + AppHelper.GetMemberImageExtensionForSave(); } return(memberDto); }
//Create Customer public void CreateCustomer(Customer customer) { _logger.LogInformation($"Creating new customer"); _dbContext.Customer.Add(customer); if (customer.Member.MemberEmail.Any() && customer.Member.MemberPassword.Any()) { MemberDTO memberDTO = new MemberDTO() { CustomerEmail = customer.Member.MemberEmail, CustomerPassword = customer.Member.MemberPassword }; _dbContext.SaveChanges(); } if (customer.Location.Any()) { foreach (var location in customer.Location) { CustomerLocation customerLocation = new CustomerLocation { City = location.CityName, Address = location.AddressName }; _dbContext.SaveChanges(); } } }
public async Task <IActionResult> UpdateMemberV2([FromBody] MemberDTO memberDTO) { Debug.Assert(memberDTO.Id > 0); var member = await db.Members .Include(x => x.Payments).ThenInclude(x => x.PaymentNotes) .Include(x => x.Changes) .Include(x => x.MemberNotes) .SingleOrDefaultAsync(x => x.Id == memberDTO.Id); if (member != null) { var changes = member.FromDTO(memberDTO, User.Identity.Name); foreach (var c in changes) { var change = new Change { Date = c.Time, Member = member, MadeBy = c.By, Description = c.Description }; member.Changes.Add(change); } member.UpdatePaymentRecords(options, true); await db.SaveChangesAsync(); return(SuccessResult(member.Id)); } else { return(ErrorResult($"Member id {memberDTO.Id} not found")); } }
public async Task <IActionResult> CreateNewMemberV2([FromBody] MemberDTO nm) { var now = DateTimeOffset.Now; var member = new Member(); var changes = member.FromDTO(nm, User.Identity.Name); member.Zone = db.Zones.SingleOrDefault(z => z.Number == member.ZoneNumber); var newMemberChanges = changes.Where(x => x.RecordForNewMember); foreach (var c in newMemberChanges) { var change = new Change { Date = c.Time, Member = member, MadeBy = c.By, Description = c.Description }; member.Changes.Add(change); } member.Changes.Add(new Change { Date = now, Member = member, MadeBy = User.Identity.Name, Description = $"new member created" }); member.UpdatePaymentRecords(options, false); await db.Members.AddAsync(member); await db.SaveChangesAsync(); return(SuccessResult(member.Id)); }
private async void ModifyConfirm_Click(object sender, RoutedEventArgs e) { GameDTO game = (GameDTO)ModifyPickerGame.SelectedItem; List <Control> controls = new List <Control> { ModifyGameDate }; if (!ValidateGame(controls, ModifyError)) { return; } MemberDTO member = (MemberDTO)ModifyPickerMember.SelectedItem; LeagueDTO league = (LeagueDTO)ModifyPickerLeague.SelectedItem; game.MemberId = member.Id; game.LeagueId = league.Id; game.Date = (DateTime)ModifyGameDate.SelectedDate; await gamesProcessor.Update(game); ModifyPickerGame.SelectedIndex = 0; MessageBox.Show("De wedstrijd werd aangepast.", "Succes"); }
private void SelectResults(bool allResults) { if (allResults) { SelectResultPicker.IsEnabled = false; FillResultOverview(results); } else { MemberDTO member = (MemberDTO)SelectResultPicker.SelectedItem; List <GameDTO> gamesWithMember = games.FindAll(game => game.MemberId == member.Id); List <ResultDTO> resultsWithMember = new List <ResultDTO>(); foreach (GameDTO game in gamesWithMember) { if (results.Exists(result => result.GameId == game.Id)) { resultsWithMember.Add(results.Find(result => result.GameId == game.Id)); } } SelectResultPicker.IsEnabled = true; FillResultOverview(resultsWithMember); } ResetFilters(2); }
public string Validate(MemberDTO member) { if (null == member) { return(GenericMessages.ObjectIsNull); } if (member.Address == null) { return("Address " + GenericMessages.ObjectIsNull); } if (String.IsNullOrEmpty(member.DisplayName)) { return(member.DisplayName + " " + GenericMessages.StringIsNullOrEmpty); } if (member.DisplayName.Length > 255) { return(member.DisplayName + " can not be more than 255 characters "); } if (!string.IsNullOrEmpty(member.Number) && member.Number.Length > 50) { return(member.Number + " can not be more than 50 characters "); } return(string.Empty); }
public Member InsertMember(MemberDTO dto, string user, string id) { try { var member = new Member() { Birthdate = dto.Birthdate, CreatedBy = user, CreatedDateTime = _member.GetCurrentDate(), FirstName = dto.FirstName, Id = id, MemberTypeId = dto.MemberTypeId, MiddleName = dto.MiddleName, PhoneNumber = dto.PhoneNumber, UserName = dto.UserName, LastName = dto.LastName }; _member.Insert(member); _member.SaveChanges(); return(member); } catch (Exception e) { return(null); } }
public string Disable(MemberDTO member) { //if (_unitOfWork.Repository<DeliveryHeaderDTO>().Query().Get().Any(i => i.MemberId == Member.Id) || // _unitOfWork.Repository<DocumentDTO>().Query().Get().Any(i => i.MemberId == Member.Id)) //{ // return "Can't delete the item, it is already in use..."; //} if (member == null) { return(GenericMessages.ObjectIsNull); } string stat; try { _memberRepository.Update(member); _unitOfWork.Commit(); stat = string.Empty; } catch (Exception exception) { stat = exception.Message; } return(stat); }
public bool ObjectExists(MemberDTO member) { var objectExists = false; var iDbContext = DbContextUtil.GetDbContextInstance(); try { var memRepository = new Repository <MemberDTO>(iDbContext); var catExists = memRepository .Query() .Include(a => a.Address) .Filter(bp => (bp.Number == member.Number || bp.Address.Mobile == member.Address.Mobile) && bp.Id != member.Id) .Get() .FirstOrDefault(); if (catExists != null) { objectExists = true; } } finally { iDbContext.Dispose(); } return(objectExists); }
private async void AddConfirm_Click(object sender, RoutedEventArgs e) { List <Control> controls = new List <Control> { AddFineNr, AddHandoutDate }; if (!ValidateFine(controls, AddError)) { return; } MemberDTO member = (MemberDTO)AddPicker.SelectedItem; FineDTO fine = new FineDTO() { FineNumber = int.Parse(AddFineNr.Text), MemberId = member.Id, Amount = ConvertToDecimal(AddAmount.Text), HandoutDate = (DateTime)AddHandoutDate.SelectedDate, PaymentDate = GetPayoutDate(AddPaymentDate) }; await finesProcessor.Add(fine); controls.Add(AddPaymentDate); controls.Add(AddAmount); ClearFields(controls); MessageBox.Show("De boete werd toegevoegd.", "Succes"); }
public string InsertOrUpdate(MemberDTO member) { try { var validate = Validate(member); if (!string.IsNullOrEmpty(validate)) { return(validate); } if (ObjectExists(member)) { return(GenericMessages.DatabaseErrorRecordAlreadyExists + Environment.NewLine + "With the same name exists"); } _memberRepository.InsertUpdate(member); _unitOfWork.Commit(); return(string.Empty); } catch (Exception exception) { return(exception.Message); } }
private async void OverviewMembers_SelectionChanged(object sender, SelectionChangedEventArgs e) { MemberView memberView = (MemberView)OverviewMembers.SelectedItem; if (memberView == null) { return; } MemberDTO member = members.Find(m => m.FederationNr == memberView.FederationNr); List <MemberRoleDTO> memberRoles = await memberRolesProcessor.GetAllRoles(member.Id); List <string> currentRoles = new List <string>(); List <string> ancientRoles = new List <string>(); foreach (MemberRoleDTO mr in memberRoles) { if (mr.EndDate == new DateTime(9999, 1, 1)) { RoleDTO role = roles.Find(role => role.Id == mr.RoleId); currentRoles.Add($"{role.Name} \t (vanaf {mr.StartDate.ToShortDateString()})"); } else { RoleDTO role = roles.Find(role => role.Id == mr.RoleId); ancientRoles.Add($"{role.Name} \t ({mr.StartDate.ToShortDateString()} - {mr.EndDate.ToShortDateString()})"); } } OverviewRoles.ItemsSource = currentRoles; OverviewHistory.ItemsSource = ancientRoles; }
public bool Insert(MemberDTO value) { Member val = new Member(); UserRequestStatus user = new UserRequestStatus(); val = mapper.MemberDTOToMember(value); val.CreatedOn = DateTime.Now; val.ModifiedOn = DateTime.Now; house.Insert(val); Member memberr = house.Find(member => member.Email == val.Email).ToList().First(); if (memberr.Email == "*****@*****.**") { user.RequestStatus = Shared_Layer.Enum.RequestStatus.Accepted; } else { user.RequestStatus = Shared_Layer.Enum.RequestStatus.Pending; } user.MemberID = memberr.MemberID; user.CreatedOn = DateTime.Now; user.ModifiedOn = DateTime.Now; userrep.Insert(user); return(true); }
public void ShowMembers() { bll = new MemberBLL(); if (!isSearch) { dto = bll.GetMembers(); } else { dto = bll.GetMembers(keyword); } dataGridView1.DataSource = dto.Members; dataGridView1.Columns["ID"].HeaderText = "編號"; dataGridView1.Columns["Name"].HeaderText = "姓名"; dataGridView1.Columns["GenderString"].HeaderText = "性別"; dataGridView1.Columns["Gender"].Visible = false; dataGridView1.Columns["Birthdate"].HeaderText = "生日"; dataGridView1.Columns["JoinDate"].HeaderText = "加入日期"; dataGridView1.Columns["Phone"].HeaderText = "電話"; dataGridView1.Columns["Status"].HeaderText = "狀態"; dataGridView1.Columns["StatusID"].Visible = false; dataGridView1.Columns["TaiwanID"].HeaderText = "身分證字號"; dataGridView1.Columns["IsAdmin"].HeaderText = "管理員"; dataGridView1.Columns["Password"].Visible = false; dataGridView1.Columns["ActivityLevelID"].Visible = false; dataGridView1.Columns["ActivityLevel"].HeaderText = "活動量"; dataGridView1.Columns["Height"].Visible = false; isSearch = false; }
public async Task SendRequestEmail(string text, Data.Enumerations.FeedbackType type, byte[] pdf = null) { MemberDTO user = MVC.Models.CompanyModel.createMemberDTO(Data.Entities.Members.GetMemberAt(MemberSession.GetMemberId())); //MemoryStream stream = new MemoryStream(pdf); var body = "<p>Feedback from: {0} ({1})</p><p>Type: {2}</p><p>Text: {3}</p>"; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); message.From = new MailAddress("*****@*****.**"); message.Subject = "Feedback"; message.Body = string.Format(body, user.Name + " " + user.Surname, user.Gmail.ToString(), type.ToString(), text); message.IsBodyHtml = true; //message.Attachments.Add(new Attachment(stream, "Request.pdf", System.Net.Mime.MediaTypeNames.Application.Pdf)); using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", Password = "******" }; smtp.Credentials = credential; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; await smtp.SendMailAsync(message); } }
private async void AddConfirm_Click(object sender, RoutedEventArgs e) { MemberDTO member = (MemberDTO)AddPickerMember.SelectedItem; LeagueDTO league = (LeagueDTO)AddPickerLeague.SelectedItem; List <Control> controls = new List <Control> { AddGameNr, AddGameDate }; if (!ValidateGame(controls, AddError)) { return; } GameDTO game = new GameDTO { GameNumber = AddGameNr.Text, MemberId = member.Id, LeagueId = league.Id, Date = (DateTime)AddGameDate.SelectedDate }; await gamesProcessor.Add(game); ClearFields(controls); AddPickerMember.SelectedIndex = 0; AddPickerLeague.SelectedIndex = 0; MessageBox.Show("De wedstrijd werd toegevoegd.", "Succes"); }
public async Task <ActionResult <MemberDTO> > Create(Guid channelId, [FromBody] CreateMemberDTO model) { //1)Channel laden via de channelrepository op basis van de channelId var channel = channelRepository.GetById(channelId); //2) valideren dat de currentUser de juiste rechten / rol heeft om een member toetevoegen via getCurrentUserAsync zit hij er niet in stuur Acces Denied terug //3) De rollen nakijken, zijn rol opvragen. Huidige rol van de user moet kleiner of groter zijn anders Acces Denied terug. //4)Indien true, member.FromCreateMemberDTO(channel,model); var member = uMessageAPI.Models.Member.FromCreateMemberDTO(channel, model); // Check whether the current channel was resolved. if (member.ChannelId == channelId) { // Create message and assign a name. memberRepository.Add(member); memberRepository.SaveChanges(); } // Check whether the channel was successfully created. if (member != null) { // Generate the channel response for given channel. return(Ok(MemberDTO.FromMember(member))); } return(NotFound()); }
protected void Application_AuthenticateRequest() { // Check if user is logged in if (User == null) { return; } // Get account string account = Context.User.Identity.Name; // Declare array of roles string[] roles = null; using (Db db = new Db()) { // Populate roles MemberDTO dto = db.Members.FirstOrDefault(x => x.Account == account); if (dto != null) { roles = db.UserRoles.Where(x => x.UserId == dto.UID).Select(x => x.Role.Name).ToArray(); } } // Build IPrinciple obj IIdentity userIdentity = new GenericIdentity(account); IPrincipal newUserObj = new GenericPrincipal(userIdentity, roles); // Update context user Context.User = newUserObj; }
public ActionResult Register(MemberDTO member) { if (CheckEmailHasBeUsed(member.Email)) { ModelState.AddModelError(string.Empty, "You input email has registed by other people."); } if (member.Password.Length < 8) { ModelState.AddModelError(string.Empty, "Password must be longer than 8 chars."); } if (ModelState.IsValid) { try { //Encrypt Password member.Password = Utils.Md5Hash(salt + member.Password); member.ConfirmPassword = member.Password; MemberManage.Create(member); return(RedirectToAction("Login", "Member")); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex); } } return(View()); }
protected void btnChange_Click(object sender, EventArgs e) { MemberDTO member = (MemberDTO)Session["MEMBER_USER"]; string username = member.Username; string oldPass = txtOldPass.Text; MemberDAO dao = new MemberDAO(); if (!dao.CheckPassword(username, oldPass)) { string message = "Password is not correct."; ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + message + "');", true); this.txtOldPass.Focus(); return; } string newPass = txtNewPass.Text; if (dao.ChangePass(username, newPass)) { string message = "Password changed SUCCESSFULLY."; ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + message + "');", true); } else { Response.Redirect("../ErrorPages/ErrorPage.aspx"); } }
public static MemberDTO CreateMemberDTO(int ID, bool isManager, int memberUserId) { MemberDTO memberDTO = new MemberDTO(); memberDTO.Id = ID; memberDTO.IsManager = isManager; memberDTO.MemberUserId = memberUserId; return memberDTO; }
public List<MemberDTO> GetAllUsers(string type) { List<MemberDTO> dtos = new List<MemberDTO>(); try { StringBuilder sbQuery = new StringBuilder(); sbQuery.Append("SELECT c.[user_id] as [UserID] "); sbQuery.Append(" ,c.[user_name] as [UserName] "); sbQuery.Append(" ,c.[nick_name] as [NickName] "); sbQuery.Append(" ,'' as [PhoneNumber] "); sbQuery.Append(" ,'' as [SkypeID] "); sbQuery.Append(" ,c.[email_address] as [Email] "); sbQuery.Append(" ,'' as [Sex] "); sbQuery.Append(" ,c.[is_admin] as [IsAdmin] "); sbQuery.Append("FROM [xe_member_group] as a "); sbQuery.Append(" JOIN [xe_member_group_member] as b "); sbQuery.Append(" ON a.[group_srl]=b.[group_srl] "); sbQuery.Append(" JOIN [xe_member] as c "); sbQuery.Append(" ON b.[member_srl]=c.[member_srl] "); sbQuery.Append(""); sbQuery.Append(""); //관리그룹,선생님,정회원,준회원 if (type.ToUpper().Equals("USER")) { //sbQuery.Append("WHERE a.[title] NOT IN (N'Managing Group', N'Teacher Group')"); sbQuery.Append("WHERE a.[title] NOT IN (N'관리그룹', N'선생님')"); //sbQuery.Replace("%GROUP%", "정회원"); } else if (type.ToUpper().Equals("TEACHER")) { //sbQuery.Append("WHERE a.[title] = N'Teacher Group'"); sbQuery.Append("WHERE a.[title] = N'선생님'"); //sbQuery.Replace("%GROUP%", "선생님"); } sbQuery.Append("ORDER BY [UserName] ASC "); DataTable dt = db.GetDataTable(sbQuery.ToString()); if (dt != null) { foreach (DataRow dr in dt.Rows) { MemberDTO memberDTO = new MemberDTO(); memberDTO.UserID = dr["UserID"].ToString(); memberDTO.UserName = dr["UserName"].ToString(); memberDTO.NickName = dr["NickName"].ToString(); memberDTO.PhoneNumber = dr["PhoneNumber"].ToString(); memberDTO.Email = dr["Email"].ToString(); memberDTO.SkypeID = dr["SkypeID"].ToString(); memberDTO.Sex = dr["Sex"].ToString(); memberDTO.IsAdmin = dr["IsAdmin"].ToString(); dtos.Add(memberDTO); } } } catch (Exception ex) { dtos.Clear(); } return dtos; }