Example #1
0
        public ActionResult Insert(CreateMemberRequest model)
        {
            var result = MemberRepository.CreateMember(model.MemberFirstName, model.MemberLastName, model.MemberEmail,
                                                       model.MemberUserName, model.MemberPassword, model.MemberBirthday,
                                                       model.MemberGender, model.MemberAddress,
                                                       null, null, model.MemberCountry, null);

            if (result.Code == "1")
            {
                return RedirectToAction("Edit","Member",new {id = model.MemberUserName});
            }

            ModelState.AddModelError("",result.Message);
            return View(model);

        }
Example #2
0
        /// <summary>
        /// Create member
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="email"></param>
        /// <param name="memberUsername"></param>
        /// <param name="password"></param>
        /// <param name="birthday"></param>
        /// <param name="gender"></param>
        /// <param name="address"></param>
        /// <param name="avatar"></param>
        /// <param name="avatarContent"></param>
        /// <param name="country"></param>
        /// <param name="facebookId"></param>
        /// <returns></returns>
        public MemberEditResponse CreateMember(string firstName, string lastName, string email, string memberUsername, string password,
                                               DateTime? birthday, bool gender, string address, string avatar, string avatarContent,
                                                string country, string facebookId)
        {
            if(memberUsername == null)
                memberUsername = NonUnicode(firstName.Split(' ')[0]) + "." + NonUnicode(lastName.Split(' ')[0]);

            var count = 1;
            while (!CheckUserName(memberUsername))
            {
                if (count == 1)
                    memberUsername = memberUsername + "." + count;
                else
                    memberUsername = memberUsername.Substring(0, memberUsername.LastIndexOf('.')) + "." + count;
                count++;
            }

            var request = new CreateMemberRequest
                {
                    ApiKey = ApiKey,
                    MemberBirthday = birthday,
                    MemberEmail = email,
                    MemberFirstName = firstName,
                    MemberLastName = lastName,
                    MemberGender = gender,
                    MemberUserName = memberUsername,
                    MemberPassword = password,
                    MemberAddress = address,
                    MemberAvatar = avatar,
                    MemberAvatarContent = avatarContent,
                    MemberCountry = country,
                    MemberFacebookId = facebookId
                };

            return ApiCall<MemberEditResponse, CreateMemberRequest>(request, "api" + RestPath.CreateMember);


        }