Exemple #1
0
        public IResult SignUp(UserForRegisterDto dto)
        {
            HashingHelper.CreatePasswordHash(dto.Password, out var passwordHash, out var passwordSalt);
            var user = new User()
            {
                Email        = dto.Email,
                FirstName    = dto.Name,
                LastName     = dto.Lastname,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                Status       = true
            };
            var result = _userService.Add(user);

            if (!result.Success)
            {
                return(result);
            }
            var member = new Member()
            {
                User = user
            };

            _memberService.Add(member);

            return(new SuccessResult(Messages.UserAdded));
        }
 public ActionResult Add(Member member)
 {
     _memberService.Add(member);
     return(View(new MemberAddViewModel {
         Member = member
     }));
 }
        private void ButtonUyeEkle_Click_1(object sender, EventArgs e)
        {
            try
            {
                _memberService.Add(new Member
                {
                    UyeAd      = textBoxUyeEkleAd.Text,
                    UyeSoyad   = textBoxUyeEkleSoyad.Text,
                    UyeTelefon = maskedTextBoxUyeEkleTelefon.Text,
                    UyeAdres   = textBoxUyeEkleAdres.Text,
                    UyeEposta  = textBoxUyeEkleEposta.Text
                });
                MessageBox.Show("Üye Başarıyla Eklendi");
                LoadMembers();

                textBoxUyeEkleAd.Text            = "";
                textBoxUyeEkleSoyad.Text         = "";
                maskedTextBoxUyeEkleTelefon.Text = "";
                textBoxUyeEkleEposta.Text        = "";
                textBoxUyeEkleAdres.Text         = "";
            }
            catch (Exception)
            {
                MessageBox.Show("Bir Hata Oluştu");
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            IMemberService _memberService = InstanceFactory.GetInstance <IMemberService>();

            try
            {
                _memberService.Add(new Member
                {
                    FirstName   = "Furkan",
                    LastName    = "Altaca",
                    DateOfBirth = new DateTime(2001, 6, 16),
                    TcNo        = "46522310036",
                    Email       = "*****@*****.**",
                });
                Console.WriteLine("Eklendi");

                var members = _memberService.GetAll();
                foreach (var member in members)
                {
                    Console.WriteLine(member.FirstName);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
 public ActionResult AddMember(Member member)
 {
     if (!ModelState.IsValid)
     {
         return(View("AddMember"));
     }
     _memberManager.Add(member);
     return(View());
 }
Exemple #6
0
        static void Main(string[] args)
        {
            IMemberService memberService = InstanceFactory.GetInstance <IMemberService>();

            memberService.Add(new Member {
                Email = "*****@*****.**", FirstName = "Kubra", LastName = "Petek", DateOfBirth = new DateTime(1995, 3, 30), TcNo = "17075218810"
            });                                                                                                                                                                    //Kontrolü mernis üzerinden yaptığı için kullancı bilgileri doğru olmak zorunda
            Console.WriteLine("Eklendi");
            Console.ReadLine();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            Member member = new Member();

            IMemberService memberService = InstanceFactory.GetInstance <IMemberService>();

            memberService.Add(member);
            Console.WriteLine("Eklendi.");
            Console.ReadLine();
        }
Exemple #8
0
        public async Task <IActionResult> Create(MemberIM model)
        {
            if (ModelState.IsValid)
            {
                await memberService.Add(model);

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Exemple #9
0
        public ActionResult Create([FromBody] MemberCreateM model)
        {
            try
            {
                DateTime now          = DateTime.Now;
                int      currentMonth = now.Month;
                string   currentSemester;
                switch (currentMonth)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                    currentSemester = "spring-" + now.Year;
                    break;

                case 5:
                case 6:
                case 7:
                case 8:
                    currentSemester = "summer-" + now.Year;
                    break;

                default:
                    currentSemester = "fall-" + now.Year;
                    break;
                }
                Member checkMember = MemberService.Get(_ => _.clubId.Equals(model.clubId) && _.studentId.Equals(model.studentId) && _.status.Equals(true));
                if (checkMember != null)
                {
                    return(StatusCode(401));
                }
                Member member = new Member
                {
                    clubId    = model.clubId,
                    studentId = model.studentId,
                    rank      = 4,
                    semester  = currentSemester,
                    status    = true
                };
                MemberService.Add(member);
                MemberService.SaveChanges();
                return(Ok(member.memberId));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        static void Main(string[] args)
        {
            IMemberService _memberService = InstanceFactory.GetInstance<IMemberService>();
            _memberService.Add(new Member()
            {
                FirstName ="Mustafa",
                Email = "*****@*****.**",
                LastName ="YILDIRIM",
                DateOfBirth =new DateTime(1993,6,24),
                TcNo = "12345678912"
            });

            Console.WriteLine("Eklendi");
            Console.ReadLine();
        }
Exemple #11
0
        public bool Register(Register member)
        {
            var MessageTemp = _memberService.Add(new Member {
                Name     = member.Name,
                Phone    = member.Phone,
                Username = member.Username,
                Surname  = member.Surname,
                Email    = member.Email,
                Password = member.Password,
                TagName  = member.TagName
            });

            _memberService.Save();
            return(true);
        }
Exemple #12
0
        static void Main(string[] args)
        {
            IMemberService memberService = InstanceFactory.GetInstance <IMemberService>();

            memberService.Add(new Member
            {
                FirstName   = "Burak",
                LastName    = "Arat",
                DateOfBirth = new DateTime(1992, 2, 2),
                Email       = "*****@*****.**",
                TcNo        = ""
            });
            Console.WriteLine("Eklendi");
            Console.ReadLine();
        }
Exemple #13
0
        public IHttpActionResult AddMember(MemberDataViewModel memberView)
        {
            try
            {
                string errorMessage = String.Empty;
                Member member       = new Member();
                if (memberView != null)
                {
                    member.NIC                   = String.IsNullOrEmpty(memberView.nic) ? String.Empty : memberView.nic;
                    member.DOB                   = memberView.dob;
                    member.FullName              = memberView.fullName;
                    member.ShortName             = String.IsNullOrEmpty(memberView.nameWithInitial) ? String.Empty : memberView.nameWithInitial;
                    member.PermanetAddress       = String.IsNullOrEmpty(memberView.permanetAddress) ? String.Empty : memberView.permanetAddress;
                    member.CurrentAddress        = String.IsNullOrEmpty(memberView.currentAddress) ? String.Empty : memberView.currentAddress;
                    member.TrainingCertificateNo = String.IsNullOrEmpty(memberView.cetificateNo) ? String.Empty : memberView.cetificateNo;
                    member.TrainingCenter        = String.IsNullOrEmpty(memberView.trainingCenter) ? String.Empty : memberView.trainingCenter;
                    member.LicenceNo             = String.IsNullOrEmpty(memberView.licenceNo) ? String.Empty : memberView.licenceNo;
                    member.IssuedDate            = memberView.dateIssued;
                    member.ExpireDate            = memberView.dateValidity;
                    member.JoinDate              = memberView.dateJoin;
                    member.HighestEducation      = String.IsNullOrEmpty(memberView.educationQuali) ? String.Empty : memberView.educationQuali;
                    member.TypeId                = memberView.typeId;
                    member.NTCNo                 = _common.GetLastNTCNO(memberView.typeId);
                    member.ImagePath             = memberView.imagePath;
                    _member.Add(member, out errorMessage);
                }
                else
                {
                    errorMessage = Constant.MessageGeneralError;
                }

                var messageData = new
                {
                    code = String.IsNullOrEmpty(errorMessage) ? Constant.SuccessMessageCode : Constant.ErrorMessageCode
                    ,
                    message = String.IsNullOrEmpty(errorMessage) ? Constant.MessageSuccess : errorMessage
                };
                var returnObject = new { ntcNo = member.NTCNo, messageCode = messageData };
                return(Ok(returnObject));
            }
            catch (Exception ex)
            {
                string errorLogId   = _eventLog.WriteLogs(User.Identity.Name, ex, MethodBase.GetCurrentMethod().Name);
                var    messageData  = new { code = Constant.ErrorMessageCode, message = String.Format(Constant.MessageTaskmateError, errorLogId) };
                var    returnObject = new { messageCode = messageData };
                return(Ok(returnObject));
            }
        }
        public IDataResult <Member> Register(MemberForRegisterDto memberForRegisterDto, string password)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
            var member = new Member
            {
                Email        = memberForRegisterDto.Email,
                FirstName    = memberForRegisterDto.FirstName,
                LastName     = memberForRegisterDto.LastName,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                Status       = true
            };

            _memberService.Add(member);
            return(new SuccessDataResult <Member>(member, Messages.MemberRegistered));
        }
        public async Task <IActionResult> Create(MemberCreateVm vm)
        {
            if (ModelState.IsValid)
            {
                //Skapa ny member
                var newMember = new Member();
                newMember.LastName  = vm.LastName;
                newMember.FirstName = vm.FirstName;
                newMember.SSN       = vm.SSN;

                memberService.Add(newMember);

                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction("Error", "Home", ""));
        }
        public IDataResult <Member> Register(MemberForRegisterDto userForRegisterDto, string password)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
            var member = new Member
            {
                EMail        = userForRegisterDto.Email,
                Name         = userForRegisterDto.FirstName,
                LastName     = userForRegisterDto.LastName,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                UserName     = userForRegisterDto.UserName,
                Education    = userForRegisterDto.Education
            };

            _memberService.Add(member);
            return(new SuccessDataResult <Member>(member));
        }
Exemple #17
0
 public IActionResult Register([FromBody] RegisterMemberQueryModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.Values));
     }
     try
     {
         var member   = model.ToDomain();
         var dbMember = _memberService.Add(member);
         dbMember.PasswordHash = "******";
         return(Ok(dbMember));
     }
     catch (System.Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        /// <summary>
        ///     Adds a member to the Episerver Social Framework.
        /// </summary>
        /// <param name="communityMember">The member to add.</param>
        /// <returns>The added member.</returns>
        public CommunityMember Add(CommunityMember communityMember)
        {
            CommunityMember addedSocialMember = null;

            try
            {
                var userReference        = Reference.Create(communityMember.User);
                var groupId              = GroupId.Create(communityMember.GroupId);
                var member               = new Member(userReference, groupId);
                var extensionData        = new MemberExtensionData(communityMember.Email, communityMember.Company);
                var addedCompositeMember = _memberService.Add(member, extensionData);
                addedSocialMember =
                    _communityMemberAdapter.Adapt(addedCompositeMember.Data, addedCompositeMember.Extension);

                if (addedSocialMember == null)
                {
                    throw new SocialRepositoryException("The new member could not be added. Please try again");
                }
            }
            catch (SocialAuthenticationException ex)
            {
                throw new SocialRepositoryException("The application failed to authenticate with Episerver Social.",
                                                    ex);
            }
            catch (MaximumDataSizeExceededException ex)
            {
                throw new SocialRepositoryException(
                          "The application request was deemed too large for Episerver Social.", ex);
            }
            catch (SocialCommunicationException ex)
            {
                throw new SocialRepositoryException("The application failed to communicate with Episerver Social.", ex);
            }
            catch (SocialException ex)
            {
                throw new SocialRepositoryException("Episerver Social failed to process the application request.", ex);
            }

            return(addedSocialMember);
        }
Exemple #19
0
        static void Main(string[] args)
        {
            try
            {
                IMemberService memberService = InstanceFactory.GetInstance <IMemberService>();
                memberService.Add(new Member
                {
                    Email       = "your email",
                    FirstName   = "your name",
                    LastName    = "your last name",
                    DateOfBirth = new DateTime(2018, 10, 16), //today
                    TcNo        = "your tc no"
                });

                Console.WriteLine("added");
                Console.ReadLine();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                Console.ReadLine();
            }
        }
Exemple #20
0
        public async Task <IActionResult> Reg([FromBody] List <FormParam> param)
        {
            if (param == null || param.Count < 4)
            {
                return(Ok(new ApiResult <string>()
                {
                    statusCode = 500, message = ApiEnum.ParameterError.GetEnumText()
                }));
            }
            var model = new Core.Model.Member.Member()
            {
                LoginName = param[0].value,
                Grade     = "d08b0d59-34a6-41d7-8bb0-6ddedd43ab33",
                NickName  = param[0].value,
                Mobile    = param[1].value,
                Email     = param[2].value,
                LoginPwd  = param[3].value,
                Autograph = "这家伙很懒,什么也没留下",
                HeadPic   = "/dist_bbs/images/head/" + Utils.Number(1) + ".jpg"
            };

            return(Ok(await _memberService.Add(model)));
        }
        public ActionResult EditMember(MemberDTO member)
        {
            return(HttpHandleExtensions.AjaxCallGetResult(() =>
            {
                member.Departments = new List <DepartmentDTO>();
                if (member.Id == Guid.Empty)
                {
                    _memberService.Add(member);
                    this.JsMessage = MessagesResources.Add_Success;
                }
                else
                {
                    _memberService.Update(member);
                    this.JsMessage = MessagesResources.Update_Success;
                }

                return Json(new AjaxResponse
                {
                    Succeeded = true,
                    RedirectUrl = Url.Action("Index")
                });
            }));
        }
Exemple #22
0
        static void Main(string[] args)
        {
            IMemberService memberService = InstanceFactory.GetInstance <IMemberService>();

            //Console.WriteLine("Ad:");
            //string FirstName = Console.ReadLine();
            //Console.WriteLine("Soyad:");
            //string LastName = Console.ReadLine();
            //Console.WriteLine("Email:");
            //string Email = Console.ReadLine();
            //Console.WriteLine("Tc:");
            //string Tc = Console.ReadLine();
            //Console.WriteLine("Doğum Tarihi(/):");
            //string Birth = Console.ReadLine();

            //string[] b = Birth.Split('/');


            memberService.Add(new Member
            {
                //FirstName = FirstName,
                //LastName = LastName,
                //Email = Email,
                //TcNo = Tc,
                //DateOfBirth = new DateTime(Convert.ToInt32(b[2]), Convert.ToInt32(b[1]), Convert.ToInt32(b[0]))

                FirstName   = "Furkan",
                LastName    = "Karataş",
                Email       = "*****@*****.**",
                TcNo        = "22348507347",
                DateOfBirth = new DateTime(2005, 10, 27)
            });

            Console.WriteLine("Eklendi");

            Console.ReadLine();
        }
        public async Task <IActionResult> AddNewMember([FromBody] AddMemberRequest request)
        {
            await _memberService.Add(request, User.Identity.Name);

            return(Ok());
        }
Exemple #24
0
 public async Task <IActionResult> Add([FromBody] Core.Model.Member.Member model)
 {
     return(Ok(await _memberService.Add(model)));
 }
Exemple #25
0
        public AppQuery(ILoggerFactory loggerFactory,
                        IOrganizationService organizationService,
                        IMemberService memberService)
        {
            _organizationService = organizationService;
            _memberService       = memberService;

            var logger = loggerFactory.CreateLogger <AppQuery>();

            Field <NonNullGraphType <StringGraphType> >()
            .Name("setup")
            .Argument <StringGraphType>("redirectUrl", "The redirect url")
            .Resolve(context =>
            {
                var userContext = context.UserContext.As <Context>();
                var csrf        = Password.Generate(24, 1);
                var redirectUrl = context.GetArgument <string>("redirectUrl");

                userContext.HttpContext.Session.SetString("CSRF", csrf);

                var request = new OauthLoginRequest(Env.GetString("CLIENT_ID"))
                {
                    Scopes = { "admin:repo_hook", "repo" },
                    State  = csrf,
                };

                if (redirectUrl != null)
                {
                    request.RedirectUri = new Uri($"{Env.GetString("APP_URL")}/setupCallback?redirectUrl={redirectUrl}");
                }

                var oAuthLoginUrl = _client.Oauth.GetGitHubLoginUrl(request);

                return(oAuthLoginUrl);
            });

            Field <NonNullGraphType <ListGraphType <OrganizationPayload> > >()
            .Name("organizations")
            .ResolveAsync(async context =>
            {
                var userContext = context.UserContext.As <Context>();
                var token       = userContext.HttpContext.Session.GetString("OAuthToken");

                if (token == null)
                {
                    throw new NullReferenceException("OAuthToken is null");
                }

                _client.Credentials = new Credentials(token);

                var user          = await _client.User.Current();
                var organizations = _organizationService.GetOrganizations(user.Id);

                return(organizations);
            });

            Field <NonNullGraphType <BooleanGraphType> >()
            .Argument <NonNullGraphType <StringGraphType> >("code", "The code for the setup")
            .Argument <NonNullGraphType <StringGraphType> >("state", "The CSRF protection state")
            .Name("setupCallback")
            .ResolveAsync(async context =>
            {
                var userContext   = context.UserContext.As <Context>();
                var state         = context.GetArgument <string>("state");
                var code          = context.GetArgument <string>("code");
                var expectedState = userContext.HttpContext.Session.GetString("CSRF");

                if (state != expectedState)
                {
                    throw new InvalidOperationException();
                }

                userContext.HttpContext.Session.SetString("CSRF", "");
                var request = new OauthTokenRequest(Env.GetString("CLIENT_ID"), Env.GetString("CLIENT_SECRET"), code);
                var token   = await _client.Oauth.CreateAccessToken(request);

                _client.Credentials = new Credentials(token.AccessToken);

                userContext.HttpContext.Session.SetString("OAuthToken", token.AccessToken);

                var organizations = await _client.Organization.GetAllForCurrent();

                foreach (var organization in organizations)
                {
                    var secretKey        = Env.GetString("GITHUB_WEBHOOKS_SECRETKEY_DEFAULT");
                    var gitHubWebHookUrl = Env.GetString("GITHUB_WEBHOOK_URL", Env.GetString("APP_URL"));

                    var hooks = new Dictionary <string, string> {
                        { "url", $"{gitHubWebHookUrl}/api/webhooks/incoming/github" },
                        { "secret", secretKey },
                        { "content_type", "json" }
                    };

                    try
                    {
                        await _client.Repository.Create(organization.Login, new NewRepository(Constants.RepositoryName)
                        {
                            Description = "This repository is auto-generated by onboardor.com and is used for storing the issues. Do not delete.",
                        });
                    }
                    catch (RepositoryExistsException) { }

                    try
                    {
                        await _client.Repository.Hooks.Create(organization.Login, Constants.RepositoryName,
                                                              new NewRepositoryHook("web", hooks)
                        {
                            Events = new List <string> {
                                "issues"
                            },
                            Active = true
                        });
                    }
                    catch (Exception ex) when(ex is ApiValidationException || ex is NotFoundException)
                    {
                    }

                    var existingOrganization = _organizationService.GetOrganization(organization.Id);

                    Member GetMember(int id, string name, string avatarUrl)
                    {
                        return(new Member
                        {
                            Id = id,
                            Name = name,
                            AvatarUrl = avatarUrl
                        });
                    }

                    if (existingOrganization == null)
                    {
                        var users           = await _client.Organization.Member.GetAll(organization.Login);
                        var newOrganization = new Organization
                        {
                            Id        = organization.Id,
                            Name      = organization.Login,
                            AvatarUrl = organization.AvatarUrl,
                        };

                        foreach (var user in users)
                        {
                            var existingMember = _memberService.GetMember(user.Id);

                            newOrganization.Members.Add(new OrganizationMember
                            {
                                Member       = existingMember ?? GetMember(user.Id, user.Login, user.AvatarUrl),
                                Organization = newOrganization
                            });
                        }

                        _organizationService.Add(newOrganization);
                    }
                    else
                    {
                        var users           = await _client.Organization.Member.GetAll(existingOrganization.Name);
                        var usersToAdd      = users.Where(x => existingOrganization.Members.All(z => z.Member.Id != x.Id));
                        var membersToRemove = existingOrganization.Members.Where(x => users.All(z => z.Id != x.Member.Id)).Select(x => x.Member);

                        foreach (var userToAdd in usersToAdd)
                        {
                            var member = GetMember(userToAdd.Id, userToAdd.Login, userToAdd.AvatarUrl);

                            member.Organizations = new List <OrganizationMember> {
                                new OrganizationMember {
                                    Member = member, Organization = existingOrganization
                                }
                            };

                            _memberService.Add(member);
                        }

                        foreach (var memberToRemove in membersToRemove)
                        {
                            _memberService.Remove(memberToRemove);
                        }
                    }
                }

                var currentUser   = await _client.User.Current();
                var currentMember = _memberService.GetMember(currentUser.Id);

                var existingOrganizations = currentMember.Organizations;
                var organizationsToRemove = existingOrganizations.Where(x => organizations.All(z => z.Id != x.Organization.Id));

                foreach (var organizationToRemove in organizationsToRemove)
                {
                    currentMember.Organizations.Remove(organizationToRemove);
                }

                return(true);
            });
        }
        public async Task <ActionResult <Member> > PostMember(Member member)
        {
            await _members.Add(member);

            return(CreatedAtAction(nameof(GetMember), new { id = member.Id }, member));
        }
 public ActionResult AddMember(Member member)
 {
     _memberService.Add(member);
     return(View("Index"));
 }
Exemple #28
0
        public ActionResult Register(RegisterViewModel registerViewModel)
        {
            if (TempData["VerificationCode"] == null || TempData["VerificationCode"].ToString() != registerViewModel.VerificationCode.ToUpper())
            {
                ModelState.AddModelError("VerificationCode", "验证码不正确");
                return(View("Register", registerViewModel));
            }

            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                Member member = new Member
                {
                    User_name  = "",
                    Portrait   = "/Upload/Portrait/1.jpg",
                    Last_login = DateTime.Now,
                    Last_ip    = "1.1.1.1",
                    nickname   = registerViewModel.NickName,
                    Password   = DEncryptUtils.Encrypt3DES(registerViewModel.Password),
                    Status     = 1,
                    Reg_time   = DateTime.Now
                };
                string str = registerViewModel.Email;
                if (RegexUtil.IsMobilePhone(str)) //是用手机号注册
                {
                    if (TempData["SMSCode"] == null || TempData["SMSCode"].ToString() != registerViewModel.SMSCode.ToUpper())
                    {
                        ModelState.AddModelError("SMSCode", "短信验证码不正确");
                        return(View("Register", registerViewModel));
                    }
                    member.Phone_mob = str;
                }
                else //邮箱注册
                {
                    member.Email = str;
                }
                using (TransactionScope ts = new TransactionScope())
                {
                    member = _memberService.Add(member);
                    var lottery = new Lottery()
                    {
                        AcId        = 0,
                        AddTime     = DateTime.Now,
                        LotteryCode = "0",
                        UserId      = member.User_id,
                        Status      = 1
                    };
                    _lotteryService.Add(lottery);
                    ts.Complete();
                }

                if (member.User_id > 0)
                {
                    //return Json(new Dictionary<string, string>() { { "status", "success" }, { "message", "注册成功" } });

                    ViewBag.IsShow = 1;
                    return(View("Register", registerViewModel));
                }
                else
                {
                    //ModelState.AddModelError("", "注册失败!");
                    //return JavaScript("alert('服务器异常,请稍后再试!');");
                    ViewBag.Message = "error";
                    return(View("Register", registerViewModel));
                }
            }
            ViewBag.Message = "error";
            return(View("Register", registerViewModel));
        }
Exemple #29
0
 public async Task <ActionResult <ObjectResult <Member> > > Post([FromBody] Member model)
 {
     return(await _memberService.Add(model));
 }
 public ActionResult Add(Member member)
 {
     _service.Add(member);
     return(View(new MemberAddViewModel()));
 }