예제 #1
0
        /// <summary>
        /// 添加系统用户
        /// </summary>
        /// <param name="command"></param>
        public void Execute(AddUserCommand command)
        {
            var sysMember = new SysMember();

            sysMember.Mapp(command);
            var check = sysMember.ValidateUserInfo();

            if (!check.success)
            {
                command.Result.Status = false;
                command.Result.Msg    = check.msg;
                return;
            }
            //加密密码
            sysMember.DesPwd();
            if (memberRepository.Exist(sysMember.Account))
            {
                command.Result.Status = false;
                command.Result.Msg    = "用户登录名已存在!";
                return;
            }
            command.RolesCmd.ForEach(r => { sysMember.AddRole(r.id, r.name); });
            var rlt = memberRepository.AddMember(sysMember);

            command.Result.Status = rlt.success;
            command.Result.Msg    = rlt.msg;
        }
예제 #2
0
        public ActionResult Save(string account, string password)
        {
            Members members = new Members();

            members.Account  = account;
            members.Password = EncryptHelper.GetSHA1(password);
            members.MemberId = Guid.NewGuid();

            try
            {
                var result = memberRep.IsMemberExists(members);
                if (result)
                {
                    TempData["Error"] = "已存在,請登入";

                    return(RedirectToAction("Display", "Home"));
                }

                if (memberRep.AddMember(members))
                {
                    string encrypt = this.LoginUser(members);

                    Response.Cookies.Add(new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encrypt));

                    return(RedirectToAction("Index", "Admin", new { area = "SiteAdmin" }));
                }

                TempData["Error"] = "註冊發生錯誤";
                return(RedirectToAction("Display", "Home"));
            }
            catch (Exception err)
            {
                throw err;
            }
        }
예제 #3
0
        public async Task <ReturnObject> Post([FromBody] Member member)
        {
            if (!ModelState.IsValid)
            {
                string errorMessages = string.Join(" ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage));

                _retObj.Status        = false;
                _retObj.StatusMessage = errorMessages;
                return(_retObj);
            }

            try
            {
                var ret = await _memberRepository.AddMember(member);

                return(ret);
            }
            catch (Exception ex)
            {
                _retObj.Status        = false;
                _retObj.StatusMessage = $"An error occured while processing your request. {ex.Message}";
                _retObj.Data          = null;

                return(_retObj);
            }

            //await this._memberRepository.AddMember(member);
        }
예제 #4
0
        public async Task <Member> AddMember(NonNull <string> teamId, NonNull <MemberInput> memberInput)
        {
            var member = memberInput.Value.ToDto();
            var result = await _memberRepository.AddMember(teamId, member);

            var addMember = Member.FromDto(result);

            return(addMember);
        }
예제 #5
0
        public void AddMember(MemberViewModel m)
        {
            Member member = new Member();

            member.Email     = m.Email;
            member.FirstName = m.FirstName;
            member.LastName  = m.LastName;
            _membersRepo.AddMember(member);
        }
 public IActionResult List(Member newMember)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     _memberRepository.AddMember(newMember);
     TempData["Message"] = $"{newMember.FirstLastName} added.";
     TempData["Style"]   = "alert alert-info";
     return(RedirectToAction("List", "Member"));
 }
예제 #7
0
        public async Task<IActionResult> RegisterMember([FromBody]RegistrationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var userIdentity = _mapper.Map<RegistrationViewModel, AppUser>(model);

            var result = await _userManager.CreateAsync(userIdentity, model.Password);

            if (!result.Succeeded) return new BadRequestObjectResult(Errors.AddErrorsToModelState(result, ModelState));

            _memberRepository.AddMember(new DomainLibrary.Member.Member { IdentityId = userIdentity.Id, Location = model.Location });
            await _uow.CompleteAsync();

            return new OkObjectResult("Account created");
        }
        public IActionResult AddMember([FromBody] Member member)
        {
            if (member == null)
            {
                return(BadRequest());
            }
            var    result         = _memberRepository.AddMember(member);
            Member memberToReturn = new Member();

            if (result < 0)
            {
                return(NoContent());
            }
            else
            {
                return(CreatedAtRoute("GetMember", new { id = result }, memberToReturn)
                       );
            }
        }
예제 #9
0
        public void AddNewMember(IAddNewMemberView inForm, IMemberRepository memberRepository)
        {
            if (inForm.ShowViewModal())
            {
                try
                {
                    string         name           = inForm.MemberName;
                    int            phoneNumber    = inForm.PhoneNumber;
                    MembershipType membershipType = memberRepository.GetMembershipTypeByName(inForm.MembershipType);

                    Member newMember = MemberFactory.CreateMember(name, phoneNumber, membershipType);
                    memberRepository.AddMember(newMember);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("EXCEPTION: " + ex.Message);
                    throw;
                }
            }
        }
예제 #10
0
        public ErrorCode AddMember(Member member)
        {
            if (string.IsNullOrEmpty(member.EmailAddress))
            {
                return(ErrorCode.ErrorWhileMemberRegistrationEmailEmpty);
            }

            if (string.IsNullOrEmpty(member.Password))
            {
                return(ErrorCode.ErrorWhileMemberRegistrationPasswordEmpty);
            }

            ErrorCode errorCode = _memberRepository.AddMember(member);

            if (errorCode == ErrorCode.None)
            {
                Save();
            }
            return(errorCode);
        }
예제 #11
0
        private void btnAddMember_Click(object sender, EventArgs e)
        {
            if (txtPassportMember.Text == "" || pcBPhotoMember.Image == null || txtNameMember.Text == "" || txtSurnameMember.Text == "" || txtDateMember.Text == "")
            {
                MessageBox.Show("One of * fields or image are empty");
            }
            else
            {
                Member member = new Member();
                member.FirstName        = txtNameMember.Text;
                member.SecondName       = txtSurnameMember.Text;
                member.PassportId       = txtPassportMember.Text;
                member.DateOfMembership = txtDateMember.Text;
                member.Address          = txtAddressMember.Text;
                member.Phone            = txtPhoneMember.Text;
                member.Email            = txtEmailMember.Text;
                member.Photo            = ImageManager.ImageToByteArray(pcBPhotoMember.Image);

                _memberRepository.AddMember(member);

                this.Close();
            }
        }
        public ResultSet <Member> AddMember(MemberRegisterViewModel member)
        {
            var result = new ResultSet <Member>();

            /******This nickname is exists*******************/
            if (_memberRepository.GetMemberByNickname(member.NickName) != null)
            {
                result.Message = "This nickname is already in use";
                return(result);
            }


            if (!string.IsNullOrEmpty(member.Password) && member.Password.Length > 16)
            {
                result.Message = "Invalid password string length";
                return(result);
            }


            if (!string.IsNullOrEmpty(member.Password))
            {
                string hash, salt;
                _hashProvider.GetHashAndSaltString(member.Password, out hash, out salt);
                member.PasswordHash = hash;
                member.PasswordSalt = salt;
            }
            var newMember = _memberRepository.AddMember(member);

            if (newMember != null)
            {
                result.Success = true;
                result.Message = Messages.OperationSuccess;
                result.Object  = newMember;
            }

            return(result);
        }
예제 #13
0
        public ActionResult MemberRegistration(MemberRegistrationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (Request.Files.Count == 0 || string.IsNullOrEmpty(Request.Files[0]?.FileName))
            {
                ModelState.AddModelError(String.Empty, "Please make sure a passport was chosen");
                return(View(model));
            }
            var directory = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/Passports/");

            if (Directory.Exists(directory) == false)
            {
                Directory.CreateDirectory(directory);
            }

            var fileName = $"{DateTime.Now:dd_MM_yyyy_hh_mm_ss}_{model.Surname}_" + Request.Files[0].FileName;
            var filePath = directory + "_" + fileName;

            Request.Files[0].SaveAs(filePath);
            try
            {
                var member = new Member
                {
                    Surname                = model.Surname,
                    Firstname              = model.Firstname,
                    Othername              = model.Othername,
                    Email                  = model.EmailAddress,
                    Phone                  = model.Phone,
                    Phone2                 = model.Phone2,
                    Gender                 = model.Gender,
                    HomeParish             = model.HomeParish,
                    Town                   = model.Town,
                    Nationality            = model.Nationality,
                    EmploymentAddress      = model.EmploymentAddress,
                    MaritalStatus          = model.MaritalStatus,
                    NextOfKin              = model.NextOfKin,
                    NextOfKinMaritalStatus = model.NextOfKinMaritalStatus,
                    NextOfKinAddress       = model.NextOfKinAddress,
                    SpouseName             = model.SpouseName,
                    SpousePhone            = model.SpousePhone1,
                    SpousePhone2           = model.SpousePhone2,
                    FamilyFemaleSize       = model.SizeOfFamilyFemale,
                    FamilyMaleSize         = model.SizeOfFamilyMale,
                    StatutoryGroup         = model.StatutoryGroup,
                    Confirmed              = 0,
                    Deleted                = 0,
                    DateRegistered         = DateTime.Now,
                    PassportUrl            = "/Images/Passports/_" + fileName
                };
                if (_memberRepository.AddMember(member) > 0)
                {
                    return(Redirect("MemberRegistrationSuccess"));
                }
                return(View(model));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(String.Empty, "There was an error completing the registration, Please try again later");
                return(View(model));
            }
        }
예제 #14
0
 public void AddMember(Member member)
 {
     _memberRepository.AddMember(member);
 }
예제 #15
0
 public bool Post([FromBody] MemberModel member)
 {
     //_member.AddMember(member);
     return(_member.AddMember(_mapper.Map <Member>(member)));
 }