Esempio n. 1
0
        public static HtmlString RestaurantStateBadge(this IHtmlHelper html, RestaurantState state)
        {
            string stateBadge = "";

            switch (state)
            {
            case RestaurantState.Unknown:
                stateBadge = string.Format(Constants.BadgeMarkup, "secondary", RestaurantState.Unknown);
                break;

            case RestaurantState.Open:
                stateBadge = string.Format(Constants.BadgeMarkup, "success", RestaurantState.Open);
                break;

            case RestaurantState.Close:
                stateBadge = string.Format(Constants.BadgeMarkup, "danger", RestaurantState.Close);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }

            return(new HtmlString(stateBadge));
        }
Esempio n. 2
0
        private void CreateRestaurant(UserManager <IdentityUser> userManager, string email, string role, RestaurantState state)
        {
            Task <IdentityUser> testUser = userManager.FindByEmailAsync(email);

            testUser.Wait();

            if (testUser.Result == null)
            {
                Restaurant user = new Restaurant();
                user.Email    = email;
                user.UserName = email;
                user.Address  = "Kaunas";
                user.Name     = "Liuks";
                user.State    = state;

                Task <IdentityResult> newUser = userManager.CreateAsync(user, "password");
                newUser.Wait();

                if (newUser.Result.Succeeded)
                {
                    Task <IdentityResult> newUserRole = userManager.AddToRoleAsync(user, role);
                    newUserRole.Wait();
                }
            }
        }