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)),
                };
            }));
        }
Пример #2
0
 public BlockedProducerSynonym(ProducerSynonym synonym)
 {
     Producer  = synonym.Producer;
     Synonym   = synonym.Name;
     BlockedOn = DateTime.Now;
     Price     = synonym.Price;
 }
        public virtual void CreateEquivalent(uint excludeId, uint producerId)
        {
            Transaction(s => {
                var exclude  = s.Load <Exclude>(excludeId);
                var producer = s.Load <Producer>(producerId);

                var equivalent = exclude.ProducerSynonym.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);
                }

                exclude.Remove(s);
            });
        }
Пример #4
0
        public void SynonymWasDeleted(ProducerSynonym synonym)
        {
            var smtp = new SmtpClient(_smtpServer);

            smtp.Send("*****@*****.**",
                      _synonymDeleteNotificationMail,
                      "Удален синоним производителя",
                      String.Format(@"Синоним: {0}
Производитель: {1}
Поставщик: {2}
Регион: {3}
", synonym.Name,
                                    synonym.Producer.Name, synonym.Price.Supplier.Name, synonym.Price.Supplier.Region.Name));
        }
        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);
            });
        }
Пример #6
0
 public SuspiciousProducerSynonym(ProducerSynonym synonym)
 {
     Synonym = synonym;
 }
 public virtual IList <ProducerSynonymDto> GetSynonymsWithProduct(uint producerId, uint catalogProductId)
 {
     return(Slave(session => ProducerSynonym.LoadWithProduct(session, new Query("ProducerId", producerId), catalogProductId)));
 }
 public virtual IList <ProducerSynonymDto> GetSynonyms(uint producerId)
 {
     return(Slave(session => ProducerSynonym.Load(session, new Query("ProducerId", producerId))));
 }