Ejemplo n.º 1
0
        public async Task <IActionResult> EditClient(ClientItemViewModel clientModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("EditClient", new { siteId = clientModel.SiteId, clientId = clientModel.ClientId }));
            }

            Guid siteId = siteManager.CurrentSite.Id;

            if (!string.IsNullOrEmpty(clientModel.SiteId) && clientModel.SiteId.Length == 36)
            {
                siteId = new Guid(clientModel.SiteId);
            }
            var selectedSite = await siteManager.GetSiteForDataOperations(siteId);

            var client = await clientsManager.FetchClient(selectedSite.Id.ToString(), clientModel.ClientId);

            if (client == null)
            {
                this.AlertDanger(sr["Client not found"], true);
                return(RedirectToAction("Index", new { siteId = selectedSite.Id.ToString() }));
            }

            client.AbsoluteRefreshTokenLifetime = clientModel.AbsoluteRefreshTokenLifetime;
            client.AccessTokenLifetime          = clientModel.AccessTokenLifetime;
            client.AccessTokenType = clientModel.AccessTokenType;
            //client.AllowAccessToAllScopes = clientModel.AllowAccessToAllScopes;
            client.AllowAccessTokensViaBrowser = clientModel.AllowAccessTokensViaBrowser;
            client.AllowRememberConsent        = clientModel.AllowRememberConsent;
            client.AlwaysSendClientClaims      = clientModel.AlwaysSendClientClaims;
            client.AuthorizationCodeLifetime   = clientModel.AuthorizationCodeLifetime;
            client.ClientName                        = clientModel.ClientName;
            client.ClientUri                         = clientModel.ClientUri;
            client.Enabled                           = clientModel.Enabled;
            client.EnableLocalLogin                  = clientModel.EnableLocalLogin;
            client.IdentityTokenLifetime             = clientModel.IdentityTokenLifetime;
            client.IncludeJwtId                      = clientModel.IncludeJwtId;
            client.LogoUri                           = clientModel.LogoUri;
            client.FrontChannelLogoutSessionRequired = clientModel.FrontChannelLogoutSessionRequired;
            client.FrontChannelLogoutUri             = clientModel.FrontChannelLogoutUri;
            client.BackChannelLogoutSessionRequired  = clientModel.BackChannelLogoutSessionRequired;
            client.BackChannelLogoutUri              = clientModel.BackChannelLogoutUri;
            client.PrefixClientClaims                = clientModel.PrefixClientClaims;
            client.RefreshTokenExpiration            = clientModel.RefreshTokenExpiration;
            client.RefreshTokenUsage                 = clientModel.RefreshTokenUsage;
            client.RequireClientSecret               = clientModel.RequireClientSecret;
            client.RequireConsent                    = clientModel.RequireConsent;
            client.RequirePkce                       = clientModel.RequirePkce;
            client.SlidingRefreshTokenLifetime       = clientModel.SlidingRefreshTokenLifetime;
            client.UpdateAccessTokenClaimsOnRefresh  = clientModel.UpdateAccessTokenClaimsOnRefresh;

            await clientsManager.UpdateClient(selectedSite.Id.ToString(), client);

            var successFormat = sr["The Client <b>{0}</b> was successfully updated."];

            this.AlertSuccess(string.Format(successFormat, client.ClientId), true);

            return(RedirectToAction("EditClient", new { siteId = selectedSite.Id.ToString(), clientId = client.ClientId }));
        }
Ejemplo n.º 2
0
 public ClientItemViewModelTest()
 {
     clientItemViewModel = new ClientItemViewModel(new ClientModel()
     {
         _id        = 1,
         _firstName = "DummyName",
         _lastName  = "DummyLastName"
     });
 }
Ejemplo n.º 3
0
        public IActionResult RecommendWine(string document)
        {
            document = document.Remove(11, 1).Insert(11, ".");
            var client = GetClientsWithHistoryShop().Find(c => c.Document == document);

            if (client == null)
            {
                return(PartialView("_PartialRecommendWine", new ClientItemViewModel {
                    NotFound = true
                }));
            }

            var viewModel = new ClientItemViewModel
            {
                Document = client.Document,
                Name     = client.Name
            };

            var repeatedItems = client.ShopHistory.SelectMany(sH => sH.Items).GroupBy(i => i.Code)
                                .Where(c => c.Count() > 1)
                                .Select(y => new ItemModel {
                Code = y.Key, Counter = y.Count()
            });

            var reccomended = repeatedItems.OrderByDescending(c => c.Counter).ElementAtOrDefault(1);

            if (reccomended != null)
            {
                viewModel.Item = FindItemByCode(reccomended.Code);
            }
            else
            {
                repeatedItems = client.ShopHistory.SelectMany(sH => sH.Items).GroupBy(i => i.Product)
                                .Where(c => c.Count() > 1)
                                .Select(y => new ItemModel {
                    Product = y.Key, Counter = y.Count()
                });

                reccomended = repeatedItems.OrderByDescending(c => c.Counter).ElementAtOrDefault(1);

                viewModel.Item = FindItemByProduct(reccomended.Product);
            }

            return(PartialView("_PartialRecommendWine", viewModel));
        }