コード例 #1
0
ファイル: Index.cshtml.cs プロジェクト: ichariawilson/____fee
        public IActionResult OnGet()
        {
            var repo = new ProfilesRepository(_context);

            ProfileDisplayList = repo.GetProfiles();
            return(Page());
        }
コード例 #2
0
        public async Task ShouldReturnEmptyProfileList()
        {
            var repo = new ProfilesRepository(_localStorageServiceMock.Object, _migratorMock.Object);

            _migratorMock
            .Setup(x => x.StartMigration(null))
            .ReturnsAsync(new ProfileStorageContainer())
            .Verifiable();

            var profiles = await repo.GetProfiles();

            profiles.Should().BeEmpty();
            _migratorMock.Verify();
        }
コード例 #3
0
        public async Task ShouldReturnProfiles()
        {
            Guid defaultProfileId = Guid.NewGuid();

            _localStorageServiceMock
            .Setup(x => x.GetItemAsync <ProfileStorageContainer>("Profiles"))
            .ReturnsAsync(new ProfileStorageContainer
            {
                Profiles = new List <Profile>
                {
                    new Profile
                    {
                        Id            = defaultProfileId,
                        ProfileName   = "default",
                        FaceApiConfig = new Domain.Profiles.CognitiveServiceConfig
                        {
                            BaseUrl     = "http",
                            ServiceName = "FaceApi",
                            Token       = "t1"
                        }
                    }
                }
            })
            .Verifiable();

            var repo = new ProfilesRepository(_localStorageServiceMock.Object, _migratorMock.Object);

            var profiles = await repo.GetProfiles();

            profiles.Should()
            .SatisfyRespectively(
                first =>
            {
                first.Id.Should().Be(defaultProfileId);
                first.ProfileName.Should().Be("default");
                first.FaceApiConfig.Should().NotBeNull();
                first.FaceApiConfig !.BaseUrl.Should().Be("http");
                first.FaceApiConfig.ServiceName.Should().Be("FaceApi");
                first.FaceApiConfig.Token.Should().Be("t1");
            });

            _migratorMock.Verify(x => x.StartMigration(It.IsAny <ProfileStorageContainer>()), Times.Never);
            _localStorageServiceMock.Verify();
        }
コード例 #4
0
ファイル: PlanesController.cs プロジェクト: goc00/freemium
        public ActionResult Index(string form, string user, string country)
        {
            //validaciones iniciales
            if (String.IsNullOrWhiteSpace(form))
            {
                throw new HttpException(404, "Debes indicar el parametro FORM");
            }

            if (String.IsNullOrWhiteSpace(user))
            {
                throw new HttpException(404, "Debes indicar el parametro USER");
            }



            ViewBag.Pais       = country;
            ViewBag.Formulario = form;

            //obtengo el formulario
            var formulario = productsFormsRepository.GetProductForm(form);

            if (formulario == null)
            {
                throw new HttpException(404, "Formulario no existe");
            }

            if (formulario.IdProduct == null)
            {
                throw new HttpException(404, "Formulario no relacionado a un producto");
            }

            if (!usersRepository.UserExist(user, (int)formulario.IdProduct))
            {
                // throw new HttpException(404, "El usuario no existe para este producto");
                //usersRepository.CreateUser(user, (int)formulario.IdProduct);
            }


            //obtengo listado de perfiles
            var perfiles = profilesRepository.GetProfiles((int)formulario.IdProduct).Where(e => e.Featured == true);

            //obtengo perfiles del servicio de COBRO
            var cobros = cobrosRepository.GetCobros((int)formulario.IdProduct); //IDAPP es IDPROD

            List <Planes> planes = new List <Planes>();

            foreach (var item in perfiles)
            {
                var cobro = cobros.FirstOrDefault(e => e.IdPlan == item.IdProfile && e.Principal == 1);

                planes.Add(new Planes
                {
                    Nombre           = item.Name,
                    Valor            = (cobro != null)? cobro.Monto : "-",
                    Plan             = item.IdProfile,
                    Caracteristicas  = item.Description.Split(','),
                    Featured         = item.Featured == null ? false : (bool)item.Featured,
                    Motivator        = item.MotivatorText,
                    ShortDescription = item.ShortDescription,
                });
            }

            ViewBag.User = user;

            //obtengo usuario
            var u = usersRepository.GetUser(user, (int)formulario.IdProduct);

            //obtengo suscripcion actual del usuario
            var subs = subscriptionsRepository.GetUserCurrentSubscription(u.IdUser);

            int IdProfile = 0;

            if (subs == null)
            {
                //si no tiene suscripcion, le crea una en el estándar de suscrito sin suscripción.
                var profile = profilesRepository.GetStandardFreeSuscription(u.IdUser);
                IdProfile = profile.IdProfile;
            }
            else
            {
                IdProfile = (int)subs.IdProfile;

                if (subs.PromoActive == true)
                {
                    ViewBag.ActivePromo = 1;
                }
            }

            //datos del formulario
            ViewBag.UrlLogo          = formulario.UrlLogo;
            ViewBag.UrlBackground    = formulario.UrlBackground;
            ViewBag.ColorSuperiorBar = formulario.ColorSuperiorBar;
            ViewBag.CssClassFeatured = formulario.CssClassFeatured;
            ViewBag.CssClassActual   = formulario.CssClassActual;
            ViewBag.TitleColor       = formulario.TitleColor;
            ViewBag.FormTitle        = formulario.Title;
            ViewBag.CurrentIdProfile = IdProfile;

            return(View(planes));
        }