Ejemplo n.º 1
0
        public RedirectToRouteResult ContinueBuilding(string Flavor1Id, string Flavor2Id)
        {
            List <FashionFlavor> selectedFF = new List <FashionFlavor>();

            selectedFF.Add(fashionFlavorRepository.Get(Convert.ToInt32(Flavor1Id)));
            if (!string.IsNullOrEmpty(Flavor2Id))
            {
                selectedFF.Add(fashionFlavorRepository.Get(Convert.ToInt32(Flavor2Id)));
            }

            ClosetState.SetFlavors(selectedFF);

            if (selectedFF.Count < 2)
            {
                IList <UserFlavor> userFlavors = new List <UserFlavor>();
                if (selectedFF != null)
                {
                    userFlavors.Add(new UserFlavor(selectedFF[0], Convert.ToDecimal(100)));
                    ClosetState.SetUserFlavors(userFlavors);
                }

                Session["previousUrl"] = "FlavorSelect";
                return(RedirectToAction("EventTypeSelector"));
            }

            return(RedirectToAction("Index", "FlavorWeight"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Se ejecuta cuando el usuario termino de seleccionar sus Flavors a través del asistente.
        /// </summary>
        /// <param name="Flavor1Id">Id del primer flavor que dio como resultado el Quiz.</param>
        /// <param name="Flavor2Id">Id del segundo flavor que dio como resultado el Quiz.</param>
        /// <returns>Si el asistente devuelve:
        ///             - 1 Flavor:  Actualiza los flavos con el flavor resultante.
        ///             - 2 Flavors: Rediecciona a la página de FlavorWeight.
        /// <returns>
        public ActionResult QuizCompleted(string Flavor1Id, string Flavor2Id)
        {
            List <FashionFlavor> selectedFF = new List <FashionFlavor>();

            selectedFF.Add(fashionFlavorRepository.Get(Convert.ToInt32(Flavor1Id)));
            if (!string.IsNullOrEmpty(Flavor2Id))
            {
                selectedFF.Add(fashionFlavorRepository.Get(Convert.ToInt32(Flavor2Id)));
            }

            ClosetState.SetFlavors(selectedFF);

            if (selectedFF.Count < 2)
            {
                IList <UserFlavor> userFlavors = new List <UserFlavor>();
                if (selectedFF != null)
                {
                    userFlavors.Add(new UserFlavor(selectedFF[0], Convert.ToDecimal(100)));
                    ClosetState.SetUserFlavors(userFlavors);
                }

                Session["previousUrl"] = "FlavorSelect";
                return(RedirectToAction("UpdateUserFlavors", new { Flavor1Weight = 100 }));
            }

            return(RedirectToAction("Index", "FlavorWeight"));
        }
Ejemplo n.º 3
0
        public ActionResult QuizCompleted(string Flavor1Id, string Flavor2Id)
        {
            List <FashionFlavor> selectedFF = new List <FashionFlavor>();

            selectedFF.Add(fashionFlavorRepository.Get(Convert.ToInt32(Flavor1Id)));
            if (!string.IsNullOrEmpty(Flavor2Id))
            {
                selectedFF.Add(fashionFlavorRepository.Get(Convert.ToInt32(Flavor2Id)));
            }

            ClosetState.SetFlavors(selectedFF);

            if (selectedFF.Count == 1)
            {
                IList <UserFlavor> userFlavors = new List <UserFlavor>();
                if (selectedFF != null)
                {
                    userFlavors.Add(new UserFlavor(selectedFF[0], Convert.ToDecimal(100)));
                    ClosetState.SetUserFlavors(userFlavors);
                }

                return(RedirectToAction("Index", "EventTypeSelector"));
            }
            else
            {
                return(RedirectToAction("Index", "FlavorWeight"));
            }
        }
    protected void Initialize()
    {
        StateBathroom = GetComponentInChildren(typeof(BathroomState)) as BathroomState;
        StateKitchen = GetComponentInChildren(typeof(KitchenState)) as KitchenState;
        StateBedroom = GetComponentInChildren(typeof(BedroomState)) as BedroomState;
        StateCloset = GetComponentInChildren(typeof(ClosetState)) as ClosetState;

        FSM = new FiniteStateMachine<MovingVoice>(this);
    }
Ejemplo n.º 5
0
    protected void Initialize()
    {
        StateBathroom = GetComponentInChildren(typeof(BathroomState)) as BathroomState;
        StateKitchen  = GetComponentInChildren(typeof(KitchenState)) as KitchenState;
        StateBedroom  = GetComponentInChildren(typeof(BedroomState)) as BedroomState;
        StateCloset   = GetComponentInChildren(typeof(ClosetState)) as ClosetState;

        FSM = new FiniteStateMachine <MovingVoice>(this);
    }
Ejemplo n.º 6
0
        public ActionResult GoToRegistration(string myGarmentsItems, string myWishListItems)
        {
            string[] myGarmentsArray = myGarmentsItems.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string[] myWishListArray = myWishListItems.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            ClosetState.SetAddGarments((from s in myGarmentsArray select Convert.ToInt32(s)).ToList <int>());
            ClosetState.SetWishGarments((from s in myWishListArray select Convert.ToInt32(s)).ToList <int>());

            return(RedirectToAction("Index", "Registration"));
        }
Ejemplo n.º 7
0
        public RedirectToRouteResult Validate(string validationCode)
        {
            if (_invitationValidatorService.IsValidCode(validationCode))
            {
                ClosetState.SetInvitationCode(validationCode);
                return(RedirectToAction("Index", "FlavorSelect"));
            }

            TempData["error"] = "Your invitation code is not valid.";
            return(RedirectToAction("Index", "Home"));
        }
        public RedirectToRouteResult SelectEventType(FormCollection values)
        {
            List <EventType> selectedET = new List <EventType>();

            foreach (var value in values)
            {
                object o = values[value.ToString()];
                if (o.ToString().Contains("true"))
                {
                    selectedET.Add(eventTypeRepository.Get(Convert.ToInt32(value.ToString().Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries)[2])));
                }
            }

            ViewData.Model = selectedET;
            ClosetState.SetEventTypes(selectedET);

            return(RedirectToAction("Index", "GarmentSelector"));
        }
Ejemplo n.º 9
0
        public RedirectToRouteResult SelectFashionFlavor(FormCollection values)
        {
            List <FashionFlavor> selectedFF = new List <FashionFlavor>();

            foreach (var value in values)
            {
                object o = values[value.ToString()];
                if (o.ToString().Contains("true"))
                {
                    selectedFF.Add(fashionFlavorRepository.Get(Convert.ToInt32(value.ToString().Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries)[2])));
                }
            }

            if (ClosetState.Flavors != null)
            {
                foreach (FashionFlavor fashionFlavor in selectedFF)
                {
                    if (ClosetState.Flavors.Count != selectedFF.Count || !ClosetState.Flavors.Contains(fashionFlavor))
                    {
                        ClosetState.ClearGarments();
                    }
                }
            }

            ClosetState.SetFlavors(selectedFF);
            if (selectedFF.Count < 2)
            {
                IList <UserFlavor> userFlavors = new List <UserFlavor>();
                userFlavors.Add(new UserFlavor(selectedFF[0], Convert.ToDecimal(100)));
                ClosetState.SetUserFlavors(userFlavors);
                ViewData.Model = userFlavors;

                Session["previousUrl"] = "FlavorSelect";

                return(((bool)Session["updateFlavors"])
                    ? RedirectToAction("UpdateUserFlavors", "FlavorChange", new { Flavor1Weight = 100 })
                    : RedirectToAction("Index", "EventTypeSelector"));
            }

            return(RedirectToAction("Index", "FlavorWeight"));
        }
Ejemplo n.º 10
0
        public ActionResult SaveSelection(UserGarmentSelection userGarmentSelection)
        {
            List <int> garmentsSelected     = new List <int>();
            List <int> wishGarmentsSelected = new List <int>();

            foreach (string id in userGarmentSelection.GarmentSelectedIds)
            {
                garmentsSelected.Add(Convert.ToInt32(id));
            }

            foreach (string id in userGarmentSelection.WishGarmentSelectedIds)
            {
                wishGarmentsSelected.Add(Convert.ToInt32(id));
            }

            ClosetState.SetAddGarments(garmentsSelected);
            ClosetState.SetWishGarments(wishGarmentsSelected);

            ViewData.Model = userGarmentSelection;

            return(Json(true));
        }
Ejemplo n.º 11
0
        public RedirectToRouteResult SetWeight(string Flavor1Weight, string Flavor2Weight, FormCollection values)
        {
            IList <FashionFlavor> flavors     = ClosetState.Flavors;
            IList <UserFlavor>    userFlavors = new List <UserFlavor>();

            if (flavors != null)
            {
                if (!string.IsNullOrEmpty(Flavor1Weight))
                {
                    userFlavors.Add(new UserFlavor(flavors[0], Convert.ToDecimal(Flavor1Weight)));
                }
                if (!string.IsNullOrEmpty(Flavor2Weight))
                {
                    userFlavors.Add(new UserFlavor(flavors[1], Convert.ToDecimal(Flavor2Weight)));
                }

                ClosetState.SetUserFlavors(userFlavors);
            }

            ViewData.Model         = userFlavors;
            Session["previousUrl"] = "FlavorWeight";

            return(RedirectToAction("Index", "EventTypeSelector"));
        }
Ejemplo n.º 12
0
        public ActionResult Register(UserRegistration userRegistration)
        {
            if (ModelState.IsValid)
            {
                IList <UserFlavor> userFlavors    = ClosetState.UserFlavors as List <UserFlavor>;
                IList <EventType>  eventTypes     = ClosetState.EventTypes as List <EventType>;
                IList <Garment>    mygarments     = garmentRepository.GetByIds(ClosetState.AddGarments) as List <Garment>;
                IList <Garment>    mywishlist     = garmentRepository.GetByIds(ClosetState.WishGarments) as List <Garment>;
                string             channel        = ClosetState.Channel;
                string             invitationCode = ClosetState.InvitationCode;

                SecurityQuestion sq = securityQuestionRepository.Get(Convert.ToInt32(userRegistration.SecurityQuestion));

                // Create Membership User
                MembershipCreateStatus status;
                MembershipUser         mu = Membership.CreateUser(userRegistration.UserName, userRegistration.Password, userRegistration.Email, sq.Description, userRegistration.SecurityAnswer, false, out status);
                if (status != MembershipCreateStatus.Success)
                {
                    ViewData["Errors"] = new string[] { status.ToString() }
                }
                ;

                try
                {
                    bool mustConfirmMail = registerMemberService.RegisterMember(userRegistration.Email,
                                                                                userRegistration.UserName, userRegistration.FirstName, userRegistration.LastName,
                                                                                userRegistration.Password,
                                                                                new UserSize(Convert.ToInt32(userRegistration.UserSize)),
                                                                                Convert.ToInt32(mu.ProviderUserKey),
                                                                                userRegistration.ZipCode,
                                                                                userFlavors,
                                                                                eventTypes,
                                                                                mygarments,
                                                                                mywishlist,
                                                                                Url.Action("Validate", "EmailConfirmation"),
                                                                                channel,
                                                                                invitationCode);

                    // Assign User Role
                    Roles.AddUserToRole(mu.UserName, "User");

                    if (mustConfirmMail)
                    {
                        ClosetState.Clear();
                        return(RedirectToAction("Index", "EmailConfirmation", new { userid = mu.ProviderUserKey }));
                    }

                    //The user already confirmed his email, so we need to approve him and go to the login
                    // Approve on Membership
                    mu.IsApproved = true;
                    Membership.UpdateUser(mu);

                    RegisteredUser ru =
                        registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey));

                    // Approve on System
                    ru.Confirm();
                    ru.Closet.PrivacyLevel = PrivacyLevel.FullCloset;
                    registeredUserRepository.SaveOrUpdate(ru);

                    ClosetState.Clear();
                    return(RedirectToAction("Index", "Login", new { validatedUser = true }));
                }
                catch (Exception ex)
                {
                    // Try to delete the incomplete created user because something went wrong.
                    try { Membership.DeleteUser(userRegistration.UserName); }
                    catch { }

                    if (ex is InvalidInvitationCodeException)
                    {
                        ModelState.AddModelError("InvitationCode", "The code is not valid or already used.");
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            else
            {
                if (new List <ModelState>(ModelState.Values).Find(e => e.Value == null).Errors[0].ErrorMessage.StartsWith("Email"))
                {
                    ModelState.AddModelError("Email", "Email does not match.");
                }
                else
                {
                    ModelState.AddModelError("Password", "Password does not match.");
                }
            }

            GetRegistrationInfo(userRegistration);
            return(View("Index", userRegistration));
        }
Ejemplo n.º 13
0
 public RedirectToRouteResult SaveTempData(UserRegistration userRegistration)
 {
     ClosetState.SetUserRegistration(new UserRegistrationSerializable(userRegistration));
     //Response.Redirect(Url.RouteUrl(new { controller = "EventTypeSelector", action= "Index"}));
     return(RedirectToAction("Index", "GarmentSelector"));
 }