public ActionResult Create(MasterCategory cvm, HttpPostedFileBase imgfile)
        {
            string path = uploadimgfile(imgfile);

            if (path.Equals("-1"))
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                MasterCategory cat = new MasterCategory();
                cat.CatName     = cvm.CatName;
                cat.CatPhoto    = path;
                cat.cat_status  = 1;
                cat.Description = cvm.Description;
                cat.isActive    = false;
                if (cvm.statusex == "Yes")
                {
                    cat.isActive = true;
                }

                db.MasterCategorys.Add(cat);
                db.SaveChanges();
                ViewBag.MasterCategory = new SelectList(db.MasterCategorys, "IisActive");
                return(RedirectToAction("Index"));
            }

            return(View());
        } //end,,,,,,,,,,,,,,,,,,,
        public IHttpActionResult UpdateLookUpValue(MasterCategory data)
        {
            if (data != null)
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var record = entity.Categories.Where(x => x.CatgCode == data.CatgCode).First();
                record.CatgDesc = data.CatgDesc;
                record.CatgCode = data.CatgCode;
                record.DeptCode = data.DeptCode;
                record.DiscPer  = data.DiscPer;

                try
                {
                    entity.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
            }
            return(Ok(data));
        }
        public ActionResult Edit(int?id)
        {
            MasterCategory masterCategory = db.MasterCategorys.Find(id);

            Session["FileName"] = masterCategory.CatPhoto;
            return(View(masterCategory));
        }
示例#4
0
        public CategoryViewModel(MasterCategory masterCategory, Category category)
        {
            this.MasterCategory = masterCategory;
            this.Category = category;

            this.Name = $"{masterCategory.Name} - {category.Name}";
        }
示例#5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
            MasterCategory masterCategory = new MasterCategory();

            masterCategory.Show();
        }
示例#6
0
        public IActionResult Index()
        {
            List <Category> AllCategories = CategoryList();

            MasterCategory MasterCategory = new MasterCategory(AllCategories);

            return(View(MasterCategory));
        }
示例#7
0
        public ActionResult Delete(Int16 id)
        {
            MasterCategory cat = db.MasterCategories.Where(x => x.CategoryId == id).Single <MasterCategory>();

            db.MasterCategories.DeleteOnSubmit(cat);
            db.SubmitChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            MasterCategory masterCategory = db.MasterCategorys.Find(id);

            db.MasterCategorys.Remove(masterCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#9
0
        public void MasterCategoryWithGuidNode_ValidatePosInReversalGuid()
        {
            string input =
                @"<eticPOSList xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#' xmlns:owl='http://www.w3.org/2002/07/owl#'>
				   <item type='category' id='Adjective' guid='30d07580-5052-4d91-bc24-469b8b2d7df9'>
					  <abbrev ws='en'>adj</abbrev>
					  <term ws='en'>Adjective</term>
					  <def ws='en'>An adjective is a part of speech whose members modify nouns. An adjective specifies the attributes of a noun referent. Note: this is one case among many. Adjectives are a class of modifiers.</def>
				   </item>
				   <item type='category' id='Adposition' guid='ae115ea8-2cd7-4501-8ae7-dc638e4f17c5'>
					  <abbrev ws='en'>adp</abbrev>
					  <term ws='en'>Adposition</term>
					  <def ws='en'>An adposition is a part of speech whose members are of a closed set and occur before or after a complement composed of a noun phrase, noun, pronoun, or clause that functions as a noun phrase and forms a single structure with the complement to express its grammatical and semantic relation to another unit within a clause.</def>
					  <item type='category' id='Postposition' guid='18f1b2b8-0ce3-4889-90e9-003fed6a969f'>
						 <abbrev ws='en'>post</abbrev>
						 <term ws='en'>Postposition</term>
						 <def ws='en'>A postposition is an adposition that occurs after its complement.</def>
						  <item type='category' id='PPchild' guid='82B1250A-E64F-4AD8-8B8C-5ABBC732087A'>
							 <abbrev ws='en'>ppc</abbrev>
							 <term ws='en'>PPchild</term>
							 <def ws='en'>An imaginary POS to test another code path.</def>
						  </item>
					  </item>
					</item>
				</eticPOSList>"                ;

            var mRevIndexFactory = Cache.ServiceLocator.GetInstance <IReversalIndexFactory>();
            var index            = mRevIndexFactory.Create();

            Cache.LangProject.LexDbOA.ReversalIndexesOC.Add(index);
            ICmPossibilityListFactory fact = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>();

            index.PartsOfSpeechOA = fact.Create();
            var posList = index.PartsOfSpeechOA;
            var doc     = new XmlDocument();

            doc.LoadXml(input);
            var rootItem = doc.DocumentElement.ChildNodes[1];
            var mc       = MasterCategory.Create(POSEmptySet, rootItem, Cache);

            m_actionHandler.EndUndoTask();
            Assert.That(posList, Is.Not.Null, "Test requires default init of cache to create POS list");
            mc.AddToDatabase(Cache, posList, null, null);

            var childItem = rootItem.ChildNodes[3];
            var firstPos  = (IPartOfSpeech)posList.PossibilitiesOS[0];
            var mcChild   = MasterCategory.Create(new HashSet <IPartOfSpeech> {
                firstPos
            }, childItem, Cache);

            mcChild.AddToDatabase(Cache, posList, null, firstPos);

            Assert.That(firstPos.Guid, Is.Not.Null, "Item in the category should not be null Guid");
            Assert.That(firstPos.SubPossibilitiesOS[0].Guid, Is.Not.Null, "Sub-Item in the category should not be null Guid");
            Assert.IsFalse(firstPos.SubPossibilitiesOS[0].Guid == Guid.Empty, "Sub-Item in the category should not be Empty Guid");
        }
示例#10
0
        public ActionResult Edit(MasterCategory_model cat)
        {
            MasterCategory tblcat = db.MasterCategories.Where(x => x.CategoryId == cat.CategoryId).Single <MasterCategory>();

            tblcat.CategoryName        = cat.CategoryName;
            tblcat.CategoryDescription = cat.CategoryDescription;
            tblcat.CategoryId          = cat.CategoryId;
            db.SubmitChanges();
            return(View());
        }
 public ActionResult Edit([Bind(Include = "Id,Name")] MasterCategory masterCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(masterCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(masterCategory));
 }
示例#12
0
        private void InitializeCategories(MasterCategory masterCategory)
        {
            _categories = new TransformingObservableCollection <Category, CategoryRowViewModel>(
                masterCategory.Categories,
                c => { return(new CategoryRowViewModel(this, c, _budgetEditor)); },
                cvm => { cvm.Dispose(); });

            _categories.Sort(c => c.Category.SortOrder);
            _categories.CollectionChanged += Categories_CollectionChanged;
        }
示例#13
0
        public ActionResult category(MasterCategory_model cat)
        {
            MasterCategory tblcat = new MasterCategory();

            tblcat.CategoryName        = cat.CategoryName;
            tblcat.CategoryDescription = cat.CategoryDescription;
            db.MasterCategories.InsertOnSubmit(tblcat);
            db.SubmitChanges();
            return(View());
        }
        public ActionResult Create([Bind(Include = "Id,Name")] MasterCategory masterCategory)
        {
            if (ModelState.IsValid)
            {
                db.MasterCategories.Add(masterCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(masterCategory));
        }
示例#15
0
 public int AddUpdateCategory([FromBody] MasterCategory category)
 {
     if (category.Category_ID <= 0)
     {
         return(CategoryService.AddCategory(category));
     }
     else
     {
         return(CategoryService.UpdateCategory(category));
     }
 }
        public async Task <IActionResult> AddMasterCategory(MasterCategory masterCategory, IFormFile McPicturePath)
        {
            if (McPicturePath != null)
            {
                masterCategory.PicturePath = FileExtension.UploadFile(McPicturePath, "wwwroot/static/uploads/categories").Replace(@"\", "/");
            }
            using var context = new EsramDbContext();
            context.MasterCategories.Add(masterCategory);
            int result = await context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> EditMasterCategory(MasterCategory mc, IFormFile PicturePath)
        {
            if (PicturePath != null)
            {
                mc.PicturePath = FileExtension.UploadFile(PicturePath, "wwwroot/static/uploads/categories").Replace(@"\", "/");
            }
            using var context = new EsramDbContext();
            context.MasterCategories.Update(mc);
            await context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        // GET: MasterCategories/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterCategory masterCategory = db.MasterCategories.Find(id);

            if (masterCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(masterCategory));
        }
        public IHttpActionResult DeleteLookUpValue(MasterCategory data)
        {
            var record = entity.Categories.Where(x => x.CatgCode == data.CatgCode).First();

            if (record == null)
            {
                return(NotFound());
            }

            entity.Categories.Remove(record);
            entity.SaveChanges();

            return(Ok(record));
        }
        public IHttpActionResult SaveLookUpValue(MasterCategory data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            entity.Categories.Add(new Category {
                CatgCode = data.CatgCode, CatgDesc = data.CatgDesc, DeptCode = data.DeptCode, DiscPer = data.DiscPer
            });
            entity.SaveChanges();

            return(Ok(data));
        }
示例#21
0
 public IActionResult NewCategory(MasterCategory NewCategory)
 {
     if (ModelState.IsValid)
     {
         Category Category = new Category(NewCategory);
         dbContext.Categories.Add(Category);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         List <Category> AllCategories = CategoryList();
         NewCategory.Categories = AllCategories;
         return(View("Index", NewCategory));
     }
 }
 public JsonResult EditMaster(MasterCategory model)
 {
     if (ModelState.IsValid)
     {
         if (model.IsNew)
         {
             _db.MasterCategories.Add(model);
         }
         else
         {
             _db.Entry(model).State = System.Data.EntityState.Modified;
         }
         _db.SaveChanges();
     }
     return(GetErrorMsgJSON());
 }
示例#23
0
        public MasterCategoryRowViewModel(MasterCategory masterCategory, BudgetEditorViewModel budgetEditor)
        {
            _masterCategory           = masterCategory;
            _budgetEditor             = budgetEditor;
            _addCategoryEditor        = new AddCategoryViewModel(this);
            _editMasterCategoryEditor = new EditMasterCategoryViewModel(this);

            if (!_masterCategory.Categories.IsLoaded)
            {
                _masterCategory.Categories.LoadCollection();
            }

            InitializeCategories(masterCategory);

            InitializeMonthViews();
            UpdateIsFirstCategoryRow();
        }
示例#24
0
        private static MasterCategory CreateCategory(string name, string[] subCategories)
        {
            var category = new MasterCategory()
            {
                Name = name
            };

            foreach (string subCategoryName in subCategories)
            {
                var subCategory = new Category()
                {
                    Name = subCategoryName
                };
                category.Categories.Add(subCategory);
            }
            return(category);
        }
        public static int UpdateCategory(MasterCategory category)
        {
            int result = 0;
            EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(Global.jSSEConn);

            //Parameter Names
            string[] JsseParams = new[] { "CategoryID", "Category", "CategoryDesc", "CreatedBy", "Active" };
            try
            {
                var JsseValues = new object[] { category.Category_ID, category.Category, category.CategoryDesc, category.ModifiedBy, category.IsActive };
                var jsseMain   = DBGeneric.ExecStoredProcedure(entityBuilder.ProviderConnectionString, "dbo.[usp_JSSE_InsertUpdateCategory]",
                                                               JsseParams, JsseValues);
            }
            catch
            {
                throw;
            }
            return(result);
        }
示例#26
0
 public Boolean Equals(Category c)
 {
     if (!MasterCategory.Equals(c.MasterCategory))
     {
         return(false);
     }
     if (SubCategories.Count != c.SubCategories.Count)
     {
         return(false);
     }
     for (int i = 0; i < SubCategories.Count; i++)
     {
         if (!SubCategories[i].Equals(c.SubCategories[i]))
         {
             return(false);
         }
     }
     return(true);
 }
示例#27
0
 public void AddCategory(AddCategoryViewModel model)
 {
     try
     {
         if (model != null)
         {
             MasterCategory entity = new MasterCategory();
             entity.CategoryName = model.CategoryName;
             db.MasterCategories.Add(entity);
         }
         else
         {
             throw new Exception("Category could not be blank!");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#28
0
        public void GetBestWritingSystemForNamedNode_FallsThrough()
        {
            const string inputTemplate =
                @"<eticPOSList xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#' xmlns:owl='http://www.w3.org/2002/07/owl#'>
   <item type='category' id='Adjective' guid='30d07580-5052-4d91-bc24-469b8b2d7df9'>
	  <abbrev ws='en'/> <!-- self-closing -->
	  <term ws='en'></term> <!-- empty -->
	  <def ws='en'>{0}</def> <!-- populated -->
	  <abbrev ws='fr'>{1}</abbrev>
	  <term ws='fr'>{2}</term>
	  <def ws='fr'>{3}</def>
   </item>
</eticPOSList>";
            const string defEn  = "An adjective modifies a noun.";
            const string abbrFr = "adj";
            const string nameFr = "Adjectif";
            const string defFr  = "Un adjectif est un modificateur du nom.";

            Cache.ServiceLocator.WritingSystemManager.GetOrSet(WSFr, out var wsDefFr);
            // NOT CurrentAWS. We need to be able fall through to English, even if the user has hidden it (LT-19115)
            Cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Add(wsDefFr);
            // Commit WS changes
            m_actionHandler.EndUndoTask();

            var doc = new XmlDocument();

            doc.LoadXml(string.Format(inputTemplate, defEn, abbrFr, nameFr, defFr));
            var posNode = doc.DocumentElement.ChildNodes[0];

            // SUT
            var wsAbbrev = MasterCategory.GetBestWritingSystemForNamedNode(posNode, "abbrev", WSEn, Cache, out var outAbbrev);
            var wsTerm   = MasterCategory.GetBestWritingSystemForNamedNode(posNode, "term", WSEn, Cache, out var outTerm);
            var wsDef    = MasterCategory.GetBestWritingSystemForNamedNode(posNode, "def", WSEn, Cache, out var outDef);

            Assert.AreEqual(wsAbbrev, WSFr, "self-closing should fall through");
            Assert.AreEqual(abbrFr, outAbbrev);
            Assert.AreEqual(wsTerm, WSFr, "empty should fall through");
            Assert.AreEqual(nameFr, outTerm);
            Assert.AreEqual(wsDef, WSEn, "populated should be taken");
            Assert.AreEqual(defEn, outDef);
        }
        public MasterCategoryMonthView(MasterCategory category, DateTime date)
        {
            MasterCategory = category;
            if (!category.Categories.IsLoaded)
            {
                category.Categories.LoadCollection();
            }
            _date = date.FirstDayOfMonth();

            _categories = new TransformingObservableCollection <Category, CategoryMonthView>(MasterCategory.Categories,
                                                                                             sc =>
            {
                return(new CategoryMonthView(sc, _date));
            },
                                                                                             scv =>
            {
                scv.Dispose();
            }, null, null, true);

            _categories.ItemPropertyChanged += Categories_ItemPropertyChanged;

            CalculateValues();
        }
        public ActionResult Edit(MasterCategory cvm, HttpPostedFileBase imgfile)
        {
            string path = "";
            var    cat  = db.MasterCategorys.Where(x => x.CategoryID == cvm.CategoryID).FirstOrDefault();

            if (cat.CatPhoto == Session["FileName"].ToString() && imgfile == null)
            {
                path = cat.CatPhoto;
            }
            else
            {
                path = uploadimgfile1(imgfile);
            }
            if (path.Equals("-1") && cat.CatPhoto != Session["FileName"].ToString())
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                cat.CatName     = cvm.CatName;
                cat.CatPhoto    = path;
                cat.cat_status  = 1;
                cat.Description = cvm.Description;
                cat.isActive    = false;
                if (cvm.statusex == "Yes")
                {
                    cat.isActive = true;
                }
                //db.MasterCategories.Add(cat);
                //  db.Entry(cat).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.MasterCategory = new SelectList(db.MasterCategorys, "IisActive");
                return(RedirectToAction("Index"));
            }
            return(View());
        }
示例#31
0
			private XmlNode m_node; // need to remember the node so can put info for *all* writing systems into databas

			public static MasterCategory Create(Set<ICmPossibility> posSet, XmlNode node, FdoCache cache)
			{
				/*
				<item type="category" id="adjective">
					<abbrev ws="en">adj</abbrev>
					<term ws="en">adjective</term>
					<def ws="en">An adjective is a part of speech whose members modify nouns. An adjective specifies the attributes of a noun referent. Note: this is one case among many. Adjectives are a class of modifiers.</def>
					<citation ws="en">Crystal 1997:8</citation>
					<citation ws="en">Mish et al. 1990:56</citation>
					<citation ws="en">Payne 1997:63</citation>
				</item>
				*/

				MasterCategory mc = new MasterCategory();
				mc.m_isGroup = node.SelectNodes("item") != null;
				mc.m_id = XmlUtils.GetManditoryAttributeValue(node, "id");
				mc.m_pos = PartOfSpeech.GoldPOS(posSet, mc.m_id);

				mc.m_node = node; // remember node, too, so can put info for all WSes in database

				string sDefaultWS = cache.LangProject.DefaultAnalysisWritingSystemICULocale;
				string sContent;
				mc.m_abbrevWs = GetBestWritingSystemForNamedNode(node, "abbrev", sDefaultWS, cache, out sContent);
				mc.m_abbrev = sContent;

				mc.m_termWs = GetBestWritingSystemForNamedNode(node, "term", sDefaultWS, cache, out sContent);
				mc.m_term = NameFixer(sContent);

				mc.m_defWs = GetBestWritingSystemForNamedNode(node, "def", sDefaultWS, cache, out sContent);
				mc.m_def = sContent;

				foreach (XmlNode citNode in node.SelectNodes("citation"))
					mc.m_citations.Add(new MasterCategoryCitation(XmlUtils.GetManditoryAttributeValue(citNode, "ws"), citNode.InnerText));
				return mc;
			}
示例#32
0
			public void AddToDatabase(FdoCache cache, ICmPossibilityList posList, MasterCategory parent, IPartOfSpeech subItemOwner)
			{
				CheckDisposed();

				if (m_pos != null)
					return; // It's already in the database, so nothing more can be done.

				cache.BeginUndoTask(LexTextControls.ksUndoCreateCategory,
									LexTextControls.ksRedoCreateCategory);
				int newOwningFlid;
				int insertLocation;
				int newOwner =
					DeterminePOSLocationInfo(subItemOwner, parent, posList, out newOwningFlid, out insertLocation);
				ILgWritingSystemFactory wsf = cache.LanguageWritingSystemFactoryAccessor;
				Debug.Assert(m_pos != null);

				if (m_node == null)
				{ // should not happen, but just in case... we still get something useful
					m_pos.Name.SetAlternative(m_term, wsf.GetWsFromStr(m_termWs));
					m_pos.Abbreviation.SetAlternative(m_abbrev, wsf.GetWsFromStr(m_abbrevWs));
					m_pos.Description.SetAlternative(m_def, wsf.GetWsFromStr(m_defWs));
				}
				else
				{
					SetContentFromNode(cache, "abbrev", false, m_pos.Abbreviation);
					SetContentFromNode(cache, "term", true, m_pos.Name);
					SetContentFromNode(cache, "def", false, m_pos.Description);
				}

				m_pos.CatalogSourceId = m_id;
				// Need a PropChanged, since it isn't done in the 'Append' for some reason.
				cache.PropChanged(null, PropChangeType.kpctNotifyAll,
								  newOwner, newOwningFlid, insertLocation, 1, 0);
				cache.EndUndoTask();
			}
示例#33
0
			private int DeterminePOSLocationInfo(IPartOfSpeech subItemOwner, MasterCategory parent, ICmPossibilityList posList, out int newOwningFlid, out int insertLocation)
			{
				int newOwner;
				// This is the index of the new object in the list.  See LT-5608.
				if (subItemOwner != null)
				{
					newOwner = subItemOwner.Hvo;
					newOwningFlid = (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities;
					insertLocation = subItemOwner.SubPossibilitiesOS.Count;
					m_pos = (IPartOfSpeech)subItemOwner.SubPossibilitiesOS.Append(new PartOfSpeech());
				}
				else if (parent != null && parent.m_pos != null)
				{
					newOwner = parent.m_pos.Hvo;
					newOwningFlid = (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities;
					insertLocation = parent.m_pos.SubPossibilitiesOS.Count;
					m_pos = (IPartOfSpeech)parent.m_pos.SubPossibilitiesOS.Append(new PartOfSpeech());
				}
				else
				{
					newOwner = posList.Hvo;
					newOwningFlid = (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities;
					insertLocation = posList.PossibilitiesOS.Count;
					m_pos = (IPartOfSpeech)posList.PossibilitiesOS.Append(new PartOfSpeech());
				}
				return newOwner;
			}
        public PartialViewResult GetById(int id)
        {
            MasterCategory masterCategory = db.MasterCategories.Where(c => c.Id == id).FirstOrDefault();

            return(PartialView("~/Views/MasterCategories/GetById.cshtml", masterCategory));
        }
			private int DeterminePOSLocationInfo(FdoCache cache, IPartOfSpeech subItemOwner, MasterCategory parent, ICmPossibilityList posList,
				out int newOwningFlid, out int insertLocation)
			{
				int newOwner;
				// The XML node is from a file shipped with FieldWorks. It is quite likely multiple users
				// of a project could independently add the same items, so we create them with fixed guids
				// so merge will recognize them as the same objects.
				//// LT-14511 However, if the partOfSpeech is being added to a reversal index, a different guid needs to be used
				//// than the ones in the file shipped with FieldWorks. In this case if two users add the same POS to the
				//// reversal index at the same time and then do a Send/Receive operation, then a merge conflict report
				//// will probably be created for this. This scenario is not likely to occur very often at all so having
				//// a conflict report created for when this happens is something we can live with.
				Guid guid;
				if (posList.Owner is IReversalIndex)
					guid = new Guid();
				else
					guid = new Guid(XmlUtils.GetAttributeValue(m_node, "guid"));
				var posFactory = cache.ServiceLocator.GetInstance<IPartOfSpeechFactory>();
				if (subItemOwner != null)
				{
					newOwner = subItemOwner.Hvo;
					newOwningFlid = CmPossibilityTags.kflidSubPossibilities;
					insertLocation = subItemOwner.SubPossibilitiesOS.Count;
					m_pos = posFactory.Create(guid, subItemOwner);
				}
				else if (parent != null && parent.m_pos != null)
				{
					newOwner = parent.m_pos.Hvo;
					newOwningFlid = CmPossibilityTags.kflidSubPossibilities;
					insertLocation = parent.m_pos.SubPossibilitiesOS.Count;
					m_pos = posFactory.Create(guid, parent.m_pos);
				}
				else
				{
					newOwner = posList.Hvo;
					newOwningFlid = CmPossibilityListTags.kflidPossibilities;
					insertLocation = posList.PossibilitiesOS.Count;
					m_pos = posFactory.Create(guid,posList); // automatically adds to parent.
				}
				return newOwner;
			}
			public void AddToDatabase(FdoCache cache, ICmPossibilityList posList, MasterCategory parent, IPartOfSpeech subItemOwner)
			{
				if (m_pos != null)
					return; // It's already in the database, so nothing more can be done.

				UndoableUnitOfWorkHelper.Do(LexTextControls.ksUndoCreateCategory, LexTextControls.ksRedoCreateCategory,
					cache.ServiceLocator.GetInstance<IActionHandler>(), () =>
				{
					int newOwningFlid;
					int insertLocation;
					int newOwner =
						DeterminePOSLocationInfo(cache, subItemOwner, parent, posList, out newOwningFlid, out insertLocation);
					ILgWritingSystemFactory wsf = cache.WritingSystemFactory;
					Debug.Assert(m_pos != null);

					int termWs = wsf.GetWsFromStr(m_termWs);
					int abbrevWs = wsf.GetWsFromStr(m_abbrevWs);
					int defWs = wsf.GetWsFromStr(m_defWs);
					ITsStrFactory tsf = cache.TsStrFactory;
					if (m_node == null)
					{ // should not happen, but just in case... we still get something useful
						m_pos.Name.set_String(termWs, tsf.MakeString(m_term, termWs));
						m_pos.Abbreviation.set_String(abbrevWs, tsf.MakeString(m_abbrev, abbrevWs));
						m_pos.Description.set_String(defWs, tsf.MakeString(m_def, defWs));
					}
					else
					{
						SetContentFromNode(cache, "abbrev", false, m_pos.Abbreviation);
						SetContentFromNode(cache, "term", true, m_pos.Name);
						SetContentFromNode(cache, "def", false, m_pos.Description);
					}

					m_pos.CatalogSourceId = m_id;
				});
			}
			public static MasterCategory Create(Set<IPartOfSpeech> posSet, XmlNode node, FdoCache cache)
			{
				/*
				<item type="category" id="Adjective" guid="30d07580-5052-4d91-bc24-469b8b2d7df9">
					<abbrev ws="en">adj</abbrev>
					<term ws="en">adjective</term>
					<def ws="en">An adjective is a part of speech whose members modify nouns. An adjective specifies the attributes of a noun referent. Note: this is one case among many. Adjectives are a class of modifiers.</def>
					<citation ws="en">Crystal 1997:8</citation>
					<citation ws="en">Mish et al. 1990:56</citation>
					<citation ws="en">Payne 1997:63</citation>
				</item>
				*/

				MasterCategory mc = new MasterCategory();
				mc.m_isGroup = node.SelectNodes("item") != null;
				mc.m_id = XmlUtils.GetManditoryAttributeValue(node, "id");

				foreach (var pos in posSet)
				{
					if (pos.CatalogSourceId == mc.m_id)
					{
						mc.m_pos = pos;
						break;
					}
				}

				mc.m_node = node; // remember node, too, so can put info for all WSes in database

				string sDefaultWS = cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Id;
				string sContent;
				mc.m_abbrevWs = GetBestWritingSystemForNamedNode(node, "abbrev", sDefaultWS, cache, out sContent);
				mc.m_abbrev = sContent;

				mc.m_termWs = GetBestWritingSystemForNamedNode(node, "term", sDefaultWS, cache, out sContent);
				mc.m_term = NameFixer(sContent);

				mc.m_defWs = GetBestWritingSystemForNamedNode(node, "def", sDefaultWS, cache, out sContent);
				mc.m_def = sContent;

				foreach (XmlNode citNode in node.SelectNodes("citation"))
					mc.m_citations.Add(new MasterCategoryCitation(XmlUtils.GetManditoryAttributeValue(citNode, "ws"), citNode.InnerText));
				return mc;
			}