public ActionResult Administrar()
 {
     if ((string)Session["User"] != "Anonymous" && (string)Session["Role"] == "admin")
     {
         var clasificados      = _readOnlyRepository.GetAll <Classified>().ToList();
         var clasif            = clasificados.Where(x => x.DesactivadoPorAdmin == false).ToList();
         var clasifar          = clasificados.Where(x => x.DesactivadoPorAdmin).ToList();
         var preguntas         = _readOnlyRepository.GetAll <QuestionAnswer>().ToList();
         var preg              = preguntas.Where(x => x.Archived == false).ToList();
         var pregar            = preguntas.Where(x => x.Archived).ToList();
         var preguntasUsuarios = _readOnlyRepository.GetAll <ContactUserInfo>().ToList();
         var preguser          = preguntasUsuarios;
         var admin             = new AdminModel
         {
             Clasificados             = clasif,
             ClasificadosDesactivados = clasifar,
             Preguntas             = preg,
             PreguntasDesactivadas = pregar,
             PreguntasUsuarios     = preguser,
         };
         return(View(admin));
     }
     this.AddNotification("Pagina no existe!", NotificationType.Error);
     return(RedirectToAction("Login", "Account"));
 }
示例#2
0
        public ActionResult CreateClassified(ClassifiedModel model)
        {
            if (ModelState.IsValid)
            {
                var validate        = new IValidate();
                var user            = _readOnlyRepository.FirstOrDefault <AccountLogin>(x => x.Email == HttpContext.User.Identity.Name);
                var classifiedsList = user.AccountClassifieds.ToList();

                classifiedsList.Add(new Classifieds(model.Category, model.Article, model.ArticleModel, model.Location,
                                                    model.Price, model.Description, user.Email, model.UrlImage, model.UrlImage1, model.UrlImage2, model.UrlImage3, model.UrlImage4, validate.Embed(model.UrlVideo)));

                user.AccountClassifieds = classifiedsList;
                _writeOnlyRepository.Update(user);

                var notifyList = _readOnlyRepository.GetAll <Subscriptions>().Where(x => x.Following == user.Id && !x.Archived);

                if (!notifyList.Any())
                {
                    foreach (var x in notifyList)
                    {
                        var userToBeNotify = _readOnlyRepository.FirstOrDefault <AccountLogin>(z => z.Id == x.Follower);
                        var list           = userToBeNotify.Notifications.ToList();
                        list.Add(new Notifications(user.Email, model.Article, "Classi"));
                        userToBeNotify.Notifications = list;
                        _writeOnlyRepository.Update(userToBeNotify);
                    }
                }

                //check
                MessageBox.Show("Classified added successfully");
            }

            return(View("CreateClassified", model));
        }
示例#3
0
        private SingleResult <TEntity> Get()
        {
            var keyPredicate = CreateKeysPredicate(GetKeysFromPath());

            IQueryable <TEntity> result = repository.GetAll().Where(keyPredicate);

            return(SingleResult.Create(result));
        }
        //
        // GET: /Calculadora/
        public ActionResult Index()
        {
            var calculadora = new Calculadora
            {
                Operaciones = _readOnlyRepository.GetAll <Operaciones>().ToList()
            };

            return(View(calculadora));
        }
示例#5
0
        public ActionResult FAQ()
        {
            var questionsList = _readOnlyRepository.GetAll <Questions>().Where(x => !x.Archived).ToList();
            var questionModel = new QuestionModel();

            questionsList.Reverse();
            questionModel.QuestionList = questionsList;

            return(View(questionModel));
        }
示例#6
0
        public ActionResult ManageClassifieds()
        {
            var allUser = _readOnlyRepository.GetAll <AccountLogin>().ToList();
            var model   = new ManageUModel
            {
                UserList = allUser,
            };


            return(View(model));
        }
示例#7
0
        public ActionResult NewClassified(ClassifiedModel clasificado)
        {
            if (ModelState.IsValid)
            {
                switch (ValidateImagesVideo(clasificado))
                {
                case true:
                    break;

                case false:
                    return(View(clasificado));
                }
                var user    = (string)Session["User"];
                var usuario = _readOnlyRepository.FirstOrDefault <User>(x => x.Nombre == user);
                clasificado.IdUsuario = usuario.Id;
                var classified = new Classified
                {
                    FechaCreacion = DateTime.Now.ToString("d"),
                    Titulo        = clasificado.Titulo,
                    Categoria     = clasificado.Categoria,
                    IdUsuario     = clasificado.IdUsuario,
                    Negocio       = clasificado.Negocio,
                    Descripcion   = clasificado.Descripcion,
                    Precio        = clasificado.Precio,
                    UrlVideo      = clasificado.UrlVideo,
                    UrlImg0       = clasificado.UrlImg0,
                    UrlImg1       = clasificado.UrlImg1,
                    UrlImg2       = clasificado.UrlImg2,
                    UrlImg3       = clasificado.UrlImg3,
                    UrlImg4       = clasificado.UrlImg4,
                    UrlImg5       = clasificado.UrlImg5,
                    Recomendado   = 1
                };

                _writeOnlyRepository.Create(classified);
                usuario.TotalClasificados += 1;
                _writeOnlyRepository.Update(usuario);
                var subscriptions = _readOnlyRepository.GetAll <Suscribtions>().ToList();
                foreach (var sus in subscriptions)
                {
                    var subs = _readOnlyRepository.GetById <User>(sus.IdUsuarioSuscrito);
                    TwilioService.SendSmsToSubscribers(subs.Nombre, classified.Titulo, usuario.Nombre);
                }

                this.AddNotification("Clasificado registrado.", NotificationType.Success);
                return(RedirectToAction("Index", "Home"));
            }
            this.AddNotification("No se pudo crear clasificado.", NotificationType.Error);
            return(View(clasificado));
        }
        public ActionResult Index()
        {
            HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie != null)
            {
                FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
                var user = _readOnlyRepository.FirstOrDefault <User>(x => x.Email == authTicket.UserData);
                if (user != null)
                {
                    var model    = new ProjectListModel();
                    var typelist =
                        from ProjectEntity ute in _readOnlyRepository.GetAll <ProjectEntity>()
                        where ute.UserId == user.Id && !ute.Archived
                        select ute;
                    var typeList = new List <ProjectEntity>(typelist);
                    model.ProjectList = new List <ProjectListModel>();
                    foreach (var tL in typeList)
                    {
                        model.ProjectList.Add(new ProjectListModel
                        {
                            ProjectId          = tL.Id,
                            ProjectName        = tL.ProjectName,
                            ProjectDescription = tL.ProjectDescription
                        });
                    }
                    return(View(model));
                }
            }
            return(RedirectToAction("Logout", "User"));
        }
示例#9
0
        public ActionResult PackageList()
        {
            //if (Session["userType"].ToString() != "Admin")
            //{
            //    return null;
            //}

            var packages          = _readOnlyRepository.GetAll <Package>();
            var packagesModelList = new List <PackageModel>();

            if (!packages.Any())
            {
                packagesModelList.Add(new PackageModel {
                    Name = "Create packages"
                });
                return(View(packagesModelList));
            }

            foreach (var package in packages)
            {
                packagesModelList.Add(new PackageModel
                {
                    Id            = package.Id,
                    IsArchived    = package.IsArchived,
                    Name          = package.Name,
                    Description   = package.Description,
                    Price         = package.Price,
                    DaysAvailable = package.DaysAvailable,
                    SpaceLimit    = package.SpaceLimit
                });
            }

            return(View(packagesModelList));
        }
        public ActionResult Index()
        {
            if (Session["User"] == null)
            {
                Session["User"] = "******";
            }
            if (Session["Role"] == null)
            {
                Session["Role"] = "Anonymous";
            }
            var index = new IndexModel
            {
                ClasificadosRecientes    = new List <Classified>(5),
                ClasificadosDestacados   = new List <Classified>(5),
                ClasificadosRecomendados = new List <Classified>(11)
            };

            var clasificados = _readOnlyRepository.GetAll <Classified>().Where(x => x.Archived == false && x.DesactivadoPorAdmin == false).ToArray();
            var desc         = from s in clasificados
                               orderby s.Visitas descending
                               select s;
            var desc1 = from s in clasificados
                        orderby s.Recomendado ascending
                        select s;


            var cont = clasificados.Length;

            GetClasificadosRecientes(index, cont, clasificados);
            GetClasificadosDestacados(cont, desc, index);
            GetClasificadosRecomendados(desc1, index);


            return(View(index));
        }
示例#11
0
        public IList <UserAppModel> GetAllUsers()
        {
            IReadOnlyRepository <DtoUser>          readOnlyRepository = repositoryFactory.CreateReadOnlyUsersRepository();
            IEnumerable <DtoUser>                  users  = readOnlyRepository.GetAll();
            AbstractMapper <DtoUser, UserAppModel> mapper = mapperFactory.Create <DtoUser, UserAppModel>();

            return(mapper.Map(users));
        }
示例#12
0
        private static TEntity[] GetData <TEntity>(IReadOnlyRepository <TEntity> repository) where TEntity : IEntity
        {
            var data = repository.GetAll();

            //TODO: do smth

            return(data);
        }
示例#13
0
            public IReport <NotaFiscal> GerarRelatorio()
            {
                // Agora dependo de um repositório somente leitura e estou seguro de que
                // caso qualquer operação de escrita sofra modificações não sofrerei de efeitos colaterais.
                var notas = _repository.GetAll <NotaFiscal>();

                return(new Report <NotaFiscal>(notas));
            }
示例#14
0
        public async Task <GetDistributionsResponse> GetAll()
        {
            IList <DistributionReadModel> result = await distributionsRepository.GetAll();

            return(new GetDistributionsResponse {
                Distributions = mapper.Map <IList <DistributionDto> >(result)
            });
        }
示例#15
0
            private async Task <IList <DistributionReadModel> > GetByFilter(DistributionsFilter filter)
            {
                if (filter.SelectedDistributions.IsEmpty())
                {
                    return(await distributionRepository.GetAll());
                }

                return(await distributionRepository.QueryAll(x => filter.SelectedDistributions.Contains(x.Id)));
            }
示例#16
0
 private void InitializeMaxId()
 {
     _maxId = 0;
     if (_repository.Count > 0)
     {
         _maxId = _repository.GetAll().Max((entity) => entity.Id);
     }
     _maxId++;
 }
示例#17
0
 public ProductData GetProductList()
 {
     return(new ProductData
     {
         LawnMowers = _lawnMowerRepository.GetAll(),
         PhoneCases = _phoneCaseRepository.GetAll(),
         TShirts = _tShirtRepository.GetAll()
     });
 }
示例#18
0
        //
        // GET: /Empleados/
        public ActionResult Index()
        {
            var usersList = _readOnlyRepository.GetAll <Empleado>();
            var deptos    = _readOnlyRepository.GetAll <Departamento>();

            var castedList = new List <EmpleadoModel>();

            foreach (var account in usersList)
            {
                var emp = Mapper.Map <EmpleadoModel>(account);
                if (emp.Departamento_id != 0)
                {
                    emp.Departamento_Name = deptos.FirstOrDefault(x => x.Id == emp.Departamento_id).Nombre;
                }

                castedList.Add(emp);
            }

            return(View(castedList));
        }
        public override void GetAll(BusinessObject sender, BusinessConsultEventArgs args)
        {
            IReadOnlyRepository <DtoUser> repository = repositoryFactory.CreateReadOnlyUsersRepository();
            List <User> list = new List <User>();

            foreach (DtoUser dto in repository.GetAll())
            {
                list.Add(new User(dto.ID, dto.UserName, dto.Hash, dto.Active, sender.GetBusinessEvents()));
            }
            args.result = list;
        }
示例#20
0
        public List <HUTModels.Person> GetAll()
        {
            List <HUTModels.Person> persons = repo.GetAll <HUTDataAccessLayerSQL.Person>()
                                              .Select(x => new HUTModels.Person()
            {
                PersonId = x.PersonId, Firstname = x.Firstname, Lastname = x.Lastname
            })
                                              .ToList();

            return(persons);
        }
示例#21
0
        public IQueryable <Product> GetAll()
        {
            var lawnmowers = lawnmowerRepository.GetAll();
            var phoneCases = phoneCaseRepository.GetAll();
            var tShirts    = teeShirtRepository.GetAll();

            return(lawnmowers.Select(ProductHelper.ToProduct)
                   .Union(phoneCases.Select(ProductHelper.ToProduct))
                   .Union(tShirts.Select(ProductHelper.ToProduct))
                   .AsQueryable());
        }
示例#22
0
        public IQueryable <RecipeModel> Execute()
        {
            var recipes = _repository.GetAll()
                          .Select(e => new RecipeModel
            {
                Id   = e.Id,
                Name = e.Name
            });

            return(recipes);
        }
示例#23
0
        private string GetEncriptKey()
        {
            IReadOnlyRepository <DtoConfiguration> repository = repositoryFactory.CreateReadOnlyConfigurationsRepository();
            var line = repository.GetAll().Where(x => x.Name == "tokenEncriptKey").FirstOrDefault();

            if (line != null)
            {
                return(line.Value);
            }

            throw new SystemConfigurationMissingException(SystemConfigurationMissingException.ConfigurationName.TokenEncriptKey);
        }
示例#24
0
        //
        // GET: /Empleados/
        public ActionResult Index()
        {
            var usersList = _readOnlyRepository.GetAll <Departamento>();

            var castedList = new List <DepartamentoModel>();

            foreach (var account in usersList)
            {
                castedList.Add(Mapper.Map <DepartamentoModel>(account));
            }

            return(View(castedList));
        }
        public ActionResult FrequentQuestions()
        {
            var questions = new QuestionModel
            {
                PreguntasFrecuentes = _readOnlyRepository.GetAll <QuestionAnswer>().Where(x => x.Archived == false).ToList()
            };

            if (questions.PreguntasFrecuentes.Count == 0)
            {
                this.AddNotification("En este momento no tenemos preguntas frecuentes en nuestra base de datos, pero puedes enviarnos" +
                                     " una y con gusto trabajaremos para contestartela.", NotificationType.Info);
            }

            return(View(questions));
        }
示例#26
0
        public List <LeaguesModel> GetAvailableLeagues()
        {
            var userTokenModel = GetUserTokenModel();

            if (userTokenModel == null)
            {
                throw new HttpException((int)HttpStatusCode.Unauthorized, "User is not authorized");
            }

            var leagues      = _readOnlyRepository.GetAll <Leagues>().ToList();
            var leaguesModel = _mappingEngine.Map <List <Leagues>, List <LeaguesModel> >(leagues);

            return(leaguesModel);
        }
        private List <Product> convertFromRepo <T>(IReadOnlyRepository <T> repository, string type) where T : class
        {
            IQueryable <T> rawData  = repository.GetAll();
            List <Product> products = rawData
                                      .Select(x => new Product()
            {
                Id    = (Guid)x.GetType().GetProperty("Id").GetValue(x, null),
                Name  = (string)x.GetType().GetProperty("Name").GetValue(x, null),
                Price = (double)x.GetType().GetProperty("Price").GetValue(x, null),
                Type  = type
            }).ToList();

            return(products);
        }
示例#28
0
        // GET: api/BodyParts
        public IQueryable <Models.BodyPart> GetBodyParts()
        {
            ServerUtils.LogTelemetryEvent(User.Identity.Name, "GetBodyParts");

            return(_bpRepository.GetAll().Select(bp => new Models.BodyPart
            {
                Id = bp.Id,
                Name = bp.Name,
                SkinRegions = bp.SkinRegions.Select(sr => new Models.SkinRegion
                {
                    Id = sr.Id,
                    Name = sr.Name,
                }).ToList()
            }));
        }
        public async Task <ActionResult <List <SearchBuildsResultModel> > > SearchBuilds([FromQuery] SearchBuildsRequestModel request)
        {
            IList <BuildMatchPatternReadModel> allPatterns = await buildMatchPatternReadOnlyRepository.GetAll();

            IList <string> searchPatterns = allPatterns.Select(x => x.Regexp).ToList();

            if (!searchPatterns.Any())
            {
                return(NotFound("Couldn't found any regular expressions in DB"));
            }

            IResponseMessage response = await buildSyncService.SearchBuilds(request.Path, request.SourceType, searchPatterns);

            return(response.ToActionResult <ScanForBuildsListResponse, List <SearchBuildsResultModel> >(
                       r => SearchBuildsResultFactory.Create(r, allPatterns)));
        }
示例#30
0
        public ActionResult RegisteredUsersList()
        {
            //if (Session["userType"].ToString() != "Admin")
            //{
            //    return null;
            //}

            var usersList = _readOnlyRepository.GetAll <Account>();

            var castedList = new List <RegisteredUsersListModel>();

            foreach (var account in usersList)
            {
                castedList.Add(Mapper.Map <RegisteredUsersListModel>(account));
            }

            return(View(castedList));
        }
示例#31
0
        public UserAccountModule(IReadOnlyRepository readOnlyRepository,ICommandDispatcher commandDispatcher, IPasswordEncryptor passwordEncryptor, IMappingEngine mappingEngine)
        {
            Post["/register"] =
                _ =>
                    {
                        var req = this.Bind<NewUserRequest>();
                        var abilities = mappingEngine.Map<IEnumerable<UserAbilityRequest>, IEnumerable<UserAbility>>(req.Abilities);
                        commandDispatcher.Dispatch(this.UserSession(),
                                                   new CreateEmailLoginUser(req.Email, passwordEncryptor.Encrypt(req.Password), req.Name, req.PhoneNumber, abilities));
                        return null;
                    };


            Post["/register/facebook"] =
                _ =>
                    {
                        var req = this.Bind<FacebookRegisterRequest>();
                        commandDispatcher.Dispatch(this.UserSession(), new CreateFacebookLoginUser(req.id,req.email, req.first_name, req.last_name,req.link,req.name,req.url_image));
                        return null;
                    };

            Post["/register/google"] =
                _ =>
                    {
                        var req = this.Bind<GoogleRegisterRequest>();
                        commandDispatcher.Dispatch(this.UserSession(), new CreateGoogleLoginUser(req.id,req.email,req.name.givenName,req.name.familyName,req.url,req.displayName,req.image.url));
                        return null;
                    };

            Post["/password/requestReset"] =
                _ =>
                {
                    var req = this.Bind<ResetPasswordRequest>();
                    commandDispatcher.Dispatch(this.UserSession(),
                                               new CreatePasswordResetToken(req.Email) );
                    return null;
                };

            Put["/password/reset/{token}"] =
                p =>
                {
                    var newPasswordRequest = this.Bind<NewPasswordRequest>();
                    var token = Guid.Parse((string)p.token);
                    commandDispatcher.Dispatch(this.UserSession(),
                                               new ResetPassword(token, passwordEncryptor.Encrypt(newPasswordRequest.Password)));
                    return null;
                };

            Post["/user/abilites"] = p =>
            {

                var requestAbilites = this.Bind<UserAbilitiesRequest>();
                commandDispatcher.Dispatch(this.UserSession(), new AddAbilitiesToUser(requestAbilites.UserId, requestAbilites.Abilities.Select(x => x.Id)));

                return null;


            };

            Get["/abilities"] = _ =>
            {
                var abilites = readOnlyRepository.GetAll<UserAbility>();

                var mappedAbilites = mappingEngine.Map<IEnumerable<UserAbility>, IEnumerable<UserAbilityRequest>>(abilites);

                return mappedAbilites;
            };
        }