Esempio n. 1
0
        public TermTaxonomy CreateFSize(string fsize)
        {
            var entitiy = TermTaxonomy.CreateFSize(fsize);

            _dataContext.AddRange(entitiy);
            return(entitiy);
        }
        protected List <Tuple <int, int> > GetListNewTerms(TaxonomyType[] taxonomyTypes, string companyId)
        {
            var listNewTerms = new List <Tuple <int, int> >();

            foreach (var item in taxonomyTypes)
            {
                var ids = Request[item.ToString() + "Id"];
                if (ids.IsNullOrWhiteSpace().Not())
                {
                    listNewTerms.AddRange(ids
                                          .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                          .Where(x => string.CompareOrdinal(x, "0") != 0)
                                          .Select(x => Tuple.Create(int.Parse(x), (int)item)));
                }

                var others = Request[item.ToString() + "NameOthers"];
                if (others.IsNullOrWhiteSpace().Not())
                {
                    var terms = others.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var newItem in terms)
                    {
                        var newTerm = new Term
                        {
                            Name       = newItem.Trim(),
                            CreatedBy  = User.Identity.GetUserId(),
                            CreatedOn  = DateTime.UtcNow,
                            CompanyId  = Guid.Empty.ToString(),
                            TaxonomyId = (int)item
                        };

                        db.Term.Add(newTerm);
                        db.SaveChanges();
                        var tax = new TermTaxonomy
                        {
                            TermId     = newTerm.Id,
                            Parent     = 0,
                            TaxonomyId = (int)item,
                            CompanyId  = Guid.Empty.ToString(),
                            CreatedBy  = User.Identity.GetUserId(),
                            CreatedOn  = DateTime.UtcNow,
                        };
                        db.TermTaxonomy.Add(tax);
                        db.SaveChanges();
                        listNewTerms.Add(Tuple.Create(newTerm.Id, (int)item));
                    }
                }
            }
            return(listNewTerms);
        }
Esempio n. 3
0
        public ActionResult AddNewBank(string termId, string termName)
        {
            int?id = null;

            if (!string.IsNullOrWhiteSpace(termId))
            {
                id = int.Parse(termId);
            }

            using (DbContextTransaction transaction = db.Database.BeginTransaction())
            {
                try
                {
                    var term = new Term();
                    term.Name       = termName;
                    term.CreatedOn  = DateTime.Now;
                    term.CompanyId  = Guid.Empty.ToString();
                    term.TaxonomyId = (int)TaxonomyType.BankName;

                    //if (!term.Id.HasValue || term.Id.Value < 1)
                    //else
                    //    db.Entry(term).State = EntityState.Modified;

                    db.Term.Add(term);
                    db.SaveChanges();



                    TermTaxonomy tx = new TermTaxonomy();
                    tx.Parent     = 0;
                    tx.TermId     = term.Id;
                    tx.CompanyId  = term.CompanyId;
                    tx.TaxonomyId = term.TaxonomyId;
                    db.TermTaxonomy.Add(tx);
                    db.SaveChanges();
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                }
            }

            return(BankGuide(id));
        }
Esempio n. 4
0
        public List <TermTaxonomy> ConvertToFilterable(TermTaxonomy color)
        {
            List <TermTaxonomy> result;

            if (directMapping.TryGetValue(color.Term.LowerName, out result))
            {
                return(result);
            }

            result = new List <TermTaxonomy>();
            foreach (var fcolour in _filterableColours)
            {
                if (color.Term.LowerName.Contains(fcolour.Term.LowerName))
                {
                    result.Add(fcolour);
                }
            }

            return(result);
        }
Esempio n. 5
0
        //[ValidateAntiForgeryToken]
        public ActionResult AddNewTerm(string companyId, int taxonomyId, string termName, int termParent)
        {
            var term = new Term();

            term.Name       = termName;
            term.CreatedOn  = DateTime.Now;
            term.CompanyId  = companyId;
            term.TaxonomyId = taxonomyId;

            if (term.Id < 1)
            {
                db.Term.Add(term);
            }
            else
            {
                db.Entry(term).State = EntityState.Modified;
            }
            db.SaveChanges();


            TermTaxonomy tx = new TermTaxonomy();

            tx.Parent     = termParent;
            tx.TermId     = term.Id;
            tx.CompanyId  = term.CompanyId;
            tx.TaxonomyId = term.TaxonomyId;
            db.TermTaxonomy.Add(tx);
            db.SaveChanges();


            //foreach (ModelState modelState in ViewData.ModelState.Values)
            //{
            //    foreach (ModelError error in modelState.Errors)
            //    {
            //        var t = error;
            //    }
            //}
            return(Taxonomies(companyId, taxonomyId));
        }
Esempio n. 6
0
        /// <summary>
        /// Создаст FColours в БД
        /// </summary>
        /// <param name="fcolours"></param>
        public void CreateFColours(string[] fcolours)
        {
            var entities = fcolours.Select(x => TermTaxonomy.CreateFColour(x)).ToArray();

            _dataContext.AddRange(entities);
        }