public WorkJsonResult CreateMember(CreateMemberDto dto) { //dto.AccessToken = GetAccessToken(QyConfig.CorpID, QyConfig.CorpSecret); MemberCreateRequest req = EmitMapperHelper.ObjectMapper <CreateMemberDto, MemberCreateRequest>(dto); var result = MailListApi.CreateMember(dto.AccessToken, req); return(result); }
public IActionResult AddMember([FromBody] CreateMemberDto memberDto) { if (memberDto == null || !ModelState.IsValid) { return(BadRequest(ModelState)); } var emailExists = _db.Members.Any(x => x.Email == memberDto.Email); if (emailExists) { ModelState.AddModelError("Email", "ایمیل قبلا استفاده شده است."); return(StatusCode(409, ModelState)); } var usernameExists = _db.Members.Any(x => x.Username == memberDto.Username); if (usernameExists) { ModelState.AddModelError("Username", "نام کاربری قبلا استفاده شده است."); return(StatusCode(409, ModelState)); } var memberTitleExists = _db.Members.Any(x => x.MemberTitle == memberDto.MemberTitle); if (memberTitleExists) { ModelState.AddModelError("MemberTitle", "عنوان قبلا استفاده شده است."); return(StatusCode(409, ModelState)); } memberDto.Password = PasswordHelper.EncodePasswordMd5(memberDto.Password); var member = _mapper.Map <Member>(memberDto); try { _db.Members.Add(member); _db.SaveChanges(); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(StatusCode(500, ModelState)); } var memberResult = _mapper.Map <MemberDto>(member); return(CreatedAtRoute("GetMember", new { memberId = member.Id }, memberResult)); }
public CreatedAtActionResult AddMember(CreateMemberDto dto) { var createdMember = _memberService.Create(new Member { Email = dto.Email, Name = dto.Name, Lastname = dto.Lastname, TeamId = dto.TeamId }); return(CreatedAtAction(nameof(AddMember), new { id = createdMember.Id }, createdMember)); }
public ApiResult <CreateMemberDto> Register([FromBody] CreateMemberDto dto) { if (ModelState.IsValid) { ApiResult <CreateMemberDto> result = _userService.VerifyEmailAndNameWhenRegister(dto); if (result.Issuccessful) { _userService.Create(dto); } return(result); } else { return(new ApiResult <CreateMemberDto>("Dto is invalid")); } }
public virtual Guid Create(CreateMemberDto dto) { var fullName = $"{dto.FirstName} {dto.LastName}"; var member = _memberService.CreateMember(dto.Email, dto.Email, fullName, "Member"); member.SetValue(ProfileConstants.FirstName, dto.FirstName); member.SetValue(ProfileConstants.LastName, dto.LastName); member.SetValue(ProfileConstants.Phone, dto.Phone); member.SetValue(ProfileConstants.Department, dto.Department); member.SetValue(ProfileConstants.Photo, dto.MediaId); _memberService.Save(member, false); UpdateMemberCache(member.Key); return(member.Key); }
public virtual IHttpActionResult Create(CreateMemberDto createModel) { if (ModelState.IsValid) { var user = _intranetMemberService.GetByEmail(createModel.Email); if (user != null) { return(Conflict()); } var id = _intranetMemberService.Create(createModel); return(Ok(id)); } else { return(BadRequest(GetModelErrors())); } }
/// <summary> /// Register /// </summary> /// <param name="dto"></param> public void Create(CreateMemberDto dto) { try { ForumMembers user = new ForumMembers() { UserId = Guid.NewGuid(), Password = _encrypt.ToMD5(dto.Password), Email = dto.Email, Name = dto.Name, Gender = dto.Gender, Age = dto.Age, Phone = dto.Phone, //Default Picture ImgLink = "https://i.imgur.com/gZQyxZj.png", //Set default role to "normal" RoleId = _roles.GetFirst(x => x.RoleName == "一般使用者").RoleId, //Set default points to 1K Points = 1000, //Set default title to "Novice" TitleId = _titles.GetFirst(x => x.TitleName == "初心者").TitleId, //RefreshToken(Use it when jwt token expired) RefreshToken = Guid.NewGuid() }; _members.Create(user); _members.SaveContext(); //Add title "Novice" to MemberTitle when register MemberTitle usertitle = new MemberTitle() { UserId = user.UserId, HasTitleId = user.TitleId }; _memberTitle.Create(usertitle); _memberTitle.SaveContext(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
/// <summary> /// Verify email and name when register /// </summary> /// <param name="dto"></param> /// <returns></returns> public ApiResult <CreateMemberDto> VerifyEmailAndNameWhenRegister(CreateMemberDto dto) { IQueryable <ForumMembers> sourcre = _members.GetAll().Where(x => x.Email == dto.Email || x.Name == dto.Name); if (sourcre.Any(x => x.Email == dto.Email)) { if (sourcre.Any(x => x.Name == dto.Name)) { return(new ApiResult <CreateMemberDto>($"{dto.Email} and {dto.Name} already exist,choose another one!")); } return(new ApiResult <CreateMemberDto>($"{dto.Email} already exists,choose another one!")); } if (sourcre.Any(x => x.Name == dto.Name)) { return(new ApiResult <CreateMemberDto>($"{dto.Name} already exists,choose another one!")); } else { return(new ApiResult <CreateMemberDto>()); } }
public async Task <IActionResult> Post([FromBody] CreateMemberDto memberDto) { try { if (memberDto == null) { return(BadRequest()); } var member = _mapper.Map <Member>(memberDto); _context.Members.Add(member); await _context.SaveChangesAsync(); return(Ok(member.Id)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task Should_CreateMember() { CreateMemberDto memberDto = new CreateMemberDto { UserName = "******", Name = "FirstName", Surname = "LastName", Password = "******", EmailAddress = "*****@*****.**", IsMale = true, IsSingle = true }; await _memberAppService.CreateMember(memberDto); var member = _memberRepository.FirstOrDefault(x => x.UserName == memberDto.UserName); member.ShouldNotBeNull(); var user = _userRepository.FirstOrDefault(x => x.UserName == member.UserName); user.ShouldNotBeNull(); }
public Member BizAction(CreateMemberDto inputData) { var item = new Member { Age = inputData.Age, Job = inputData.Job, Name = inputData.Name, Tags = inputData.Tags, Group = inputData.Group, Phone = inputData.Phone, Email = inputData.Email, Gender = inputData.Gender, Address = inputData.Address, Website = inputData.Website, Twitter = inputData.Twitter, Facebook = inputData.Facebook, Interest = inputData.Interest, Projects = inputData.Projects, Last_name = inputData.Last_name, Signature = inputData.Signature, Newsletter = inputData.Newsletter, Cad_software = inputData.Cad_software, Invoice_disabled = inputData.Invoice_disabled, Validated_training = inputData.Validated_training, Number_Invoices = inputData.Number_Invoices, Ecocience = inputData.Ecocience, Organization = inputData.Organization, Organization_Address = inputData.Organization_Address, Aux_Group = inputData.Aux_Group, Aux_Training = inputData.Aux_Training, Aux_Group_Training = inputData.Aux_Group_Training }; _context.Add(item); Message = "A entidade foi criada com sucesso."; return(item); }
public IActionResult Create(CreateMemberDto dto) { var result = _memberService.CreateMember(dto); return(Json(result)); }
public JObject UpdateMember(CreateMemberDto input) { Logger.Info("UpdateMember() - Started."); JObject obj = new JObject(); Logger.DebugFormat("UpdateMember() - Start get data for update in Personals Member. Parameters sent:{0}" + "entityCode = {1}{0}" + "psCode = {2}{0}" + "scmCode = {3}{0}" + "memberCode = {4}{0}" , Environment.NewLine, 1, input.memberData.psCode, input.memberData.scmCode, input.memberData.memberCode); var getSetMember = (from personalsMember in _personalsMemberRepo.GetAll() where personalsMember.entityCode == "1" && personalsMember.psCode == input.memberData.psCode && personalsMember.scmCode == input.memberData.scmCode && personalsMember.memberCode == input.memberData.memberCode select personalsMember).FirstOrDefault(); Logger.DebugFormat("UpdateMember() - End get data for update in Personals Member."); if (getSetMember != null) { if (input.memberActivation.isActive) { var getUnavailableMemberScmCode = (from x in _personalsMemberRepo.GetAll() where x.entityCode == "1" && x.psCode == input.memberData.psCode && x.scmCode == input.memberData.scmCode && x.memberCode != input.memberData.memberCode && x.isMember == true select x).ToList(); foreach (var dataToEdit in getUnavailableMemberScmCode) { dataToEdit.isMember = false; try { Logger.DebugFormat("DeleteMember() - Start delete member. Params sent: {0}" + "isMember = {1}{0}" , Environment.NewLine, false); _personalsMemberRepo.Update(dataToEdit); CurrentUnitOfWork.SaveChanges(); Logger.DebugFormat("DeleteMember() - End delete member."); } // Handle data errors. catch (DataException exDb) { Logger.ErrorFormat("DeleteMember() - ERROR DataException. Result = {0}", exDb.Message); throw new UserFriendlyException("Database Error : {0}", exDb.Message); } // Handle all other exceptions. catch (Exception ex) { Logger.ErrorFormat("DeleteMember() - ERROR Exception. Result = {0}", ex.Message); throw new UserFriendlyException("Error : {0}", ex.Message); } } } var update = getSetMember.MapTo <PERSONALS_MEMBER>(); #region member data update.parentMemberCode = String.IsNullOrEmpty(input.memberData.parentMemberCode) ? "-" : input.memberData.parentMemberCode; update.PTName = String.IsNullOrEmpty(input.memberData.PTName) ? "-" : input.memberData.PTName; update.PrincName = String.IsNullOrEmpty(input.memberData.PrincName) ? "-" : input.memberData.PrincName; update.spouName = String.IsNullOrEmpty(input.memberData.spouName) ? "-" : input.memberData.spouName; update.specCode = String.IsNullOrEmpty(input.memberData.specCode) ? "0" : input.memberData.specCode; update.franchiseGroup = String.IsNullOrEmpty(input.memberData.franchiseGroup) ? "-" : input.memberData.franchiseGroup; update.isInstitusi = input.memberData.isInstitusi; update.isPKP = input.memberData.isPKP; update.isCD = input.memberData.isCD; update.CDCode = String.IsNullOrEmpty(input.memberData.CDCode) ? "-" : input.memberData.CDCode; update.isACD = input.memberData.isACD; update.ACDCode = String.IsNullOrEmpty(input.memberData.ACDCode) ? "-" : input.memberData.ACDCode; update.remarks1 = input.memberData.remarks1 == null ? "-" : input.memberData.remarks1; #endregion #region activation update.memberStatusCode = String.IsNullOrEmpty(input.memberActivation.memberStatusCode) ? "-" : input.memberActivation.memberStatusCode; update.isActive = input.memberActivation.isActive; update.isMember = input.memberActivation.isMember; update.password = String.IsNullOrEmpty(input.memberActivation.password) ? "-" : input.memberActivation.password; #endregion #region bank data update.bankType = String.IsNullOrEmpty(input.memberBankData.bankType) ? "0" : input.memberBankData.bankType; update.bankCode = input.memberBankData.bankCode; update.bankBranchName = String.IsNullOrEmpty(input.memberBankData.bankBranchName) ? "-" : input.memberBankData.bankBranchName; update.bankAccNo = String.IsNullOrEmpty(input.memberBankData.bankAccNo) ? "-" : input.memberBankData.bankAccNo; update.bankAccName = String.IsNullOrEmpty(input.memberBankData.bankAccName) ? "-" : input.memberBankData.bankAccName; #endregion try { Logger.DebugFormat("UpdateMember() - Start update member. Params sent:{0}" + "Data Member:{0}" + "parentMemberCode ={2}{0}"+ "PTName ={3}{0}"+ "PrincName ={4}{0}"+ "spouName ={5}{0}"+ "specCode ={6}{0}"+ "franchiseGroup ={7}{0}"+ "isInstitusi ={8}{0}" + "isCD ={9}{0}"+ "CDCode ={10}{0}"+ "isACD ={11}{0}"+ "ACDCode ={12}{0}" + "remarks1 ={13}{0}"+ "Data Activation:{0}" + "memberStatusCode ={14}{0}" + "isActive ={15}{0}" + "isMember ={16}{0}" + "password ={17}{0}" + "Data Bank:{0}" + "bankType ={18}{0}" + "bankCode ={19}{0}" + "bankBranchName ={20}{0}" + "bankAccNo ={21}{0}" + "bankAccName ={1}" , Environment.NewLine, input.memberBankData.bankAccName, input.memberData.parentMemberCode, input.memberData.PTName, input.memberData.PrincName, input.memberData.spouName , input.memberData.specCode, input.memberData.franchiseGroup, input.memberData.isInstitusi, input.memberData.isCD, input.memberData.CDCode , input.memberData.isACD, input.memberData.ACDCode, input.memberData.remarks1 , input.memberActivation.memberStatusCode, input.memberActivation.isActive, input.memberActivation.isMember, input.memberActivation.password , input.memberBankData.bankType, input.memberBankData.bankCode, input.memberBankData.bankBranchName, input.memberBankData.bankAccNo); _personalsMemberRepo.Update(update); CurrentUnitOfWork.SaveChanges(); obj.Add("message", "Successfully Updated"); } // Handle data errors. catch (DataException exDb) { Logger.ErrorFormat("UpdateMember() - ERROR DataException. Result = {0}", exDb.Message); throw new UserFriendlyException("Database Error : {0}", exDb.Message); } // Handle all other exceptions. catch (Exception ex) { Logger.ErrorFormat("UpdateMember() - ERROR Exception. Result = {0}", ex.Message); throw new UserFriendlyException("Error : {0}", ex.Message); } } else { Logger.ErrorFormat("UpdateMember() - ERROR. Result = {0}", "The member is not exist!"); throw new UserFriendlyException("The member is not exist!"); } Logger.Info("UpdateMember() - Finished."); return(obj); }
/// <summary> /// /// </summary> /// <param name="dto"></param> /// <returns></returns> public PublicResult <CreateMemberApo> CreateMember(CreateMemberDto dto) { var member = new Member { UId = Guid.NewGuid().ToString("N"), Address = null, Avatar = dto.Avatar, Nickname = dto.Nickname, Birthday = null, CannotLoginUntilDate = null, Email = null, FailedLoginAttempts = 0, Gender = dto.Gender, Geohash = null, IsActive = true, IsDelete = false, IsEmailValid = false, IsMobileValid = false, LastActiveDatetime = DateTime.Now, LastLoginDatetime = DateTime.Now, LastLoginIp = null, Lat = null, Lng = null, LoginCount = 0, Mobile = null, OnlineTimeCount = 0, Password = null, PasswordSalt = null, RegionCode = null, RegisterDatetime = DateTime.Now, RegisterIp = null, Username = dto.Username }; using (var db = DbFactory.CreateClient()) { { var isExist = db.Queryable <Member>() .Where(it => it.Username.Equals(dto.Username)) .Select(it => new { it.Id }) .ToList() .Any(); if (isExist) { return(Error($"此用户名 {dto.Username} 已存在")); } member.Username = dto.Username; } { var saltKey = _encryptionService.CreateSaltKey(6); var newPassword = _encryptionService .CreatePasswordHash(dto.Password, saltKey, "SHA512"); member.Password = newPassword; member.PasswordSalt = saltKey; } if (!dto.Email.IsNullOrEmpty()) { var isExist = db.Queryable <Member>() .Where(it => it.Email.Equals(dto.Email)) .Select(it => new { it.Id }) .ToList() .Any(); if (isExist) { return(Error($"此邮箱 {dto.Email} 已存在")); } member.Email = dto.Email; } if (!dto.Mobile.IsNullOrEmpty()) { var isExist = db.Queryable <Member>() .Where(it => it.Mobile.Equals(dto.Mobile)) .Select(it => new { it.Id }) .ToList() .Any(); if (isExist) { return(Error($"此手机 {dto.Mobile} 已存在")); } member.Mobile = dto.Mobile; } db.UseTran(tran => { member.Id = tran.Insertable(member).ExecuteReturnBigIdentity(); tran.Insertable(new MemberRole { ExpireDate = null, MemberId = member.Id, RoleId = 3 }).ExecuteCommand(); return(0); }); } return(new CreateMemberApo { Id = member.Id, UId = member.UId, Username = member.Username }); }
public ActionResult <Member> Post(CreateMemberDto item, [FromServices] IActionService <ICreateMemberBizLogic> service) { var result = service.RunBizAction <Member>(item); return(service.Status.Response(this, "GetSingleMember", new { id = result?.Id }, result)); }