protected void Page_Init(object sender, EventArgs e) { string catalog = Request.QueryString["catalog"]; if (!string.IsNullOrEmpty(catalog)) { try { _catalogType = (CatalogType)Enum.Parse(typeof(CatalogType), catalog); } catch { } } string category = Request.QueryString["category"]; if (!string.IsNullOrEmpty(category)) { try { _categoryId = int.Parse(category); } catch { } } string creator = Request.QueryString["creator"]; if (!string.IsNullOrEmpty(creator)) { _creatorId = HttpUtility.UrlDecode(creator); } }
public async Task <CatalogType> CreateTypeAsync(CatalogType type) { this.catalogContext.CatalogTypes.Add(type); await this.catalogContext.SaveChangesAsync().ConfigureAwait(false); return(type); }
public async Task <IList <CatalogItem> > GetItemsAsync(CatalogType catalogType, CatalogBrand catalogBrand, string query) { await Task.FromResult(true); using (var db = new LocalCatalogDb()) { IEnumerable <CatalogItem> items = db.CatalogItems; if (!String.IsNullOrEmpty(query)) { items = items.Where(r => $"{r.Name}".ToUpper().Contains(query.ToUpper())); } if (catalogType != null && catalogType.Id > 0) { items = items.Where(r => r.CatalogTypeId == catalogType.Id); } if (catalogBrand != null && catalogBrand.Id > 0) { items = items.Where(r => r.CatalogBrandId == catalogBrand.Id); } return(Populate(db, items.ToArray().OrderBy(r => r.Name)).ToList()); } }
public static ObjectChooser CreateObjectChooser(MainForm.DoWaitCallback doWaitCB, MainForm.StopWaitCallback stopWaitCB, MainForm.updateProgressCallback updateProgressCB, MainForm.listViewAddCallBack listViewAddCB, CatalogType resourceType, EventHandler<MainForm.SelectedIndexChangedEventArgs> selectedIndexChangedHandler, EventHandler<MainForm.ItemActivateEventArgs> itemActivateHandler) { ObjectChooser res; if (!objectChooserCache.ContainsKey(resourceType)) { res = new ObjectChooser(doWaitCB, stopWaitCB, updateProgressCB, listViewAddCB, resourceType); res.SelectedIndexChanged += selectedIndexChangedHandler; res.ItemActivate += itemActivateHandler; return res; } res = objectChooserCache[resourceType]; res.SelectedIndexChanged = null; res.SelectedItem = null; res.listView1.SelectedItems.Clear(); res.SelectedIndexChanged += selectedIndexChangedHandler; res.ItemActivate = null; res.ItemActivate += itemActivateHandler; return res; }
/// <summary> /// Método responsável por manipular a adição uma tipo ao repositorio /// </summary> /// <param name="command"></param> /// <returns></returns> public IResponse handle(CommandAddType command) { // Validação rapida command.Validate(); if (command.Invalid) { return(new ResponseError <CommandAddType>( errorCode: "400", description: "Não foi possível prosseguir com a solicitação", data: command.Notifications )); } // cria a entidade catalogType var type = new CatalogType(type: command.Type); // Salva os dados no repositorio e retorna false caso ocorrá algum erro if (!_repository.CreateTypeAsync(type: type)) { return(new ResponseError <CommandAddType>( errorCode: "400", description: "Não foi possível prosseguir com a solicitação", data: "Erro sistemico" )); } // retorna successo para operação para adicionar um novo tipo para o produto return(new ResponseOk <CatalogType>(responseObj: type)); }
public List <NomenclatureDTO> GetGoods(CatalogType type) { using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var types = Enum.GetValues(typeof(MobileCatalog)) .Cast <MobileCatalog>() .Where(x => x.ToString().StartsWith(type.ToString())) .ToArray(); var list = NomenclatureRepository.GetNomenclatureWithPriceForMobileApp(uow, types); if (type == CatalogType.Water) { list = list.OrderByDescending(n => n.Weight) .ThenBy(n => n.NomenclaturePrice.Any() ? n.NomenclaturePrice.Max(p => p.Price) : 0) .ToList(); } else { list = list.OrderBy(n => (int)n.MobileCatalog) .ThenBy(n => n.NomenclaturePrice.Any() ? n.NomenclaturePrice.Max(p => p.Price) : 0) .ToList(); } var listDto = list.Select(n => new NomenclatureDTO(n)).ToList(); var imageIds = NomenclatureRepository.GetNomenclatureImagesIds(uow, list.Select(x => x.Id).ToArray()); listDto.Where(dto => imageIds.ContainsKey(dto.Id)) .ToList() .ForEach(dto => dto.imagesIds = imageIds[dto.Id]); return(listDto); } }
public static void Initialize(CatalogContext context) { context.Database.EnsureCreated(); if (context.CatalogTypes.Any()) { return; } var catalogtypes = new CatalogType[] { new CatalogType { Type = "Portie frieten" }, new CatalogType { Type = "Burgers" }, new CatalogType { Type = "Menu's" }, new CatalogType { Type = "Frisdrank" }, new CatalogType { Type = "Dessert" }, }; }
public async Task <ActionResult <CatalogType> > CreateCatalogType(CatalogType type) { try { if (type == null) { // this.logger.LogError("Type object sent from client is null"); return(this.BadRequest()); } if (this.ModelState.IsValid == false) { // this.logger.LogError("Invalid type object sent from client"); return(this.BadRequest()); } var newItem = await this.catalogService.CreateTypeAsync(type).ConfigureAwait(false); return(this.CreatedAtAction(nameof(GetCatalogTypeById), new { id = newItem.Id }, newItem)); } catch (ArgumentException) { return(this.BadRequest()); } }
public async Task <ActionResult <IReadOnlyList <CatalogType> > > Post(CatalogType catalogType) { _logger.LogInformation("################################"); _logger.LogInformation("POST Catalog types"); _logger.LogInformation("################################"); try { var types = await _typeRepository.ListAllAsync(); var typeFindeds = types .Where(x => string.Compare(x.Type, catalogType.Type, StringComparison.InvariantCultureIgnoreCase) == 0); if (typeFindeds != null) { return(Conflict()); } await _typeRepository.AddAsync(catalogType); return(Ok()); } catch (ModelNotFoundException error) { _logger.LogError("O erro é: ", error); return(NotFound()); } }
private static CatalogImportDto GenerateCatalogImport( IEnumerable <BookWithDescription> books, Dictionary <string, Dictionary <string, IpfsBookCoverMapping> > bookCoverDictionary) { var excerpt = new CatalogImportDto(); var bookCatalogType = new CatalogType { Id = 1, Type = "Book" }; excerpt.CatalogTypes.Add(bookCatalogType); var authorDictionary = new Dictionary <string, CatalogBrand>(StringComparer.OrdinalIgnoreCase); int id = 0; int authorIdCounter = 0; foreach (var book in books) { id++; var item = Convert( bookCatalogType.Id, book, bookCoverDictionary, id, authorDictionary, ref authorIdCounter); excerpt.CatalogItems.Add(item); } excerpt.CatalogBrands = authorDictionary.Values.ToList(); return(excerpt); }
public async Task <ActionResult <IReadOnlyList <CatalogType> > > Put(CatalogType catalogType) { _logger.LogInformation("################################"); _logger.LogInformation("Update Catalog types"); _logger.LogInformation("################################"); try { var types = await _typeRepository.ListAllAsync(); // return catalog types list where de type name is the same and id not iqual var typeFindeds = types .Where(x => string.Compare(x.Type, catalogType.Type, StringComparison.InvariantCultureIgnoreCase) == 0) .Where(x => x.Id != catalogType.Id); if (typeFindeds != null) { return(Conflict()); } await _typeRepository.UpdateAsync(catalogType); return(Ok()); } catch (ModelNotFoundException error) { _logger.LogError("O erro é: ", error); return(NotFound()); } }
public CatalogForm(CatalogType type) : this() { _catType = type; this.Text = "Справочник "; switch (_catType) { case CatalogType.BREEDS: Text += "Пород"; break; case CatalogType.ZONES: Text += "Зон Прибытия"; break; case CatalogType.DEAD: Text += "причин списания"; break; case CatalogType.PRODUCTS: this.Text += "видов продукции"; break; //case CatalogType.VACCINES: // this.Text += "вакцин"; // break; } //ds.RowChanged += new DataRowChangeEventHandler(this.OnRowChange); //ds.TableNewRow += new DataTableNewRowEventHandler(this.OnRowInsert); fillTable(false); }
public static string ProcessUserInput(int id, CatalogType catalogies) { string allLines = String.Empty; string checkLines = String.Empty; string inputLine; int counter = 0; List <Catalog> catalogList = Data.GetList(catalogies + ".csv"); do { inputLine = Console.ReadLine(); if (inputLine != String.Empty && !int.TryParse(inputLine, out _)) { inputLine = ValidateName(catalogList, inputLine); id++; if (counter == 0 && id > 1) { allLines = Environment.NewLine; } string[] lines = checkLines.Split(Environment.NewLine); if (lines.FirstOrDefault(x => x.ToLower() == inputLine.ToLower()) == null) { allLines = allLines + id.ToString() + Constant.Delimiter + inputLine + Environment.NewLine; checkLines = checkLines + inputLine + Environment.NewLine; } } counter++; } while (inputLine != String.Empty); allLines = allLines.TrimEnd(Environment.NewLine.ToCharArray()); return(allLines); }
public CatalogInfo(XElement node) { string value; if (node.TryGetAttributeValue("id", out value)) { Id = int.Parse(value); } XElement n = node.Element("name"); if (n != null && n.TryGetValue(out value)) { _name = value; } n = node.Element("description"); if (n != null && n.TryGetValue(out value)) { _description = value; } n = node.Element("type"); if (n != null && n.TryGetValue(out value)) { _type = (CatalogType)Enum.Parse(typeof(CatalogType), value); } }
protected void Page_Init(object sender, EventArgs e) { string catalog = Request.QueryString["catalog"]; if (!string.IsNullOrEmpty(catalog)) { try { _catalogType = (CatalogType)Enum.Parse(typeof(CatalogType), catalog); } catch { } } string item = Request.QueryString["item"]; if (!string.IsNullOrEmpty(item)) { try { _itemId = int.Parse(item); } catch { } } }
public static void DeleteRecord(int menuCatalog) { Console.WriteLine(" Введите ID удаляемой записи:"); bool isInputFieldFinished = false; CatalogType catalogies = (CatalogType)menuCatalog; while (!isInputFieldFinished) { string inputLine = Console.ReadLine(); if (inputLine.Length == 0) { continue; } string filePath = Data.CreateFile(catalogies.ToString()); List <Catalog> catalogs = Data.GetList(filePath); if (int.TryParse(inputLine, out int userInput)) { if (userInput == 0) { Console.Clear(); isInputFieldFinished = true; break; } Catalog catalog = catalogs.FirstOrDefault(x => x.Id == userInput); if (catalog == null) { Console.WriteLine(" Запись с данным ID не существует."); } else { Expenses expenses = null; if (catalogies == CatalogType.GoodsCategory) { expenses = Data.GetExpenses().FirstOrDefault(x => x.CategoryId == userInput); } else if (catalogies == CatalogType.Goods) { expenses = Data.GetExpenses().FirstOrDefault(x => x.GoodsId == userInput); } else if (catalogies == CatalogType.Unit) { expenses = Data.GetExpenses().FirstOrDefault(x => x.UnitId == userInput); } if (expenses != null) { Console.WriteLine("Запись с данным ID используется в покупках. Не может быть удалена."); } else { catalogs.Remove(catalog); string lines = Catalog.ListToCsv(catalogs); Data.SaveAllData(filePath, lines); isInputFieldFinished = true; } } } } }
private string GetTable(CatalogType catalogType) { switch (catalogType) { case CatalogType.Aduana: return("TBLADUANA"); case CatalogType.ClaveUnidad: return("TBLCLAVEUNIDAD"); case CatalogType.ClaveProdServ: return("TBLPRODUCTOSSERVICIOS"); case CatalogType.CodigoPostal: return("TBLCODIGOPOSTAL"); case CatalogType.FormaPago: return("TBLFORMAPAGO"); case CatalogType.Impuesto: return("TBLIMPUESTO"); case CatalogType.MetodoPago: return("TBLMETODODEPAGO33"); case CatalogType.Moneda: return("TBLMONEDAS"); case CatalogType.NumPedimentoAduana: return("TBLNUMPEDIMENTOADUANA"); case CatalogType.Pais: return("TBLPAISES"); case CatalogType.PatenteAduanal: return("TBLPATENTEADUANAL"); case CatalogType.RegimenFiscal: return("TBLREGIMENFISCAL"); case CatalogType.TasaOCuota: return("TBLTASAOCUOTA"); case CatalogType.TipoDeComprobante: return("TBLTIPOCOMPROBANTE"); case CatalogType.TipoFactor: return("TBLTIPOFACTOR"); case CatalogType.TipoRelacion: return("TBLTIPORELACION"); case CatalogType.UsoCFDI: return("TBLUSOCFDI"); default: throw new ArgumentException($"El catálogo {catalogType} especificado no está definido."); } }
public Yield(CatalogContext dbContext) { var catalogTypes = dbContext.CatalogTypes.Where(catalogType => Markers.AllFlowers.Contains(catalogType.Type)).ToArray(); Plant = catalogTypes.First(catalogType => catalogType.Type == Markers.Plant); Flower = catalogTypes.First(catalogType => catalogType.Type == Markers.Flower); Bouquet = catalogTypes.First(catalogType => catalogType.Type == Markers.Bouquet); }
public Content(CatalogType type, IList<string> commandParams) { this.Type = type; this.Title = commandParams[(int)Acpi.Title]; this.Author = commandParams[(int)Acpi.Author]; this.Size = long.Parse(commandParams[(int)Acpi.Size]); this.URL = commandParams[(int)Acpi.Url]; }
public static int InputCatalog(string input, CatalogType catalogType, string error) { Console.WriteLine($"\n Введите имя {input} или ID:"); bool isInputFieldFinished = false; int catalogID = -1; while (!isInputFieldFinished) { string inputLine = Console.ReadLine(); if (inputLine.Trim().Length == 0) { continue; } string filePath = Data.CreateFile(catalogType.ToString()); List <Catalog> catalogs = Data.GetList(filePath); if (int.TryParse(inputLine, out catalogID)) { Catalog catalog = catalogs.FirstOrDefault(x => x.Id == catalogID); if (catalog == null) { Console.WriteLine($" {error} с данным ID не существует."); } else { return(catalogID); } } else { Catalog catalog = catalogs.FirstOrDefault(x => x.Name.ToLower().StartsWith(inputLine.ToLower())); if (catalog == null) { Console.WriteLine($" {error} с данным именем не существует. Добавить?"); Menu menu = new Menu(); int toAdd = menu.AskAddRecord(); while (toAdd != 1 && toAdd != 2) { toAdd = menu.AskAddRecord(); } if (toAdd == 1) { catalogID = AddRecord(inputLine, filePath, catalogs); return(catalogID); } else if (toAdd == 2) { InputCatalog(input, catalogType, error); isInputFieldFinished = true; } } else { return(catalog.Id); } } } return(catalogID); }
private void MockGetByIdAsync(int catalogTypeId, int catalogBrandId, CatalogType catalogType, CatalogBrand catalogBrand) { _mockCatalogTypeRepository .Setup(x => x.GetByIdAsync(catalogTypeId)) .ReturnsAsync(catalogType); _mockCatalogBrandRepository .Setup(x => x.GetByIdAsync(catalogBrandId)) .ReturnsAsync(catalogBrand); }
static IEnumerable <CatalogType> GetPreconfiguredCatalogTypes() { return(new List <CatalogType>() { CatalogType.Create("TLR"), CatalogType.Create("SLR"), CatalogType.Create("Rangefinder") }); }
public static void AddRecord(int menuCatalog) { Console.WriteLine("\n Добавить:"); CatalogType catalogies = (CatalogType)menuCatalog; string filePath = Data.CreateFile(catalogies.ToString()); int id = Data.GetMaxId(filePath); string allLines = UserInput.ProcessUserInput(id, catalogies); Data.SaveData(filePath, allLines); }
public IAcquisitionService GetAcquisitionService(CatalogType catalogType) { switch (catalogType) { case CatalogType.Litres: return(new LitresAcquisitionService(_webClient)); } throw new NotImplementedException(); }
public string readCatalog() { Console.WriteLine("Reading Component Catalog"); CatalogType env = br.ufc.pargo.hpe.backend.DGAC.BackEnd.readCatalog(); string xmlEnv = LoaderApp.SerializeCatalog(Constants.PATH_TEMP_WORKER + "catalog.xml", env); return(xmlEnv); }
public async Task <ActionResult <CatalogType> > AddCatalogType(string type) { var newCatalogType = new CatalogType(); newCatalogType.Type = type; await _typeRepository.AddAsync(newCatalogType); return(Ok()); }
public IAcquisitionService GetAcquisitionService(CatalogType catalogType) { switch (catalogType) { case CatalogType.Litres: return new LitresAcquisitionService(_webClient); } throw new NotImplementedException(); }
private CatalogItem(string name, string description, double price, string pictureUri, CatalogType catalogType) { Id = Guid.NewGuid(); Name = name; Description = description; Price = price; PictureUri = pictureUri; CatalogType = catalogType; CreatedUtc = DateTime.UtcNow; }
private ObjectChooser(MainForm.DoWaitCallback doWaitCB, MainForm.StopWaitCallback stopWaitCB, MainForm.updateProgressCallback updateProgressCB, MainForm.listViewAddCallBack listViewAddCB, CatalogType resourceType) : this() { this.doWaitCB = doWaitCB; this.stopWaitCB = stopWaitCB; this.updateProgressCB = updateProgressCB; this.listViewAddCB = listViewAddCB; this.resourceType = resourceType; }
private void SelectOriginalOrDeltaCheckBox(CatalogType catalogType) { if (OriginalCatalogCheckbox.Selected != (catalogType == CatalogType.Original)) { OriginalCatalogCheckbox.Click(); } else if (DeltaCatalogCheckbox.Selected != (catalogType == CatalogType.Delta)) { DeltaCatalogCheckbox.Click(); } }
private void SelectCatalogTypeOrginalOrDelta(CatalogType catalogType) { if (catalogType == CatalogType.Original) { OriginalRadioButton.Click(); } else if (catalogType == CatalogType.Delta) { DeltaRadioButton.Click(); } }
public static void TableExpensesDynamic(int from, int to) { List <Expenses> expensesList = Data.GetExpenses().Where(x => x.Id > from && x.Id <= to).ToList(); int maxEnum = Enum.GetValues(typeof(CatalogType)).Cast <int>().Max(); int minEnum = Enum.GetValues(typeof(CatalogType)).Cast <int>().Min(); for (CatalogType catalogType = (CatalogType)minEnum; catalogType <= (CatalogType)maxEnum; catalogType++) { Data.CreateFile(catalogType.ToString()); } List <Catalog> categories = Data.GetList(CatalogType.GoodsCategory + ".csv"); List <Catalog> goods = Data.GetList(CatalogType.Goods + ".csv"); List <Catalog> units = Data.GetList(CatalogType.Unit + ".csv"); string mainHeader = "ПОКУПКИ"; string[] header = new string[] { "ID", "Категория", "Наименование", "Ед.измер.", "Цена", "Кол-во", "Дата" }; int WindowWidth = Console.WindowWidth - 4; int[] maxWidth = new int[] { Constant.IdColumnPers, Constant.CategoryColumnPers, Constant.NameColumnPers, Constant.UnitColumnPers, Constant.PriceColumnPers, Constant.QuantityColumnPers, Constant.DateColumnPers }; for (int i = 1; i < maxWidth.Length; i++) { maxWidth[i] = (int)(Console.WindowWidth / 100f * maxWidth[i]); } Console.Clear(); Console.WriteLine(" ." + new string('_', WindowWidth) + "."); Console.WriteLine(" |" + new string(' ', WindowWidth) + "|"); Console.WriteLine(" |" + WriteCenter(mainHeader, WindowWidth)); Console.WriteLine(" |" + new string('_', WindowWidth) + "|"); Console.WriteLine(" |" + WriteStr(maxWidth, ' ')); Console.WriteLine(" |" + WriteCenterStr(header, maxWidth)); Console.WriteLine(" |" + WriteStr(maxWidth, '_')); for (int i = 0; i < expensesList.Count; i++) { Console.WriteLine(" |" + WriteStr(maxWidth, ' ')); string[] row = new string[] { expensesList[i].Id.ToString(), categories.FirstOrDefault(x => x.Id == expensesList[i].CategoryId).Name, goods.FirstOrDefault(x => x.Id == expensesList[i].GoodsId).Name, units.FirstOrDefault(x => x.Id == expensesList[i].UnitId).Name, expensesList[i].Price.ToString(), expensesList[i].Quantity.ToString(), expensesList[i].Date.ToShortDateString() }; CellLineBreak(row, maxWidth); Console.WriteLine(" |" + WriteStr(maxWidth, '_')); } }
public async Task <bool> AddTypes() { _logger.LogInformation("addtypes called."); CatalogType ctype = new CatalogType(); ctype.Id = 123; ctype.Type = "anupam"; var types = await _typeRepository.AddAsync(ctype); return(true); }
public CatalogInfo(XElement node) { string value; if (node.TryGetAttributeValue("id", out value)) _id = int.Parse(value); XElement n = node.Element("name"); if (n != null && n.TryGetValue(out value)) _name = value; n = node.Element("description"); if (n != null && n.TryGetValue(out value)) _description = value; n = node.Element("type"); if (n != null && n.TryGetValue(out value)) _type = (CatalogType)System.Enum.Parse(typeof(CatalogType), value); }
protected void Page_Init(object sender, EventArgs e) { string catalog = Request.QueryString["catalog"]; if (!string.IsNullOrEmpty(catalog)) { try { _catalogType = (CatalogType)Enum.Parse(typeof(CatalogType), catalog); } catch { } } string category = Request.QueryString["category"]; if (!string.IsNullOrEmpty(category)) { try { _categoryId = int.Parse(category); } catch { } } string creator = Request.QueryString["creator"]; if (!string.IsNullOrEmpty(creator)) _creatorId = HttpUtility.UrlDecode(creator); }
protected static string QueryType(CatalogType type) { switch (type) { case CatalogType.年级_幼儿园: case CatalogType.年级_初中: case CatalogType.年级_小学: case CatalogType.年级_高中: { return "Grade"; } case CatalogType.课程: { return "Course"; } default: { return "Catalog"; } } }
public static CatalogFolderModel ToFolder(this CatalogContentDto catalogContentDto, string authorityUrl, CatalogType type, int catalogId) { var folderModel = new CatalogFolderModel(); var folderItems = new List<CatalogItemModel>(); if (catalogContentDto.Links != null) { // pagination, next page var nextPageLink = catalogContentDto.Links.SingleOrDefault(l => !string.IsNullOrEmpty(l.Rel) && l.Rel.Equals("next") && !string.IsNullOrEmpty(l.Type) && (l.Type.Contains(CATALOG_LINK_TYPE_PREFIX) || (l.Type.Contains(CATALOG_LINK_TYPE)))); if (nextPageLink != null) { folderModel.NextPageUrl = GetValidUrl(nextPageLink.Href, authorityUrl); } } if (catalogContentDto.Entries != null) { foreach (var entryDto in catalogContentDto.Entries) { CatalogItemModel model = null; // book or just folder var links = entryDto.Links.Where(e => { if (string.IsNullOrEmpty(e.Rel) || (!e.Rel.StartsWith(REL_ACQUISITION_PREFIX))) { if (string.IsNullOrEmpty(e.Type) || !(e.Type.StartsWith(APPLICATION_PREFIX) && FormatConstants.Any(fc => e.Type.Contains(fc)) && !ApparentlyIgnoredFormatConstants.Any(fc => e.Type.Contains(fc)))) { return false; } return true; } return !string.IsNullOrEmpty(e.Type); // && FormatConstants.Any(formatConstant => e.Type.Contains(formatConstant)); }); if (links.Count() != 0) { // links with price var priceLink = links.SingleOrDefault(l => REL_ACQUISITION_BUY_PREFIX.Equals(l.Rel) && !string.IsNullOrEmpty(l.Href) && l.Prices != null && l.Prices.Any(p => !p.Price.Equals("0.00"))); // download links for diff. formats var downloadLinks = (from linkDto in links where !string.IsNullOrEmpty(linkDto.Type) && !string.IsNullOrEmpty(linkDto.Href) && !REL_ACQUISITION_BUY_PREFIX.Equals(linkDto.Rel) select new BookDownloadLinkModel { Type = linkDto.Type, Url = GetValidUrl(linkDto.Href, authorityUrl, true) }).Where(dl => FormatConstants.Any(fc => dl.Type.Contains(fc))).ToList(); // if there are now supported formats in downloadLinks, but there were some acquisition links with another formats => skip this book. if (!downloadLinks.Any() && priceLink == null) { var htmlBuyLink = links.SingleOrDefault(l => REL_ACQUISITION_BUY_PREFIX.Equals(l.Rel)); if (htmlBuyLink == null) { continue; } model = new CatalogItemModel {HtmlUrl = GetValidUrl(htmlBuyLink.Href, authorityUrl)}; } else { // this is book BookAcquisitionLinkModel acquisitionLink = null; if (priceLink != null && priceLink.Prices.Any(p => !p.Price.Equals("0.00"))) { acquisitionLink = new BookAcquisitionLinkModel { Type = !string.IsNullOrEmpty(priceLink.DcFormat) ? priceLink.DcFormat : priceLink.Type, Prices = priceLink.Prices != null ? priceLink.Prices.Select(p => new BookPriceModel { CurrencyCode = p.CurrencyCode, Price = p.Price }) .ToList() : null, Url = GetValidUrl(priceLink.Href, authorityUrl) }; } var id = string.IsNullOrEmpty(entryDto.Id) ? string.Concat(catalogId, "-", entryDto.Title) : entryDto.Id; model = new CatalogBookItemModel { AcquisitionLink = acquisitionLink, Links = downloadLinks, Id = id, TrialLink = type == CatalogType.Litres ? CreateTrialLink(entryDto.Id) : null }; } } // check for Litres bookshelf else if (entryDto.Links.Any(l => LITRES_REL_BOOKSHELF_PREFIX.Equals(l.Rel))) { model = new LitresBookshelfCatalogItemModel(); } // check for Litres topup else if (entryDto.Links.Any(l => LITRES_REL_TOPUP_PREFIX.Equals(l.Rel))) { model = new LitresTopupCatalogItemModel { HtmlUrl = LITRES_PUT_MONEY_LINK_FORMAT, Title = LITRES_REL_TOPUP_TITLE }; } else { // this is default folder if (model == null) { model = new CatalogItemModel(); } } // title if (string.IsNullOrEmpty(model.Title)) { if (entryDto.Title == null) { continue; } if (!string.IsNullOrEmpty(entryDto.Title.Text)) { model.Title = entryDto.Title.Text; } else if (!string.IsNullOrEmpty(entryDto.Title.DivValue)) { model.Title = entryDto.Title.DivValue; } else { continue; } } // description model.Description = entryDto.Content != null && !string.IsNullOrEmpty(entryDto.Content.Value) ? entryDto.Content.Value : string.Empty; // author model.Author = entryDto.Author != null && !string.IsNullOrEmpty(entryDto.Author.Name) ? entryDto.Author.Name : string.Empty; // opds catalog url if (!(model is LitresTopupCatalogItemModel) && string.IsNullOrEmpty(model.HtmlUrl)) { var catalogLink = entryDto.Links.FirstOrDefault(l => !string.IsNullOrEmpty(l.Type) && (l.Type.Contains(CATALOG_LINK_TYPE_PREFIX) || l.Type.Contains(CATALOG_LINK_TYPE) || l.Type.Contains(LITRES_CATALOG_LINK_TYPE_))); if (catalogLink != null) { model.OpdsUrl = GetValidUrl(catalogLink.Href, authorityUrl); } } // html url, to open in browser var htmlLink = entryDto.Links.FirstOrDefault(l => HTML_TEXT_LINK_TYPE.Equals(l.Type) && !string.IsNullOrEmpty(l.Href)); if (htmlLink != null) { if (string.IsNullOrEmpty(model.HtmlUrl)) { model.HtmlUrl = GetValidUrl(htmlLink.Href, authorityUrl); } } //image var imageLinks = entryDto.Links.Where(l => !string.IsNullOrEmpty(l.Type) && l.Type.Equals(IMAGE_LINK_TYPE)); if (imageLinks.Any()) { if (imageLinks.Count() > 1) { var imageLink = imageLinks.SingleOrDefault(l => l.Rel.Equals(REL_IMAGE_PREFIX)); if (imageLink != null) { model.ImageUrl = new Uri(GetValidUrl(imageLink.Href, authorityUrl, true)); } } else { model.ImageUrl = new Uri(GetValidUrl(imageLinks.First().Href, authorityUrl, true)); } } // decoding of description & title model.Description = HttpUtility.HtmlDecode(model.Description); model.Title = HttpUtility.HtmlDecode(model.Title); model.Author = HttpUtility.HtmlDecode(model.Author); if (model.Description.Contains("<") && model.Description.Contains(">")) { model.Description = HtmlToText.Convert(model.Description); } model.Description = model.Description.Trim(); if (model.Author.Contains("<") && model.Author.Contains(">")) { model.Author = HtmlToText.Convert(model.Author); } folderItems.Add(model); } } folderModel.Items = folderItems; return folderModel; }
public CatalogNotEnoughMoneyException(CatalogType catalogType, string payMoneyUrl) { CatalogType = catalogType; PayMoneyUrl = payMoneyUrl; }
public CatalogNotEnoughMoneyException(string message, Exception innerException, CatalogType catalogType) : base(message, innerException) { CatalogType = catalogType; }
public CatalogNotEnoughMoneyException(string message, Exception innerException, CatalogType catalogType, string payMoneyUrl) : base(message, innerException) { CatalogType = catalogType; PayMoneyUrl = payMoneyUrl; }
public FillThread(Control objectChooser, CatalogType resourceType , AddCallBack createListViewItemCB , MainForm.updateProgressCallback updateProgressCB , stopFillingCallback stopFillingCB , fillingCompleteCallback fillingCompleteCB ) { this.control = objectChooser; this.resourceType = resourceType; this.addCB = createListViewItemCB; this.updateProgressCB = updateProgressCB; this.stopFillingCB = stopFillingCB; this.fillingCompleteCB = fillingCompleteCB; }
public CatalogAuthorizationException(CatalogType catalogType, string path) { CatalogType = catalogType; Path = path; }
public ItemInfoCollection GetItems(CatalogType catType) { if (_items == null) { _items = new ItemInfoCollection(); foreach (ItemInfo item in Marketplace.Catalogs[catType].Items.Values) { if (Util.AreEqualIgnoreCase(item.CreatorId, Id)) _items.Add(item.Id, item); } } return _items; }
private bool IsExternalCatalog(CatalogType type) { return (StrFileType != CatalogType.AntMovieCatalog3 && StrFileType != CatalogType.AntMovieCatalog4Xtended); }
public CatalogBookAlreadyBoughtException(CatalogType catalogType, string bookId) { CatalogType = catalogType; BookId = bookId; }
public CatalogBookAlreadyBoughtException(string message, Exception innerException, CatalogType catalogType, string bookId) : base(message, innerException) { CatalogType = catalogType; BookId = bookId; }
public AddContent(CatalogType catalogType, IList<string> parameters, ICatalog catalog) { this.catalogType = catalogType; this.parameters = parameters; this.catalog = catalog; }
public CatalogAuthorizationException(string message, Exception innerException, CatalogType catalogType, string path) : base(message, innerException) { CatalogType = catalogType; Path = path; }