Ejemplo n.º 1
0
 public ProductService(IContentLoader contentLoader,
                       IPromotionService promotionService,
                       IPricingService pricingService,
                       UrlResolver urlResolver,
                       LinksRepository linksRepository,
                       IRelationRepository relationRepository,
                       ICurrentMarket currentMarketService,
                       ICurrencyService currencyService,
                       AppContextFacade appContext,
                       ReferenceConverter referenceConverter,
                       LanguageService languageService,
                       FilterPublished filterPublished)
 {
     _contentLoader        = contentLoader;
     _promotionService     = promotionService;
     _pricingService       = pricingService;
     _urlResolver          = urlResolver;
     _linksRepository      = linksRepository;
     _relationRepository   = relationRepository;
     _preferredCulture     = ContentLanguage.PreferredCulture;
     _currentMarketService = currentMarketService;
     _currencyService      = currencyService;
     _appContext           = appContext;
     _referenceConverter   = referenceConverter;
     _languageService      = languageService;
     _filterPublished      = filterPublished;
 }
Ejemplo n.º 2
0
        public IHttpActionResult Post([FromBody] LinkModel link)
        {
            try
            {
                if (link == null)
                {
                    return(BadRequest("Product Cannont be null"));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var savedLink = new LinksRepository().Save(link);
                if (savedLink == null)
                {
                    return(Conflict());
                }
                return(Created <LinkModel>(Request.RequestUri + savedLink.Id.ToString(), savedLink));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 3
0
        // PUT api/links/5
        public IHttpActionResult Put(int id, [FromBody] LinkModel link)
        {
            new LinksRepository().Save(id, link);

            try
            {
                if (link == null)
                {
                    return(BadRequest("Product Cannont be null"));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var savedLink = new LinksRepository().Save(id, link);
                if (savedLink == null)
                {
                    return(NotFound());
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 4
0
        public ActionResult PostLink(string url)
        {
            // TODO - Include a success or failure message with the redirect
            ILinksRepository context  = new LinksRepository();
            DataResponse     response = context.SaveLink(url);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult Index()
        {
            ILinksRepository context = new LinksRepository();
            LinksModel       model   = new LinksModel();

            model.links = context.UserLinks();
            return(View(model));
        }
Ejemplo n.º 6
0
        private void LoadData()
        {
            LinksRepository   lr = new LinksRepository();
            List <shortLinks> ll = lr.ReadALL();

            dataGridView1.DataSource = ll;
            dataGridView1.ReadOnly   = true;
        }
Ejemplo n.º 7
0
        IEnumerable <IVariationViewModel <VariationContent> > CreateRelatedVariationViewModelCollection(CatalogContentBase catalogContent, string associationType)
        {
            IEnumerable <Association> associations = LinksRepository.GetAssociations(catalogContent.ContentLink);
            IEnumerable <IVariationViewModel <VariationContent> > productViewModels =
                Enumerable.Where(associations, p => p.Group.Name.Equals(associationType) && IsVariation <VariationContent>(p.Target))
                .Select(a => CreateVariationViewModel(ContentLoader.Get <VariationContent>(a.Target)));

            return(productViewModels);
        }
Ejemplo n.º 8
0
        public ActionResult DeleteLink(int id)
        {
            ILinksRepository context  = new LinksRepository();
            DataResponse     response = context.DeleteLink(id);

            if (response.Success)
            {
                response.Message = "Link successfully deleted.";
            }
            return(Json(new { Success = response.Success, Message = response.Message }));
        }
Ejemplo n.º 9
0
 public IHttpActionResult Get()
 {
     try
     {
         var linkRepo = new LinksRepository();
         return(Ok(linkRepo.Retrive().AsQueryable()));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Ejemplo n.º 10
0
        private LazyProductViewModelCollection CreateLazyRelatedProductContentViewModels(CatalogContentBase catalogContent, string associationType)
        {
            return(new LazyProductViewModelCollection(() =>
            {
                IEnumerable <Association> associations = LinksRepository.GetAssociations(catalogContent.ContentLink);
                IEnumerable <IProductViewModel <ProductContent> > productViewModels =
                    Enumerable.Where(associations, p => p.Group.Name.Equals(associationType) && IsProduct <ProductContent>(p.Target))
                    .Select(a => CreateProductViewModel(ContentLoader.Get <ProductContent>(a.Target)));

                return productViewModels;
            }));
        }
Ejemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            LinksRepository   lr = new LinksRepository();
            List <shortLinks> ll = lr.ReadALL();

            if (check_id(ll, Int32.Parse(textBox1.Text)))
            {
                textBox2.Text = lr.ReadById(Int32.Parse(textBox1.Text));
                lr.updateCount(Int32.Parse(textBox1.Text));
            }
            else
            {
                MessageBox.Show("Ошибка. Проверьте выбранный id");
            }
        }
        public ContentArea CreateRelatedProductsContentArea(EntryContentBase catalogContent, string associationType)
        {
            IEnumerable <Association> associations   = LinksRepository.GetAssociations(catalogContent.ContentLink);
            ContentArea             relatedEntriesCA = new ContentArea();
            List <EntryContentBase> relatedEntires   = Enumerable.Where(associations, p => p.Group.Name.Equals(associationType))
                                                       .Select(a => ContentLoader.Get <EntryContentBase>(a.Target)).ToList();

            foreach (var relatedEntire in relatedEntires)
            {
                ContentAreaItem caItem = new ContentAreaItem();
                caItem.ContentLink = relatedEntire.ContentLink;
                relatedEntriesCA.Items.Add(caItem);
            }
            return(relatedEntriesCA);
        }
Ejemplo n.º 13
0
        public ActionResult GoToLink(string hash)
        {
            // Grab the required database row
            ILinksRepository context = new LinksRepository();
            Link             link    = context.RedirectLink(hash);

            if (link == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(Redirect(link.url));
            }
        }
Ejemplo n.º 14
0
        public IHttpActionResult Get(int id)
        {
            try
            {
                var links = new LinksRepository().Retrive();
                var link  = links.FirstOrDefault(p => p.Id == id);
                if (link == null)
                {
                    return(NotFound());
                }

                return(Ok(link));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public ContentArea CreateRelatedProductsContentArea(EntryContentBase catalogContent, string associationType)
        {
            IEnumerable <Association> associations = LinksRepository.GetAssociations(catalogContent.ContentLink);

            var relatedEntires = associations.Where(p => p.Group.Name.Equals(associationType))
                                 .Where(x => x.Target != null && x.Target != ContentReference.EmptyReference)
                                 .Select(x => ContentLoader.Get <EntryContentBase>(x.Target));

            var relatedEntriesCa = new ContentArea();

            foreach (var relatedEntire in relatedEntires)
            {
                ContentAreaItem caItem = new ContentAreaItem();
                caItem.ContentLink = relatedEntire.ContentLink;
                relatedEntriesCa.Items.Add(caItem);
            }

            return(relatedEntriesCa);
        }
Ejemplo n.º 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            Links ln = new Links();

            ln.fullUrl = textBox1.Text;
            using (MD5 md5Hash = MD5.Create())
            {
                string hash = _md5.GetMd5Hash(md5Hash, textBox1.Text);
                htmlFile.createFile(hash, ln.fullUrl);
                ftp.uploadFile(hash);
                ln.shortUrl = "http://f0287337.xsph.ru/" + hash + ".html";
            }
            ln.usCount      = 5;
            ln.finishDate   = DateTime.Today.AddDays(Convert.ToDouble(textBox2.Text));
            ln.lDescription = textBox4.Text;
            //textBox3.Text = ln.fullUrl + Environment.NewLine + ln.shortUrl + Environment.NewLine + ln.usCount + Environment.NewLine + ln.finishDate+ Environment.NewLine+ln.lDescription;
            LinksRepository lr = new LinksRepository();

            lr.insertLink(ln);
        }
Ejemplo n.º 17
0
 public ProductService(IContentLoader contentLoader,
     IPromotionService promotionService,
     IPricingService pricingService,
     UrlResolver urlResolver,
     LinksRepository linksRepository,
     IRelationRepository relationRepository,
     ICurrentMarket currentMarket,
     ICurrencyService currencyService,
     AppContextFacade appContext,
     ReferenceConverter referenceConverter)
 {
     _contentLoader = contentLoader;
     _promotionService = promotionService;
     _pricingService = pricingService;
     _urlResolver = urlResolver;
     _linksRepository = linksRepository;
     _relationRepository = relationRepository;
     _preferredCulture = ContentLanguage.PreferredCulture;
     _currentMarket = currentMarket;
     _currencyService = currencyService;
     _appContext = appContext;
     _referenceConverter = referenceConverter;
 }
Ejemplo n.º 18
0
 public LinksApiController(LinksRepository repository)
 {
     this.repository = repository;
     this.OnCreated();
 }