Esempio n. 1
0
        public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)

            { 
                 return RedirectToAction("Index", "Dashboard");
            }
            //Check to see if we can read their profile RSS feed. If not, then id is invalid. Return to page and ask again.
            try
            {
                ParsedFeed profilecheck = new ParsedFeed(model.CustomerID);
            }
            catch
            {
                ViewBag.Error = "There is a problem with that Amazon Profile ID. Please check and try again.";
                ViewBag.ReturnUrl = returnUrl;
                return View(model);
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new ApplicationUser { UserName = model.CustomerID, Email = model.Email, CustomerID = model.CustomerID };
                var result = await UserManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.Id, info.Login);
                    if (result.Succeeded)
                    {
                        await UserManager.AddToRoleAsync(user.Id, "customer");

                        //We're not logging in customer until they verify email
                        //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        Customer customer = new Customer();
                        customer.Email = model.Email;
                        customer.FirstName = model.FirstName;
                        customer.LastName = model.LastName;
                        customer.CustomerID = model.CustomerID;
                        customer.LastReviewCheck = DateTime.Now;
                        customer.JoinDate = DateTime.Now;
                        customer.Qualified = true;
                        db.Customers.Add(customer);
                        db.SaveChanges();

                        string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                        var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);

                        var response = SendEmailConfirmation(user.Email, callbackUrl, false);

                        // Uncomment to debug locally 
                        // TempData["ViewBagLink"] = callbackUrl;



                        return RedirectToAction("Welcome", "Dashboard", new { message = "confirmmail" });

                        //return RedirectToAction("Welcome", "Dashboard");

                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
Esempio n. 2
0
        //Actual Checking mechanism
        public void Check()
        {
            foreach (var ID in CustomersToCheck)
            {
                //Get list of all reviews by customer that are not done.
                List<Review> reviewFeed = (from revs in db.Reviews
                                           where revs.Reviewed.Equals(false)
                                           where revs.CustomerID.Equals(ID)
                                           select revs).ToList();

                //If there are uncompleted reviews, then get the customers
                //Amazon RSS review feed and check to see if review completed.
                if (reviewFeed.Count() > 0)
                {
                    ParsedFeed currentFeed = new ParsedFeed(ID);
                    foreach (Review r in reviewFeed)
                    {
                        foreach (ParsedReview p in currentFeed.FeedReviews)
                        {
                            if (p.ASIN == r.Campaign.ASIN)
                            {
                                r.ReviewDate = p.ReviewDate;
                                r.ProductRating = p.Rating;
                                r.VideoReview = p.HasVideo;
                                r.PhotoReview = p.HasPhoto;
                                r.ReviewLength = p.ReviewLength;
                                r.ReviewLink = p.Link;

                                //We'll mark review as complete now, but do some checks next.
                                r.Reviewed = true;

                                //Checking for various attributes.
                                if(r.ReviewLength < 70)
                                {
                                    r.Reviewed = false;
                                    r.CustomerAlert = "Reviews must be at least 70 words long. Please update your review on Amazon.";
                                }

                                // 1/20/15 Alex asked to NOT check for Verified Purchase as Amazon won't mark all discounted/free items as verified. 
                                //if (!p.VerfiedPurchase)
                                //{
                                //    r.Reviewed = false;
                                //    r.CustomerAlert = "Your review is not marked as a Verified Purchase. " +
                                //        "Reviewers must purchase/test product before reviewing.";
                                //}

                                if(r.ReviewTypeExpected.ToString() == "Photo" && p.HasPhoto == false)
                                {
                                    r.Reviewed = false;
                                    r.CustomerAlert = "You agreed to do a photo review and your review does not appear to have photos. " +
                                        "Please add at least one photo your review on Amazon.";
                                }

                                if (r.ReviewTypeExpected.ToString() == "Video" && p.HasVideo == false)
                                {
                                    r.Reviewed = false;
                                    r.CustomerAlert = "You agreed to do a video review and your review does not appear to have a video. " +
                                        "Please add a video to your review.";
                                }

                                if (!p.HasDisclaimer)
                                {
                                    r.Reviewed = false;
                                    r.CustomerAlert = "Your review does not appear to have included the disclaimer. " +
                                        "Please update your review on Amazon.";
                                }

                                db.Entry(r).State = EntityState.Modified;
                            }
                        }
                    }

                }

                db.SaveChanges();
            }
        }  
Esempio n. 3
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            //Check to see if we can read their profile RSS feed. If not, then id is invalid. Return to page and ask again.
            try
            {
                ParsedFeed profilecheck = new ParsedFeed(model.CustomerID);
            }
            catch
            {
                ViewBag.Error = "There is a problem with that Amazon Profile ID. Please check and try again.";
                return View("Register", model);
            }

            if (db.Customers.Where(u => u.CustomerID == model.CustomerID).Any())
            {
                ViewBag.Error = "That Amazon Profile ID is already in use.";
                return View("Register", model);
            }


            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.CustomerID, Email = model.Email, CustomerID = model.CustomerID };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    //We will not sign in customer immediately. They have to confirm email.
                    //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    Customer customer = new Customer();
                    customer.Email = model.Email;
                    customer.FirstName = model.FirstName;
                    customer.LastName = model.LastName;
                    customer.CustomerID = model.CustomerID;
                    customer.LastReviewCheck = DateTime.Now;
                    customer.JoinDate = DateTime.Now;
                    customer.Qualified = true;
                    db.Customers.Add(customer);
                    db.SaveChanges();

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Email Confirmation
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);

                    var response = SendEmailConfirmation(user.Email, callbackUrl, false);

                    // Uncomment to debug locally 
                    // TempData["ViewBagLink"] = callbackUrl;

                    if (model.BeSeller)
                    {
                        await UserManager.AddToRoleAsync(user.Id, "seller");
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                        return RedirectToAction("CreateSeller", "Seller");
                    }
                    else
                    {
                        //use this for TESTING ONLY
                        //await UserManager.AddToRoleAsync(user.Id, "campaignManager");

                        ////USE THIS FOR LIVE SITE
                        await UserManager.AddToRoleAsync(user.Id, "customer");
                    }

                    return RedirectToAction("Welcome", "Dashboard", new { message = "confirmmail" });

                    //return RedirectToAction("Welcome", "Dashboard");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }