Exemplo n.º 1
0
        public ActionResult SelectStore(SelectStoreViewModel _model)
        {
            if (_model.State.FBSignedRequest == null)
                return new RedirectResult("/");

            // load contact from storage
            Contact contact = contactRepository.GetFromFacebookId(_model.State.FBUserId);

            if (contact == null)
                return new RedirectResult("/");

            if (contactRepository.IsRegistered(_model.State.FBUserId))
                return RedirectToAction("RegisterComplete");

            if (ModelState.IsValid)
            {
                contact.StoreNumber = _model.StoreNumber;
                contact.Registered = true;
                contactRepository.Save(contact);

                QueueContact(contact);
                return RedirectToAction("RegisterComplete");
            }

            return View(_model);
        }
Exemplo n.º 2
0
        public ActionResult SelectStore(string _fbsignedRequest, string _fbuserid)
        {
            if (_fbsignedRequest == null)
                return new RedirectResult("/");

            // load contact from storage
            Contact contact = contactRepository.GetFromFacebookId(_fbuserid);

            if (contactRepository.IsRegistered(_fbuserid))
                return RedirectToAction("RegisterComplete");

            // load nearby stores
            IList<Store> nearbyStores = storeRepository.GetNearbyStores(contact.Zip);

            if (nearbyStores.Count <= 1)
            {
                // Select this one store and move on automatically.
                if (nearbyStores.Count == 1)
                {
                    contact.StoreNumber = nearbyStores[0].PartitionKey;
                }
                contact.Registered = true;
                contactRepository.Save(contact);

                QueueContact(contact);
                return RedirectToAction("RegisterComplete");
            }
            else
            {
                SelectStoreViewModel model = new SelectStoreViewModel()
                {
                    NearbyStores = nearbyStores,
                    StoreNumber = nearbyStores[0].PartitionKey,
                    State = new StateData { FBSignedRequest = _fbsignedRequest, FBUserId = _fbuserid }
                };

                // have user pick a favorite store.
                return View(model);
            }
        }