Exemple #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services
            .AddMvc(options => { options.EnableEndpointRouting = false; })
            .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });

            var dummyBanner = new Banner
            {
                Id      = 1,
                Created = DateTime.UtcNow,
                Html    = "<h1>My title</h1><p>hello<span style=\"color:red\">!</span></p>"
            };

            var bannerRepository = new BannerRepository();

            bannerRepository.TrySave(dummyBanner);

            services.AddSingleton <IBannerRepository>(provider => bannerRepository);
            services.AddSingleton <IMapper, Mapper>();
            services.AddSingleton <IValidate, ValidateHtml>();

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "BannerWebAPI", Version = "v1"
                });
            });
        }
Exemple #2
0
        public UnitOfWork(ApplicationDbContext context)
        {
            _context       = context;
            ProductDetails = new ReservationDetailsRepository(_context);
            Products       = new ProductRepository(_context);

            ProductCategories = new ProductCategoryRepository(_context);

            Services = new ServiceRepository(_context);

            ServiceCategories = new ServiceCategoryRepository(_context);

            Departments = new DepartmentRepository(_context);

            Menus = new MenuRepository(_context);

            SubMenus = new SubMenuRepository(_context);

            OurTeams = new OurTeamRepository(_context);

            Designations = new DesignationRepository(_context);

            Faq = new FaqRepository(_context);

            Client = new ClientRepository(_context);

            Blogs = new BlogRepository(_context);

            ContactUs = new ContactUsRepository(_context);

            Companies = new CompanyRepository(_context);

            Banner = new BannerRepository(_context);

            ChooseUs = new WhyChooseUsRepository(_context);

            ClientProducts = new ClientProductRepository(_context);

            AboutUs = new AboutUsRepository(_context);

            HostingPlan = new HostingPlanRepository(_context);

            CustomerReview = new CustomerReviewRepository(_context);

            Career = new CareerRepository(_context);

            Job = new JobRepository(_context);

            Softwares = new SoftwareRepository(_context);

            SoftwareCategories = new SoftwareCategoriesRepository(_context);

            Features = new FeaturesRepository(_context);

            BlogComment = new BlogCommentRepository(_context);

            QueryHelper = new QueryHelper();
        }
        public IndexService()
        {
            ImageCardData = new ImageCardRepository().CreateImageCardList();

            NewsCardData = new NewsCardRepository().CreateNewsCardList();

            BannerData = new BannerRepository().CreateBannerList();

            ServicesData = new ServiceItemRepository().CreateServicesList();
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            var db   = MongoDatabaseProvider.MongoDatabase;
            var repo = new BannerRepository(db);

            repo.Insert(new Infrastructure.DataModels.Banner()
            {
                Created  = DateTime.Now,
                Id       = 0,
                Html     = "<html>test</html>",
                Modified = DateTime.Now
            });
        }
Exemple #5
0
        private void RightBannerList()
        {
            RightBanners = BannerRepository.RightBannerList();
            foreach (var item in RightBanners)
            {
                item.Product.DiscountAmount = string.Format("{0:0.##}", (item.Product.Prize - ((item.Product.Prize * item.Product.Discount) / 100)));

                if (item.Product.Description.Length > 60)
                {
                    item.Product.Description = item.Product.Description.Substring(0, 60);
                }
            }
        }
        /// <summary>
        /// Add a new banner.  Needs a valid banner html.
        /// </summary>
        /// <param name="banner">Html of the banner.</param>
        /// <returns>Created banner Id.</returns>
        /// // POST api/Banner
        public int Post([FromBody]string banner)
        {
            if (banner == null) throw new InvalidOperationException("Html provided is not valid"); ;
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(banner);
            if (doc.ParseErrors.Count() > 0)
            {
                throw new InvalidOperationException("Html provided is not valid");
                //Invalid HTML
            }
            var insertedBanner = new BannerRepository().AddBanner(banner);

            return insertedBanner.BannerId;
        }
Exemple #7
0
 private void CreateRepos()
 {
     mEntities                      = new V308CMSEntities();
     ProductRepos                   = new ProductRepository(mEntities);
     ProductRepos.PageSize          = PageSize;
     ProductHelper.ProductShowLimit = ProductRepos.PageSize;
     AccountRepos                   = new AccountRepository(mEntities);
     NewsRepos                      = new NewsRepository(mEntities);
     CommentRepo                    = new TestimonialRepository(mEntities);
     CategoryRepo                   = new CategoryRepository(mEntities);
     LinkRepo            = new LinkRepository(mEntities);
     BannerRepo          = new BannerRepository(mEntities);
     TicketRepo          = new TicketRepository(mEntities);
     CouponRepo          = new CouponRepository(mEntities);
     CouponRepo.PageSize = PageSize;
 }
Exemple #8
0
        /// <summary>
        /// gets the home of banner module
        /// </summary>
        /// <param name="page">index page</param>
        /// <param name="name">criteria search</param>
        /// <param name="lang">culture name</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Index(int?page, string name, string lang)
        {
            BannerRepository objbanner = new BannerRepository(SessionCustom);
            PaginInfo        paginInfo = new PaginInfo()
            {
                PageIndex = page != null ? page.Value : 1
            };

            return(this.View(new Banners()
            {
                UserPrincipal = CustomUser,
                Module = this.Module,
                ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext),
                CollBanners = objbanner.GetAllPaging(name, paginInfo, CurrentLanguage.LanguageId.Value),
                Pagininfo = paginInfo,
                CurrentLanguage = CurrentLanguage
            }));
        }
Exemple #9
0
        /// <summary>
        /// gets the detail of a banner
        /// </summary>
        /// <param name="id">identifier of banner</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Detail(int?id)
        {
            BannerRepository   objbanner         = new BannerRepository(SessionCustom);
            SectionManagement  objsection        = new SectionManagement(SessionCustom, HttpContext);
            SectionRepository  sectionrepository = new SectionRepository(SessionCustom);
            PositionRepository objposition       = new PositionRepository(SessionCustom);

            Domain.Entities.Banner banner = null;
            bool?isHome = null;

            if (id != null)
            {
                objbanner.Entity.BannerId = id;
                objbanner.Load();
                banner     = objbanner.Entity;
                ViewBag.id = id;

                BannersectionRepository objbannersection = new BannersectionRepository(SessionCustom);
                objbannersection.Entity.BannerId = id;

                List <Bannersection> collsections = objbannersection.GetAll();
                objsection.CreateTreeViewCheck(sectionrepository.GetAll().FindAll(t => t.LanguageId == CurrentLanguage.LanguageId), collsections);
                isHome = collsections.Exists(t => t.SectionId == 0);
            }
            else
            {
                objsection.CreateTreeViewCheck(sectionrepository.GetAll().FindAll(t => t.LanguageId == CurrentLanguage.LanguageId), null);
            }

            return(this.View(new Banners()
            {
                UserPrincipal = CustomUser,
                Banner = banner,
                ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext),
                Module = this.Module,
                TreeView = objsection.Tree,
                Collposition = objposition.GetAll(),
                IsHome = isHome,
                CurrentLanguage = CurrentLanguage
            }));
        }
Exemple #10
0
        /// <summary>
        /// delete a banner
        /// </summary>
        /// <param name="id">identifier of banner</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Delete(int id)
        {
            BannerRepository objbanner = new BannerRepository(SessionCustom);

            objbanner.Entity.BannerId = id;
            objbanner.LoadByKey();

            if (objbanner.Entity.Bannertype != 2)
            {
                string path = Path.Combine(Server.MapPath("~"), @"resources\banners\" + objbanner.Entity.Bannerfile);

                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }
            }

            objbanner.Delete();

            this.InsertAudit("Delete", this.Module.Name + " -> " + id);

            return(this.RedirectToAction("Index", "Banner"));
        }
 // GET api/Banner/5
 /// <summary>
 /// Get a specific banner.
 /// </summary>
 /// <param name="id">Banner Id</param>
 /// <returns>Object Banner</returns>
 public IBanner Get(int id)
 {
     var banner = new BannerRepository().GetBanner(id);
     return banner;
 }
Exemple #12
0
        /// <summary>
        /// gets the home of content according to identifier
        /// </summary>
        /// <param name="id">identifier of content</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Index(int id)
        {
            SetLabel();
            bool versus = false;
            FrontEndManagement   objman     = new FrontEndManagement(SessionCustom, HttpContext, FrontEndManagement.Type.Content, CurrentLanguage);
            BannerRepository     banner     = new BannerRepository(SessionCustom);
            IdeaRepository       idea       = new IdeaRepository(SessionCustom);
            UserAnswerRepository userAnswer = new UserAnswerRepository(SessionCustom);
            bool voted = false;

            idea.Entity.ContentId = id;

            int?currentUserId = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUserId = ((CustomPrincipal)User).UserId;
                objman.BindInfo(id, currentUserId.Value);
                versus = Business.Utils.CheckVersus(((CustomPrincipal)User).UserId, id, this.SessionCustom);
                voted  = userAnswer.CheckUserVoted(((CustomPrincipal)User).UserId, id, null);
            }
            else
            {
                objman.BindInfo(id, null);
                versus = true;
            }

            ViewBag.CurrentUserId = currentUserId;

            if (!objman.Content.Active.Value)
            {
                return(this.Redirect("~/" + objman.Section.Friendlyname));
            }

            if (objman.Outcome == FrontEndManagement.Result.Ok)
            {
                ViewBag.Ideas = idea.GetAll();
                return(this.View(
                           objman.Template,
                           new Models.FEContenido()
                {
                    UserPrincipal = CustomUser,
                    PageTitle = string.Format("{0} | {1}", ConfigurationManager.AppSettings["TitleHome"], objman.Content.Name),
                    Content = objman.Content,
                    Section = objman.Section,
                    Layout = objman.Layout + ".cshtml",
                    Entity = objman.Detail,
                    MetaTags = objman.Metatags,
                    Banners = banner.GetBannersBySection(objman.Section.SectionId.Value, CurrentLanguage.LanguageId.Value),
                    DeepFollower = objman.DeepFollower,
                    CurrentLanguage = CurrentLanguage,
                    IdeasCountAll = idea.IdeasCountAll(),
                    Versus = versus,
                    Voted = voted
                }));
            }
            else if (objman.Outcome == FrontEndManagement.Result.NotFound)
            {
                return(this.View(
                           "Mensaje",
                           new FEMessage()
                {
                    PageTitle = "Recurso no encontrado",
                    UserPrincipal = CustomUser,
                    Banners = banner.GetBannersBySection(0, CurrentLanguage.LanguageId.Value),
                    Title = "Recurso no encontrado",
                    Description = "Recurso no encontrado",
                    Message = Resources.Extend.Messages.RESOURCE_NOT_FOUND,
                    CurrentLanguage = CurrentLanguage
                }));
            }
            else
            {
                return(this.View(
                           "Mensaje",
                           new FEMessage()
                {
                    PageTitle = "Sistema no disponible",
                    UserPrincipal = CustomUser,
                    Banners = banner.GetBannersBySection(0, CurrentLanguage.LanguageId.Value),
                    Title = "Sistema no disponible",
                    Description = "Sistema no disponible",
                    Message = Resources.Extend.Messages.SYSTEM_ERROR,
                    CurrentLanguage = CurrentLanguage
                }));
            }
        }
 public BannersController()
 {
     bannerRepository = new BannerRepository(db);
 }
Exemple #14
0
        public void DeleteBanner(int id)
        {
            var repo = new BannerRepository();

            repo.Delete(id);
        }
Exemple #15
0
        public void UpdateBanner(Banner banner)
        {
            var repo = new BannerRepository();

            repo.Update(banner);
        }
Exemple #16
0
 public BannerService()
 {
     _bannerRepository = new BannerRepository();
 }
Exemple #17
0
        public List <Banner> GetAllBanner()
        {
            var repo = new BannerRepository();

            return(repo.GetAll());
        }
Exemple #18
0
 public BannerServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _bannerRepository = new BannerRepository(entities);
 }
Exemple #19
0
        public ActionResult Detail(int?id, Banners model, HttpPostedFileBase bannerFile, string sectionsid, string bannerhtml, short type)
        {
            BannerRepository        objbanner   = new BannerRepository(SessionCustom);
            BannersectionRepository objsections = new BannersectionRepository(SessionCustom);

            objbanner.Entity            = model.Banner;
            objbanner.Entity.LanguageId = CurrentLanguage.LanguageId;
            int bannerId = 0;

            if (type != 2)
            {
                if (bannerFile != null && bannerFile.ContentLength > 0)
                {
                    string extension = Path.GetExtension(bannerFile.FileName).ToLower();
                    objbanner.Entity.Bannertype = extension == ".swf" ? short.Parse("0") : short.Parse("1");
                    objbanner.Entity.Bannerfile = Utils.UploadFile(bannerFile, Server.MapPath("~"), @"Resources\Banners\", null);
                }
            }
            else
            {
                objbanner.Entity.Bannertype = short.Parse("2");
                objbanner.Entity.Bannerfile = bannerhtml;
            }

            if (id != null)
            {
                objbanner.Entity.BannerId = id;
                bannerId = id.Value;
                objbanner.Update();
                this.InsertAudit("Update", this.Module.Name + " -> " + objbanner.Entity.Name);
            }
            else
            {
                objbanner.Entity.Bannerdate = DateTime.Now;
                bannerId = Convert.ToInt32(objbanner.Insert());
                this.InsertAudit("Insert", this.Module.Name + " -> " + objbanner.Entity.Name);
            }

            objsections.Entity.BannerId = bannerId;
            string[]             arrid    = sectionsid.Split(',');
            List <Bannersection> collbann = objsections.GetAll();

            foreach (string item in arrid)
            {
                int sectionId = int.Parse(item);
                if (!collbann.Exists(t => t.SectionId == sectionId))
                {
                    objsections.Entity.SectionId = sectionId;
                    objsections.Insert();
                }
                else
                {
                    collbann.RemoveAll(t => t.SectionId == sectionId);
                }
            }

            foreach (Bannersection item in collbann)
            {
                objsections.Entity = item;
                objsections.Delete();
            }

            return(this.RedirectToAction("Index", "Banner"));
        }
Exemple #20
0
 public BannerService(BannerRepository bannerRepository)
 {
     _bannerRepository = bannerRepository;
 }
Exemple #21
0
        public Banner GetBannerById(int id)
        {
            var repo = new BannerRepository();

            return(repo.GetById(id));
        }
 public HttpResponseMessage Render(int id)
 {
     var banner = new BannerRepository().GetBanner(id);
     var content = "";
     if (banner != null) content = banner.Html;
     var response = new HttpResponseMessage();
     response.Content = new StringContent(content);
     response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
     return response;
 }
Exemple #23
0
        public void AddBanner(Banner banner)
        {
            var repo = new BannerRepository();

            repo.Add(banner);
        }
Exemple #24
0
 public BannerController()
 {
     repo = new BannerRepository();
 }
Exemple #25
0
 public BannerServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance <ILocalizedResourceServices>();
     _bannerRepository          = new BannerRepository(entities);
 }