Пример #1
0
        public async Task <IActionResult> PutUserAuth(long id, UserAuth userAuth)
        {
            if (id != userAuth.Id)
            {
                return(BadRequest());
            }

            _context.Entry(userAuth).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserAuthExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,AdminEmail,AdminPassword,CreatedDate,LastLogin,IPAddress,UserAgent")] AdminAuth adminAuth)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("_logged")))
            {
                HttpContext.Session.SetString("_logged", "masuk");
            }
            if (ModelState.IsValid)
            {
                var insertdb = new AdminAuth();

                var message = adminAuth.AdminPassword;
                var salt    = Salt.Create();
                var hash    = Hash.Create(message, salt);

                insertdb.AdminEmail    = adminAuth.AdminEmail;
                insertdb.Salt          = salt;
                insertdb.AdminPassword = hash;
                insertdb.CreatedDate   = DateTime.Now;
                insertdb.IPAddress     = adminAuth.IPAddress;
                insertdb.IsActive      = 1;
                insertdb.UserAgent     = Request.Headers["User-Agent"];

                _context.Add(insertdb);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(adminAuth));
        }
Пример #3
0
        public async Task <IActionResult> PutLandingRegistration(long id, LandingRegistration landingRegistration)
        {
            if (id != landingRegistration.Id)
            {
                return(BadRequest());
            }

            _context.Entry(landingRegistration).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LandingRegistrationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Email,SocialMedia,VideoYes,FileUrl,SessionId,RegistrationDate,RegisteredIp,RegisteredUserAgent,UniqueKey,UniqueKeyConfirm,InstagramUrl,FacebookUrl,TwitterUrl,GoogleUrl,LinkedInUrl")] LandingRegistration landingRegistration)
        {
            if (ModelState.IsValid)
            {
                _context.Add(landingRegistration);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(landingRegistration));
        }
Пример #5
0
        public async Task <ActionResult <LandingRegistration> > PostLandingRegistration(LandingRegistrationRequest landingRegistration)
        {
            LandingRegistration ld = new LandingRegistration();

            ld.Name                = landingRegistration.Name;
            ld.Email               = landingRegistration.Email;
            ld.SocialMedia         = landingRegistration.SocialMedia;
            ld.VideoYes            = landingRegistration.VideoYes;
            ld.FileUrl             = landingRegistration.FileUrl;
            ld.SessionId           = Guid.NewGuid().ToString();
            ld.RegistrationDate    = DateTime.Now;
            ld.RegisteredIp        = landingRegistration.RegisteredIp;
            ld.RegisteredUserAgent = landingRegistration.RegisteredUserAgent;
            ld.UniqueKey           = Guid.NewGuid().ToString();
            ld.UniqueKeyConfirm    = false;
            ld.InstagramUrl        = landingRegistration.InstagramUrl;
            ld.FacebookUrl         = landingRegistration.FacebookUrl;
            ld.TwitterUrl          = landingRegistration.TwitterUrl;
            ld.GoogleUrl           = landingRegistration.GoogleUrl;
            ld.LinkedInUrl         = landingRegistration.LinkedInUrl;
            _context.LandingRegistration.Add(ld);

            UserAuth userauth = new UserAuth();

            userauth.Password  = landingRegistration.Password;
            userauth.LastLogin = null;
            userauth.UniqueKey = ld.UniqueKey;
            userauth.Ipaddress = ld.RegisteredIp;
            userauth.UserAgent = ld.RegisteredUserAgent;
            userauth.LoginType = landingRegistration.LoginType;
            userauth.Email     = ld.Email;
            _context.UserAuth.Add(userauth);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLandingRegistration", new { id = ld.Id }, ld));
        }
Пример #6
0
        public async Task <IActionResult> Registration(LandingRegistrationRequest landingRegistration, string reff)
        {
            var landingcheck = _context.LandingRegistration.FirstOrDefault(x => x.Email == landingRegistration.Email);

            if (landingcheck == null)
            {
                var userAgent = Request.Headers["User-Agent"];

                LandingRegistration ld = new LandingRegistration();
                ld.Name                = landingRegistration.Name;
                ld.Email               = landingRegistration.Email;
                ld.SocialMedia         = landingRegistration.SocialMedia;
                ld.VideoYes            = landingRegistration.VideoYes;
                ld.FileUrl             = landingRegistration.FileUrl;
                ld.SessionId           = Guid.NewGuid().ToString();
                ld.RegistrationDate    = DateTime.Now;
                ld.RegisteredIp        = landingRegistration.RegisteredIp;
                ld.RegisteredUserAgent = userAgent;
                ld.UniqueKey           = Guid.NewGuid().ToString();
                ld.UniqueKeyConfirm    = false;
                ld.InstagramUrl        = landingRegistration.InstagramUrl;
                ld.FacebookUrl         = landingRegistration.FacebookUrl;
                ld.TwitterUrl          = landingRegistration.TwitterUrl;
                ld.GoogleUrl           = landingRegistration.GoogleUrl;
                ld.LinkedInUrl         = landingRegistration.LinkedInUrl;

                if (landingRegistration.Referral != null)
                {
                    if (landingRegistration.Referral.Length > 0)
                    {
                        ld.Referral = landingRegistration.Referral;
                    }
                }

                if (landingRegistration.Name.Length < 4)
                {
                    Random rdn   = new Random();
                    int    value = rdn.Next(1000);
                    string text  = value.ToString("000");
                    ld.ReferralCode = landingRegistration.Name + text;
                }
                else
                {
                    Random rdn   = new Random();
                    int    value = rdn.Next(1000);
                    string text  = value.ToString("000");
                    ld.ReferralCode = landingRegistration.Name.ToLower().Substring(0, 4) + text;
                }

                _context.LandingRegistration.Add(ld);

                UserAuth userauth = new UserAuth();

                var message = landingRegistration.Password;
                var salt    = Salt.Create();
                var hash    = Hash.Create(message, salt);

                userauth.Salt      = salt;
                userauth.Password  = hash;
                userauth.LastLogin = null;
                userauth.UniqueKey = ld.UniqueKey;
                userauth.Ipaddress = ld.RegisteredIp;
                userauth.UserAgent = ld.RegisteredUserAgent;
                userauth.LoginType = landingRegistration.LoginType;
                userauth.Email     = ld.Email;
                _context.UserAuth.Add(userauth);

                await _context.SaveChangesAsync();

                //try
                //{
                //    IMailChimpManager mailChimpManager = new MailChimpManager("5d37a4dcc7a09f5bb6b96efbebd41233-us20");
                //    var listId = "1006a7a0f5";
                //    // Use the Status property if updating an existing member
                //    var member = new Member { EmailAddress = landingRegistration.Email, StatusIfNew = Status.Subscribed };
                //    member.MergeFields.Add("FNAME", landingRegistration.Name);
                //    member.MergeFields.Add("LNAME", "");
                //    await mailChimpManager.Members.AddOrUpdateAsync(listId, member);

                //}
                //catch (Exception es)
                //{
                //    ViewBag.Error = es.Message;
                //}

                //send email here
                EmailHelper.SendEmail(ld.Email, ld.Name, ld.ReferralCode);


                if (string.IsNullOrEmpty(HttpContext.Session.GetString("_email")))
                {
                    HttpContext.Session.SetString("_email", landingRegistration.Email);
                    HttpContext.Session.SetString("_idunique", ld.UniqueKey);
                }

                var routeValues = new RouteValueDictionary
                {
                    { "id", ld.UniqueKey }
                };

                return(RedirectToAction(nameof(RegistrationSuccess), routeValues));
            }
            else
            {
                if (string.IsNullOrEmpty(HttpContext.Session.GetString("_error")))
                {
                    HttpContext.Session.SetString("_error", "email Anda sudah pernah terdaftar.");
                }
                return(RedirectToAction(nameof(Error)));
            }
        }