public void AddScientificRecommendedTaxonName(string name, string author, ITaxon taxon, ITaxonRevision taxonRevision)
        {
            var taxonName = new ArtDatabanken.Data.TaxonName();

            taxonName.DataContext               = new DataContext(_user);
            taxonName.Name                      = name;
            taxonName.Author                    = author;
            taxonName.Category                  = CoreData.TaxonManager.GetTaxonNameCategory(_user, (Int32)TaxonNameCategoryId.ScientificName);
            taxonName.Status                    = CoreData.TaxonManager.GetTaxonNameStatus(_user, TaxonNameStatusId.ApprovedNaming);
            taxonName.NameUsage                 = CoreData.TaxonManager.GetTaxonNameUsage(_user, TaxonNameUsageId.Accepted);
            taxonName.IsRecommended             = true;
            taxonName.Description               = "";
            taxonName.Taxon                     = taxon;
            taxonName.IsOkForSpeciesObservation = true;
            taxonName.IsOriginalName            = false;
            using (ITransaction transaction = _user.StartTransaction())
            {
                CoreData.TaxonManager.CreateTaxonName(_user, taxonRevision, taxonName);
                // Set default reference, set from Revision..
                ReferenceRelationList referencesToAdd = ReferenceHelper.GetDefaultReferences(
                    _user,
                    taxonName,
                    taxonRevision,
                    null);
                var referencesToRemove = new ReferenceRelationList();
                CoreData.ReferenceManager.CreateDeleteReferenceRelations(_user, referencesToAdd, referencesToRemove);
                transaction.Commit();
            }
        }
        /// <summary>
        /// Get a copy of this TaxonName.
        /// </summary>
        /// <returns>A copy of this TaxonName.</returns>
        public TaxonName Clone(IUserContext userContext)
        {
            TaxonName clone = (TaxonName)(MemberwiseClone());

            clone.SetChangedInRevisionEvent(GetChangedInRevisionEvent(userContext));
            clone.Taxon = Taxon;
            return(clone);
        }
Ejemplo n.º 3
0
        public ITaxonName AddTaxonName(TaxonNameDetailsViewModel model, int taxonId, ITaxonRevision taxonRevision)
        {
            ITaxon taxon = CoreData.TaxonManager.GetTaxon(_user, taxonId);

            var taxonName = new ArtDatabanken.Data.TaxonName();

            taxonName.DataContext = new DataContext(_user);
            taxonName.Name        = model.Name;
            taxonName.Author      = model.Author;
            taxonName.Category    = CoreData.TaxonManager.GetTaxonNameCategory(_user, model.SelectedCategoryId);
            taxonName.Status      = CoreData.TaxonManager.GetTaxonNameStatus(CoreData.UserManager.GetCurrentUser(), model.SelectedTaxonNameStatusId);
            taxonName.NameUsage   = CoreData.TaxonManager.GetTaxonNameUsage(CoreData.UserManager.GetCurrentUser(), model.SelectedTaxonNameUsageId);
            // Todo Not set in GUI only Changed in list
            taxonName.IsRecommended = model.IsRecommended;
            taxonName.Description   = model.Comment;
            // taxonName.Taxon = CoreData.TaxonManager.GetTaxon(_user, model.TaxonId);
            taxonName.IsOkForSpeciesObservation = !model.IsNotOkForObsSystem;
            taxonName.IsOriginalName            = model.IsOriginal;
            taxonName.Taxon = taxon;

            CoreData.TaxonManager.CreateTaxonName(_user, taxonRevision, taxonName);
            //CoreData.TaxonManager.AddTaxonName(_user, taxon, revision, taxonName);
            return(taxonName);
        }