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; }
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)); } }
// 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)); } }
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")); }
public ActionResult Index() { ILinksRepository context = new LinksRepository(); LinksModel model = new LinksModel(); model.links = context.UserLinks(); return(View(model)); }
private void LoadData() { LinksRepository lr = new LinksRepository(); List <shortLinks> ll = lr.ReadALL(); dataGridView1.DataSource = ll; dataGridView1.ReadOnly = true; }
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); }
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 })); }
public IHttpActionResult Get() { try { var linkRepo = new LinksRepository(); return(Ok(linkRepo.Retrive().AsQueryable())); } catch (Exception ex) { return(InternalServerError(ex)); } }
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; })); }
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); }
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)); } }
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); }
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); }
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; }
public LinksApiController(LinksRepository repository) { this.repository = repository; this.OnCreated(); }