private Product selectedProduct = null; //выбранный продукт #endregion Fields #region Constructors //КОНСТРУКТОРЫ КЛАССА //+-------------------------------------------------------------------+ /// <summary> /// Конструктор формы с параметрами /// </summary> /// <param name="categories">объект класса "товарные категории"</param> /// <param name="assortment">объект класса "ассортимент товаров"</param> public FormCreateAndEdit(Category categories, Assortment assortment) { this.InitializeComponent(); this.categories = categories; this.assortment = assortment; this.ComboBoxCategoryInitialization(); }
private Category CreateCategory(string categoryName, string categoryId, Assortment assortment, Category parent) { try { var category = new Category(FieldTemplate.SystemId, assortment.SystemId) { Id = categoryId, ParentCategorySystemId = parent?.SystemId ?? Guid.Empty }; foreach (var assortmentLocalization in assortment.Localizations) { var culture = CultureInfo.GetCultureInfo(assortmentLocalization.Key); category.Fields.AddOrUpdateValue("_name", culture, categoryName); category.Fields.AddOrUpdateValue("_url", culture, _suggestionService.Suggest(culture, categoryName)); } _categoryService.Create(category); return(category); } catch (Exception exception) { this.Log().Error($"Cannot create category '{categoryName}' ('{categoryId}') in parent category '{parent?.Id ?? "NULL"}'", exception); throw; } }
public void ADDTest() { Assortment assortment = new Assortment(); assortment.AddEquipment(new Server()); Assert.AreEqual(1, assortment.Servers.Count); assortment.AddEquipment(new Antenna()); Assert.AreEqual(1, assortment.Antennas.Count); assortment.AddEquipment(new Cable()); Assert.AreEqual(1, assortment.Cables.Count); assortment.AddEquipment(new Clock()); Assert.AreEqual(1, assortment.Clocks.Count); assortment.AddEquipment(new Converter()); Assert.AreEqual(1, assortment.Converters.Count); assortment.AddEquipment(new Receiver()); Assert.AreEqual(1, assortment.Receivers.Count); assortment.AddEquipment(new SDU()); Assert.AreEqual(1, assortment.Sdus.Count); assortment.AddEquipment(new SedovServer()); Assert.AreEqual(1, assortment.SedovServers.Count); }
public void CheckMonobrendforExclude() { var excludes = service.ShowExcludes().Content; var exclude = excludes.First(); uint existsProducerId; // устанавливаем для продукта свойство монобренда using (var session = sessionFactory.OpenSession()) { var product = session.Load <Exclude>(exclude.Id).CatalogProduct; product.Monobrend = true; session.Save(product); var producer = session.Query <Producer>().First(); var newAssortment = new Assortment { CatalogProduct = product, Producer = producer }; session.Save(newAssortment); session.Flush(); existsProducerId = producer.Id; } Assert.That(service.CheckProductIsMonobrend(exclude.Id, 0), Is.True); Assert.That(service.CheckProductIsMonobrend(exclude.Id, existsProducerId), Is.False); // возвращаем все назад, чтобы не ломать остальные тесты using (var session = sessionFactory.OpenSession()) { var product = session.Load <Exclude>(exclude.Id).CatalogProduct; product.Monobrend = false; session.Save(product); session.Flush(); } }
//создание товаров static Assortment SetAssortmentTestData(Category categories) { Assortment assortment = new Assortment(categories); // Категория №1: Экран Product screen1 = new Product("Экраны", "Очень хороший", "Супер характеристики","Экран Самсунг", 150); Product screen2 = new Product("Экраны", "нормальный", "неплохие характеристики", "Экран Филипс", 50); Product screen3 = new Product("Экраны", "плохой", "плохие характеристики", "Экран Хуавэй", 10); // Категория №2: Мышки Product mouse1 = new Product("Мышки", "Очень хорошая", "Супер характеристики", "Мышка Logitech", 150); Product mouse2 = new Product("Мышки", "нормальная", "неплохие характеристики", "Мышка Apple", 50); Product mouse3 = new Product("Мышки", "плохая", "плохие характеристики", "Мышка Corsair", 10); //добавление товаров в ассортмент магазина assortment.AddProduct(screen1); assortment.AddProduct(screen2); assortment.AddProduct(screen3); assortment.AddProduct(mouse1); assortment.AddProduct(mouse2); assortment.AddProduct(mouse3); return assortment; }
public virtual ExcludeData GetExcludeData(uint excludeId) { return(Slave(s => { var exclude = s.Load <Exclude>(excludeId); var equivalients = s.CreateSQLQuery(@" select e.ProducerId as Id, concat(e.Name, ' [', p.Name, ' ]') as Name from Catalogs.ProducerEquivalents e join Catalogs.Assortment a on a.ProducerId = e.ProducerId join Catalogs.Producers p on p.Id = a.ProducerId where a.Checked = 1 and a.CatalogId = :catalogId") .SetParameter("catalogId", exclude.CatalogProduct.Id) .SetResultTransformer(new AliasToPropertyTransformer(typeof(ProducerOrEquivalentDto))) .List <ProducerOrEquivalentDto>(); var assortment = Assortment.Search(s, 0, new Query("CatalogId", exclude.CatalogProduct.Id)).Content.Where(a => a.Checked).ToList(); var producers = equivalients .Concat(assortment.Select(a => new ProducerOrEquivalentDto { Id = a.ProducerId, Name = a.Producer })) .OrderBy(p => p.Name).ToList(); return new ExcludeData { Producers = producers, Synonyms = ProducerSynonym.Load(s, new Query("Name", exclude.ProducerSynonym)), }; })); }
public async Task <IActionResult> Edit(int id, [Bind("AssortmentId,AssortmentName,AssortmentBrand,AssortmentPrice,ParamId")] Assortment assortment) { if (id != assortment.AssortmentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(assortment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssortmentExists(assortment.AssortmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ParamId"] = new SelectList(_context.Params, "ParamId", "ParamName", assortment.ParamId); return(View(assortment)); }
public void Get_assortment_for_producer() { var testProducer = session.Query <Producer>().FirstOrDefault(p => p.Name == "test-producer"); if (testProducer != null) { session.Delete(testProducer); } session.Flush(); var producer = new Producer(); producer.Name = "test-producer"; session.Save(producer); var assortment = new Assortment(session.Query <CatalogProduct>().First(), producer); session.Save(assortment); session.Flush(); var producerId = producer.Id; session.Clear(); var assortments = Assortment.Search(session, 0, new Query("ProducerId", producerId)); Assert.That(assortments.Content.Count, Is.EqualTo(1)); var assortment1 = assortments.Content.Single(); Assert.That(assortment1.Producer, Is.EqualTo("test-producer")); }
public void When_assortmentHasPermanentBlock_then_CantUnblockAssortment() { Assortment assortment = AnyPermanentBlockedAssortment(); var result = assortment.Unblock(); Assert.That(result, Is.False); }
//add()数据 public void serch_add_data(string name, Assortment mm) { Assort muser = serchdata(name); Assortmentmessage mserchmassage = muser.mserch; mserchmassage.addnewdata(mm, mserchmassage.getmsderchdatanode()); }
public void Search_text() { var assortments = Assortment.Search(session, 5, null); var findedAssortments = Assortment.Search(session, 0, new Query("ProducerId", assortments.Content[1].ProducerId)); Assert.That(findedAssortments.Content.Count, Is.GreaterThan(1)); Assert.That(findedAssortments.Page, Is.EqualTo(0)); }
//分类词 public Assortment getAssortment(string username, string wordstr, string assortname, string assortpinyin) { AssortmentDatamanage mmm = getAssortmentDatamanage(username, wordstr); Assortment mass = mmm.serch_result(assortname, assortpinyin); return(null); }
/// <summary> /// Конструктор с параметрами /// </summary> /// <param name="categories">информация о существующих товарных /// категориях, представленная объектом класса Category</param> /// <param name="assortment">Информация об ассортименте товаров, /// представленная объектом класса Аssortment</param> public FormOrder(Category categories = null, Assortment assortment = null) : this() { this.categories = categories; this.assortment = assortment; this.ComboBoxProductsInitialization(); }
public void When_assortmentHasPermanentBlock_then_CantBlockPermanently() { Assortment assortment = AnyPermanentBlockedAssortment(); Owner owner = AnyOwner(); var result = assortment.BlockPermanentlyFor(owner); Assert.That(result, Is.False); }
public void When_assortmentHasTemporaryBlockByOtherOwner_then_CantBlockPermanent() { Assortment assortment = AnyTemporaryBlockedAssortment(); Owner owner = Owner.New(Guid.NewGuid()); var result = assortment.BlockPermanentlyFor(owner); Assert.That(result, Is.False); }
public void When_assortmentHasTemporaryBlock_then_UnblockAssortment() { Assortment assortment = AnyTemporaryBlockedAssortment(); var result = assortment.Unblock(); Assert.That(result, Is.True); Assert.That(assortment.IsBlocked(), Is.False); }
public void When_assortmentHasNotBlocks_then_blockAssortment() { Assortment assortment = NotBlockedAssortment(); Owner owner = AnyOwner(); var result = assortment.BlockTemporaryFor(owner); Assert.That(result, Is.True); Assert.That(assortment.IsBlocked(), Is.True); }
public void When_assortmentHasAnyBlock_then_dontLetAddingNewBlockAndKeepBlocking() { Assortment assortment = AnyPermanentBlockedAssortment(); Owner owner = AnyOwner(); var result = assortment.BlockTemporaryFor(owner); Assert.That(result, Is.False); Assert.That(assortment.IsBlocked(), Is.True); }
public void When_assortmentHasNotAnyBlock_then_BlockPermanently() { Assortment assortment = NotBlockedAssortment(); Owner owner = AnyOwner(); var result = assortment.BlockPermanentlyFor(owner); Assert.That(result, Is.True); Assert.That(assortment.IsBlocked(), Is.True); }
public IActionResult Get(int id) { Assortment result = _IUnitOfWork.Assortment.GetByID(id); if (result == null) { return(NotFound("Produkt nie istnieje w bazie danych")); } return(Ok(result)); }
public virtual Pager <AssortmentDto> ShowAssortment(uint assortimentId) { return(Slave(session => { uint page = 0; if (assortimentId != 0) { page = Assortment.GetPage(session, assortimentId); } return Assortment.Search(session, page, null); })); }
/// <summary> /// Конструктор формы с параметрами /// </summary> /// <param name="categories">объект класса "товарные категории"</param> /// <param name="assortment">объект класса "ассортимент товаров"</param> /// <param name="product">продукт, информацию о котором необходимо /// откорректировать</param> public FormCreateAndEdit(Category categories, Assortment assortment, Product product) : this(categories, assortment) { this.selectedProduct = product; this.SetComboBoxCategoryStartIteam(); this.TextBoxNameInitialization(); this.TextBoxCharacteristicsInitialization(); this.TextBoxDescriptionInitialization(); this.TextBoxPriceInitialization(); }
public async Task <IActionResult> Create([Bind("AssortmentId,AssortmentName,AssortmentBrand,AssortmentPrice,ParamId")] Assortment assortment) { if (ModelState.IsValid) { _context.Add(assortment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ParamId"] = new SelectList(_context.Params, "ParamId", "ParamName", assortment.ParamId); return(View(assortment)); }
//搜索相关的词语 public Assortment serchofword(Assortmentdatanode mm, string m2) { Assortment mword = mm.getuser_work(); if (mword.getWord() == m2) { return(mword); } else { return(serchofword(mm.getnextserchdatanode(), m2)); } }//
public AssortimentsWrapper(Assortment _assortment) { if (_assortment == null) { } else { m_Assortment = _assortment; if (_assortment.Product == null) { _assortment.Product = new Product(); } } }
protected override Constants.ProcessOutcome Process() { var fileName = String.Format(Settings.Default.FileName, DateTime.Now.AddDays(Settings.Default.FileNameDateCheckOffsetDays).ToString("yyyyMMdd")); importer = new Assortment(Settings.Default.FilePath, fileName, Settings.Default.StagingTableName, Settings.Default.FormatFilePath, Settings.Default.ArchivePath, Settings.Default.SummaryReportErrorToEmailAddress, Settings.Default.SummaryReportFromEmailAddress, Settings.Default.SummaryReportFromAddressFriendlyName, Settings.Default.SqlaServerPath, Settings.Default.SqlbServerPath, Settings.Default.LocalSqlPath, Settings.Default.TemporaryUploadFolder, Settings.Default.DaysToRun); return(importer.Process()); }
//添加文章 public Boolean addserchdatanode(Assortment am) { if (this.nextserchdatanode == null) { Assortmentdatanode mma = new Assortmentdatanode(am); this.nextserchdatanode = mma; return(true); } else { return(false); } }//添加商品
void Awake() { canvas = Assortment.Unpaused; if (instance == null) { instance = this; } else { Destroy(gameObject); return; } }
private Assortment CreateAssortment(StructureInfo structureInfo, string name, string domainName) { var assortment = new Assortment { Id = structureInfo.ProductCatalog.Assortment.Id + _slugifyService.Slugify(CultureInfo.CurrentCulture, name), AccessControlList = structureInfo.ProductCatalog.Assortment.AccessControlList.MakeWritable() }; foreach (var language in _languageService.GetAll()) { assortment.Localizations[language.CultureInfo].Name = name; } _assortmentService.Create(assortment); return(assortment); }
//删除节点 public Boolean deletenode(Assortmentdatanode mm, float gailv) { Assortment mword = mm.getuser_work(); if (mword.getPro() < gailv) { Assortmentdatanode beforenode = mm.getbfserchdatanode(); beforenode.setnextserchdatanode(mm.getnextserchdatanode()); mm = null; return(true); } else { return(deletenode(mm.getnextserchdatanode(), gailv)); } }
public Category GetOrCreateCategory(Assortment assortment, string[] categoryTree) { if (!categoryTree.Any()) { return(null); } var categoryKey = assortment.Id + "---" + string.Join("---", categoryTree); try { if (_categoryLookup.ContainsKey(categoryKey)) { return(_categoryLookup[categoryKey]); } this.Log().Info($"Creating category '{categoryKey}'"); var categoryName = categoryTree.First(); if (string.IsNullOrEmpty(categoryName)) { return(null); } var rootCategories = _categoryService.GetChildCategories(Guid.Empty, assortment.SystemId); var rootCategory = rootCategories.FirstOrDefault(c => c.Id?.Equals(Uri.EscapeDataString(categoryName), StringComparison.InvariantCultureIgnoreCase) ?? false); if (rootCategory == null) { rootCategory = CreateCategory(categoryName, Uri.EscapeDataString(categoryName), assortment, null); } if (rootCategory == null) { throw new Exception("Cannot find or create root category: " + categoryName); } var category = GetOrCreateCategoriesRecursive(assortment, rootCategory, categoryTree.Skip(1).ToList()); _categoryLookup.Add(categoryKey, category); return(category); } catch (Exception exception) { this.Log().Error($"Creating category '{categoryKey}'", exception); return(null); } }
public virtual void AddToAssotrment(uint excludeId, uint producerId, string equivalent) { Transaction(s => { var exclude = s.Load <Exclude>(excludeId); var producer = s.Load <Producer>(producerId); var assortment = new Assortment(exclude.CatalogProduct, producer) { Checked = true }; if (assortment.Exist(s)) { assortment = s.Query <Assortment>() .First(a => a.Producer == assortment.Producer && a.CatalogProduct == assortment.CatalogProduct); assortment.Checked = true; } if (!String.IsNullOrEmpty(equivalent)) { equivalent = equivalent.Trim(); if (!producer.Equivalents.Any(e => e.Name.Equals(equivalent, StringComparison.CurrentCultureIgnoreCase))) { s.Save(new ProducerEquivalent(producer, equivalent)); } } var synonym = new ProducerSynonym { Price = exclude.Price, Name = exclude.ProducerSynonym, Producer = producer }; if (!synonym.Exist(s)) { s.Save(synonym); } s.SaveOrUpdate(assortment); exclude.Remove(s); s.Flush(); assortment.CleanupExcludes(s); }); }
//搜索返回数据 public Assortment serch_result(string username, string wordstr) { Assort muser = serchdata_(username); if (muser == null) { return(null); } Assortmentmessage mserch = muser.mserch; if (mserch == null) { return(null); } Assortment mword = mserch.serchofword(mserch.getmsderchdatanode(), wordstr); return(mword); }
//添加数据文章 public Boolean addnewdata(Assortment nn, Assortmentdatanode ff) { if (ff.getuser_work() == null) { ff.setuser_work(nn); return(true); } else { Assortmentdatanode na = ff.getnextserchdatanode(); if (na == null) { na = new Assortmentdatanode(nn); return(true); } else { return(addnewdata(nn, na)); } // return false; } }
/// <summary> /// Обработка нажатия кнопки "Создать". Добавляет информацию о /// новом товаре в ассортимент товаров. /// </summary> private void ButtonCreate(Object sender, EventArgs e) { this.formCreateAndEdit = new FormCreateAndEdit(this.categories, this.assortment); this.formCreateAndEdit.Owner = this; this.formCreateAndEdit.StartPosition = FormStartPosition.CenterParent; this.formCreateAndEdit.ShowDialog(this); if (this.formCreateAndEdit.DialogResult == DialogResult.OK) { this.selectedProduct = this.formCreateAndEdit.SelectedProduct; this.assortment = this.formCreateAndEdit.Assortment; this.categories = this.formCreateAndEdit.Categoties; this.comboBoxProducts.Items.Clear(); this.ComboBoxProductsInitialization(); this.comboBoxProducts.SelectedItem = this.selectedProduct.Name; this.textBoxPrice.Text = this.selectedProduct.Price.ToString(); } if (this.formCreateAndEdit != null) { this.formCreateAndEdit.Close(); this.formCreateAndEdit.Dispose(); this.formCreateAndEdit = null; } }
/// <summary> /// Обработка нажатия кнопки "Редактировать". Создает окно /// предоставляющее возможность редактировать информацию о выбранном /// товаре. /// </summary> private void ButtonEditClick(Object sender, EventArgs e) { if(this.selectedProduct == null ) { MessageBox.Show( text: "Операция редактирования " + "не может быть выполнена. Не выбрано имя товара, " + "информацию о котором необходимо отредактировать. " + "Выберите имя товара и повторите попытку.", caption: "Уведомление", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Exclamation); } else { this.FormCreateAndEditInitialization(); if (this.formCreateAndEdit.DialogResult == DialogResult.OK) { this.selectedProduct = this.formCreateAndEdit.SelectedProduct; this.assortment = this.formCreateAndEdit.Assortment; this.categories = this.formCreateAndEdit.Categoties; this.comboBoxProducts.Items.Clear(); this.ComboBoxProductsInitialization(); this.comboBoxProducts.SelectedItem = this.selectedProduct.Name; this.textBoxPrice.Text = this.selectedProduct.Price.ToString(); this.textBoxTotalPrice.Text = "0.00"; totalOrderPrice = 0.00; this.listBoxOrderInfo.Items.Clear(); } if (this.formCreateAndEdit != null) { this.formCreateAndEdit.Close(); this.formCreateAndEdit.Dispose(); this.formCreateAndEdit = null; } } }