public static Pedigree FromPedigreeDTOToPedigree(PedigreeDTO pedigreeDTO)
        {
            if (pedigreeDTO == null)
            {
                return(null);
            }

            var pedigree = new Pedigree
            {
                Father               = pedigreeDTO.Father,
                Father_Father        = pedigreeDTO.Father_Father,
                Father_Mother        = pedigreeDTO.Father_Mother,
                Father_Father_Father = pedigreeDTO.Father_Father_Father,
                Father_Father_Mother = pedigreeDTO.Father_Father_Mother,
                Father_Mother_Father = pedigreeDTO.Father_Mother_Father,
                Father_Mother_Mother = pedigreeDTO.Father_Mother_Mother,
                Mother               = pedigreeDTO.Mother,
                Mother_Father        = pedigreeDTO.Mother_Father,
                Mother_Mother        = pedigreeDTO.Mother_Mother,
                Mother_Father_Father = pedigreeDTO.Mother_Father_Father,
                Mother_Father_Mother = pedigreeDTO.Mother_Father_Mother,
                Mother_Mother_Father = pedigreeDTO.Mother_Mother_Father,
                Mother_Mother_Mother = pedigreeDTO.Mother_Mother_Mother
            };

            return(pedigree);
        }
示例#2
0
        //Use Case Driven - Adding new pedigree
        public void addNewPedigree(Pedigree pedigree)
        {
            ServiceFactory   serviceFactory = new ServiceFactory();
            IPedigreeService pedigreeSvc    = (IPedigreeService)GetService(typeof(IPedigreeService).Name);

            pedigreeSvc.storePedigreeData(pedigree);
        }            //end addNewPedigree
示例#3
0
        public PedigreeDTO AddChild(int id, PersonInfoDTO personInfo)
        {
            User loggedUser = this.Authenticate();

            if (!ModelState.IsValid)
            {
                string errorMessage = GetModelStateErrors(ModelState);
                throw new FamilyValidationException(errorMessage);
            }

            Person parent = this.data.People.GetFull(id, loggedUser.Id);

            if (parent == null)
            {
                throw new FamilyException("No person found. Maybe the person is already deleted.");
            }

            Person dbPerson = this.map.ToSinglePerson(personInfo);

            dbPerson.PedigreeId = parent.PedigreeId;
            parent.ChildrenFirst.Add(dbPerson);
            if (parent.Spouse != null)
            {
                parent.Spouse.ChildrenSecond.Add(dbPerson);
            }

            this.data.Save();
            Pedigree    pedigree       = this.data.Pedigrees.GetById(loggedUser.Id, dbPerson.PedigreeId);
            PedigreeDTO outputPedigree = this.map.ToSinglePedigreeDTO(pedigree);

            return(outputPedigree);
        }
示例#4
0
        public IHttpActionResult AddPedigree(PedigreeAddDTO pedigree)
        {
            User loggedUser = this.Authenticate();

            if (!ModelState.IsValid)
            {
                string errorMessage = GetModelStateErrors(ModelState);
                throw new FamilyValidationException(errorMessage);
            }

            Pedigree dbPedigree = this.map.ToSinglePedigree(pedigree, loggedUser.Id);

            dbPedigree.People.Add(new Person()
            {
                DisplayName = "Ме",
                IsMale      = true,
                IsAlive     = true
            });
            this.data.Pedigrees.Insert(dbPedigree);
            this.data.Save();

            IEnumerable <PedigreeSimpleDTO> pedigrees = this.data.Pedigrees.Get(loggedUser.Id).AsQueryable().Select(this.map.ToPedigreeSimpleDTO);

            return(CreatedAtRoute("DefaultApi", new { id = dbPedigree.Id }, pedigrees));
        }
 private void ParentStats_Paint(object sender, PaintEventArgs e)
 {
     if (ControlOffspring.Creature != null && _lines[0].Any())
     {
         Pedigree.DrawLines(e.Graphics, _lines);
     }
 }
示例#6
0
        /// <summary>
        /// Mutates the genome by creating a new connection.
        /// </summary>
        public void Mutate_Link()
        {
            //Get first node to connect. It is random.
            NodeGene nodeGene_a = NodeGenes.RandomValue(Random).Take(1).ElementAt(0);


            IEnumerable <NodeGene> temp_subset = NodeGenes.Values.Where(a => a.NodeGenePattern.X > nodeGene_a.NodeGenePattern.X);

            if (temp_subset.Count() == 0)
            {
                return; //TODO handle this too
            }


            NodeGene nodeGene_b = temp_subset.ElementAt(Random.Next(temp_subset.Count()));  //Get a random gene with a higher X value.


            ConnectionGene connectionGene = Pedigree.Create_ConnectionGene(nodeGene_a, nodeGene_b, Pedigree.Mutation_WeightRandom * (Random.NextDouble() * 2 - 1),
                                                                           true);

            if (ConnectionGenes.ContainsKey(connectionGene.ConnectionGenePattern.InnovationNumber)) //Can only happen if it already existed in the tracker.
            {
                return;                                                                             //TODO think of how to handle this, maybe have a retry somewhere?
            }


            ConnectionGenes.Add(connectionGene.ConnectionGenePattern.InnovationNumber, connectionGene);
        }
示例#7
0
 public void storePedigreeData(Pedigree pedigree)
 {
     if (pedigree == null)
     {
         throw new ArgumentNullException();
     }
 }
示例#8
0
        public PedigreeDTO Update(int id, PersonInfoDTO personInfo)
        {
            User loggedUser = this.Authenticate();

            if (!ModelState.IsValid)
            {
                string errorMessage = GetModelStateErrors(ModelState);
                throw new FamilyValidationException(errorMessage);
            }

            Person dbPerson = this.data.People.GetById(id);

            if (dbPerson == null)
            {
                throw new FamilyException("No person found. Maybe the person is already deleted.");
            }

            this.map.UpdatePerson(personInfo, dbPerson);

            this.data.Save();
            Pedigree    pedigree       = this.data.Pedigrees.GetById(loggedUser.Id, dbPerson.PedigreeId);
            PedigreeDTO outputPedigree = this.map.ToSinglePedigreeDTO(pedigree);

            return(outputPedigree);
        }
        private static PedigreeDTO FromPedigreeToPedigreeDTO(Pedigree pedigree)
        {
            if (pedigree == null)
            {
                return(null);
            }

            return(new PedigreeDTO
            {
                Father = pedigree.Father,
                Father_Father = pedigree.Father_Father,
                Father_Mother = pedigree.Father_Mother,
                Father_Father_Father = pedigree.Father_Father_Father,
                Father_Father_Mother = pedigree.Father_Father_Mother,
                Father_Mother_Father = pedigree.Father_Mother_Father,
                Father_Mother_Mother = pedigree.Father_Mother_Mother,
                Mother = pedigree.Mother,
                Mother_Father = pedigree.Mother_Father,
                Mother_Mother = pedigree.Mother_Mother,
                Mother_Father_Father = pedigree.Mother_Father_Father,
                Mother_Father_Mother = pedigree.Mother_Father_Mother,
                Mother_Mother_Father = pedigree.Mother_Mother_Father,
                Mother_Mother_Mother = pedigree.Mother_Mother_Mother
            });
        }
示例#10
0
 public void Write(TProtocol oprot)
 {
     oprot.IncrementRecursionDepth();
     try
     {
         TStruct struc = new TStruct("Data");
         oprot.WriteStructBegin(struc);
         TField field = new TField();
         field.Name = "pedigree";
         field.Type = TType.Struct;
         field.ID   = 1;
         oprot.WriteFieldBegin(field);
         Pedigree.Write(oprot);
         oprot.WriteFieldEnd();
         field.Name = "dataunit";
         field.Type = TType.Struct;
         field.ID   = 2;
         oprot.WriteFieldBegin(field);
         Dataunit.Write(oprot);
         oprot.WriteFieldEnd();
         oprot.WriteFieldStop();
         oprot.WriteStructEnd();
     }
     finally
     {
         oprot.DecrementRecursionDepth();
     }
 }
示例#11
0
 protected Message(string msgType, string name, string description, Pedigree pedigree, MessageFieldCollection fields)
 {
     MsgType     = msgType;
     Name        = name;
     Description = description;
     Pedigree    = pedigree;
     Fields      = fields;
 }
示例#12
0
 public PedigreeDTO ToSinglePedigreeDTO(Pedigree pedigree)
 {
     return(new PedigreeDTO
     {
         Id = pedigree.Id,
         Title = pedigree.Title,
         OwnerId = pedigree.OwnerId,
         People = pedigree.People.AsQueryable().Select(this.ToPersonDTO)
     });
 }
示例#13
0
        public PedigreeDTO AddParent(int id, PersonInfoDTO personInfo)
        {
            User loggedUser = this.Authenticate();

            if (!ModelState.IsValid)
            {
                string errorMessage = GetModelStateErrors(ModelState);
                throw new FamilyValidationException(errorMessage);
            }

            Person child = this.data.People.GetFull(id, loggedUser.Id);

            if (child == null)
            {
                throw new FamilyException("No person found. Maybe the person is already deleted.");
            }

            if (child.FirstParent != null && child.SecondParent != null)
            {
                throw new FamilyException("You can't add a third parent to a person. Consider deleting or editing an existing one.");
            }

            Person parentToAdd = this.map.ToSinglePerson(personInfo);

            parentToAdd.PedigreeId = child.PedigreeId;
            parentToAdd.Spouse     = child.FirstParent ?? child.SecondParent;
            if (parentToAdd.Spouse == null)
            {
                child.FirstParent = parentToAdd;
            }
            else
            {
                parentToAdd.Spouse.Spouse = parentToAdd;
                IEnumerable <Person> childrenFirst  = parentToAdd.Spouse.ChildrenFirst.ToArray();
                IEnumerable <Person> childrenSecond = parentToAdd.Spouse.ChildrenSecond.ToArray();
                IEnumerable <Person> children       = childrenFirst.Union(childrenSecond);
                foreach (Person singleChild in children)
                {
                    if (singleChild.FirstParent == null)
                    {
                        singleChild.FirstParent = parentToAdd;
                    }
                    else if (singleChild.SecondParent == null)
                    {
                        singleChild.SecondParent = parentToAdd;
                    }
                }
            }

            this.data.Save();
            Pedigree    pedigree       = this.data.Pedigrees.GetById(loggedUser.Id, parentToAdd.PedigreeId);
            PedigreeDTO outputPedigree = this.map.ToSinglePedigreeDTO(pedigree);

            return(outputPedigree);
        }
示例#14
0
    public override string ToString()
    {
        StringBuilder __sb = new StringBuilder("Data(");

        __sb.Append(", Pedigree: ");
        __sb.Append(Pedigree == null ? "<null>" : Pedigree.ToString());
        __sb.Append(", Dataunit: ");
        __sb.Append(Dataunit == null ? "<null>" : Dataunit.ToString());
        __sb.Append(")");
        return(__sb.ToString());
    }
示例#15
0
        public JsonResult pedigree(int id)
        {
            Pedigree pedigree = new Pedigree();
            pgsql    conn     = new pgsql();

            if (conn.open())
            {
                pedigree = conn.sqlPedigree(id);
            }

            return(Json(pedigree));
        }
示例#16
0
 public VersionField(int tag, string name, string dataType, string description, Pedigree pedigree, params FieldValue[] values)
 {
     Tag = tag;
     Name = name;
     Description = description;
     DataType = dataType;
     Pedigree = pedigree;
     foreach (var value in values)
     {
         Values.Add(value.Value, value);
     }
 }
示例#17
0
        /// <summary>
        /// Constructs a genome with the given pedigree and random.
        /// </summary>
        /// <param name="pedigree">The pedigree for the genome.</param>
        /// <param name="random">The internal random for the genome.</param>
        /// <exception cref="ArgumentNullException">When either parameter is null.</exception>
        protected internal Genome(Pedigree pedigree, Random random)
        {
            Helpers.ThrowOnNull(pedigree, "genePatternTracker");
            Helpers.ThrowOnNull(random, "random");


            Pedigree = pedigree;
            Random   = random;

            ConnectionGenes = new SortedDictionary <int, ConnectionGene>();
            NodeGenes       = new SortedDictionary <int, NodeGene>();
        }
示例#18
0
        public PedigreeDTO Delete(int id)
        {
            User loggedUser = this.Authenticate();

            Person person = this.data.People.GetFull(id, loggedUser.Id);

            if (person == null)
            {
                throw new FamilyException("No person found. Maybe the person is already deleted.");
            }
            if (person.Pedigree.People.Count() == 1)
            {
                throw new FamilyException("The person can't be deleted because he is the only person in the pedigree. Consider deleteing the whole pedigree.");
            }

            IEnumerable <Person> personChildren = person.ChildrenFirst.Union(person.ChildrenSecond);

            if (person.Spouse == null && personChildren.Count() > 1)
            {
                throw new FamilyException(String.Format(
                                              "{0} has no spouse but has more than one children. Such a person can't be deleted because the pedigree will be divided in parts.", person.DisplayName));
            }
            // If the person has any parents and has spouse or children he can't be deleted
            if ((person.FirstParentId != null || person.SecondParentId != null) && (person.SpouseId != null || personChildren.Count() > 0))
            {
                throw new FamilyException("The person can't be deleted because the pedigree will be divided in two parts. To delete the person, you must first delete the people in one of the parts.");
            }

            if (person.Spouse != null)
            {
                person.Spouse.Spouse = null;
            }

            foreach (Person child in personChildren)
            {
                if (child.FirstParentId == person.Id)
                {
                    child.FirstParentId = null;
                }
                else if (child.SecondParentId == person.Id)
                {
                    child.SecondParentId = null;
                }
            }

            this.data.People.Delete(person);
            this.data.Save();
            Pedigree    pedigree       = this.data.Pedigrees.GetById(loggedUser.Id, person.PedigreeId);
            PedigreeDTO outputPedigree = this.map.ToSinglePedigreeDTO(pedigree);

            return(outputPedigree);
        }
示例#19
0
        public IHttpActionResult GetPedigree(int id)
        {
            User     loggedUser = this.Authenticate();
            Pedigree pedigree   = this.data.Pedigrees.GetById(loggedUser.Id, id);

            if (pedigree == null)
            {
                throw new FamilyException("The pedigree doesn't exists. Maybe it was deleted.");
            }

            PedigreeDTO outputPedigree = this.map.ToSinglePedigreeDTO(pedigree);

            return(Ok(outputPedigree));
        }
示例#20
0
        /// <summary>
        /// Constructs a NEAT client with the given pedigree, number of organisms, evaluation function, and every constant.
        /// </summary>
        /// <param name="pedigree">The pedigree used to track all genes in this NEAT client.</param>
        /// <param name="numOrganisms">The total number of organisms this NEAT client will train.</param>
        /// <param name="evaluateFunction">The function to evaluate organisms' neural networks and give them a fitness score.</param>
        /// <param name="compatibility_distance">The initial compatibility distance.</param>
        /// <param name="CD_function">The function to adjust the compatibility distance by. Good options are the <see cref="NEAT.NEATClient.NERO_CD_Function(int)"/> and the
        /// <see cref="NEAT.NEATClient.Constant_CD_Function(int)"/></param>
        /// <param name="surviving_percentage">The percentage of organisms that will survive on <see cref="NEAT.NEATClient.Kill"/>.</param>
        public NEATClient(Pedigree pedigree, int numOrganisms, EvaluateFunction evaluateFunction, double compatibility_distance, CompatibilityDistanceFunction CD_function,
                          double surviving_percentage)
        {
            #region Internal Setters

            Pedigree = pedigree;

            NumOrganisms = numOrganisms;


            Organisms = new List <Organism>(numOrganisms);

            Species = new HashSet <Species>();


            this.evaluateFunction = evaluateFunction;


            CompatibilityDistance = compatibility_distance;

            this.CD_function = CD_function;


            SurvivingPercentage = surviving_percentage;

            #endregion Internal Setters


            #region Initial Conditions

            //Create organisms:
            for (int i = 0; i < NumOrganisms; ++i)
            {
                Organisms.Add(new Organism(Pedigree.CreateGenome()));
            }


            //Create Species:
            Species first_species = new Species();

            Species.Add(first_species);

            first_species.AddOrganism(Organisms[0]);    //Prepares first species to house every organism.


            Speciate();

            #endregion Initial Conditions
        }
示例#21
0
        // GET: Pedigree
        public ActionResult Index(int id)
        {
            Pedigree pedigree = new Pedigree();
            pgsql    conn     = new pgsql();

            if (conn.open())
            {
                pedigree = conn.sqlPedigree(id);
            }
            ViewBag.pedigree = pedigree;

            //return Json(pedigree);

            return(View());
        }
示例#22
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="wp">WP7</param>
 /// <param name="family_line_info">系統状態のリスト</param>
 /// <param name="target_country">配合地域</param>
 /// <param name="sire_pedigree">種牡馬の血統</param>
 /// <param name="dam_pedigree">繁殖牝馬の血統</param>
 public Breeding( WP7 wp, FamilyLineInfo[] family_line_info, Horse.Area target_country, Pedigree sire_pedigree, Pedigree dam_pedigree )
 {
     if( sire_pedigree.Type != Enums.血統タイプ.父系 ) {
         throw new ArgumentException("種牡馬の血統に繁殖牝馬の血統が与えられました");
     }
     if( dam_pedigree.Type != Enums.血統タイプ.母系 ) {
         throw new ArgumentException("繁殖牝馬の血統に種牡馬の血統が与えられました");
     }
     this.wp = wp;
     this.family_line_info = family_line_info;
     this.TargetCountry = target_country;
     this.SirePedigree = sire_pedigree;
     this.DamPedigree = dam_pedigree;
     this.DoCombination();
 }
示例#23
0
        /**
         * Pedigree Service Implementation
         * Creates a new pedigree object at the request of PedigreeManager.
         *
         *
         */

        public new void storePedigreeData(Pedigree pedigree)
        {
            Pedigree pED1 = new Pedigree();

            try
            {
                Stream os = new System.IO.FileStream("pedigree1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write);;
                os.Equals(pED1);
                os.Close();
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex);
            }
        } // end Pedigree Service
        private static void CleanupEmptyXmlArrays(Pedigree pedigree)
        {
            if (pedigree.Commits?.Count == 0)
            {
                pedigree.Commits = null;
            }
            if (pedigree.Patches?.Count == 0)
            {
                pedigree.Patches = null;
            }

            if (pedigree.Ancestors?.Count == 0)
            {
                pedigree.Ancestors = null;
            }
            if (pedigree.Ancestors != null)
            {
                foreach (var component in pedigree.Ancestors)
                {
                    CleanupEmptyXmlArrays(component);
                }
            }

            if (pedigree.Descendants?.Count == 0)
            {
                pedigree.Descendants = null;
            }
            if (pedigree.Descendants != null)
            {
                foreach (var component in pedigree.Descendants)
                {
                    CleanupEmptyXmlArrays(component);
                }
            }

            if (pedigree.Variants?.Count == 0)
            {
                pedigree.Variants = null;
            }
            if (pedigree.Variants != null)
            {
                foreach (var component in pedigree.Variants)
                {
                    CleanupEmptyXmlArrays(component);
                }
            }
        }
        /// <summary>
        /// Compares the current and passed family link to see if they are the same.
        /// </summary>
        /// <param name="link">The family link to compare the current instance against.</param>
        /// <returns>A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter.</returns>
        public int CompareTo(GedcomFamilyLink link)
        {
            /* Family and Individual appear to store XRefId values,
             * which don't seem to contribute to the equality of a family link.
             */

            if (link == null)
            {
                return(1);
            }

            var compare = FatherPedigree.CompareTo(link.FatherPedigree);

            if (compare != 0)
            {
                return(compare);
            }

            compare = MotherPedigree.CompareTo(link.MotherPedigree);
            if (compare != 0)
            {
                return(compare);
            }

            compare = Pedigree.CompareTo(link.Pedigree);
            if (compare != 0)
            {
                return(compare);
            }

            compare = PreferedSpouse.CompareTo(link.PreferedSpouse);
            if (compare != 0)
            {
                return(compare);
            }

            compare = Status.CompareTo(link.Status);
            if (compare != 0)
            {
                return(compare);
            }

            return(compare);
        }
        internal void SetCreatures(Creature offspring = null, Creature mother = null, Creature father = null)
        {
            if (offspring == null || (mother == null && father == null))
            {
                Visible = false;
                return;
            }
            Visible = true;

            var enabledColorRegions = offspring?.Species?.EnabledColorRegions;

            if (enabledColorRegions != null)
            {
                ControlOffspring.enabledColorRegions = enabledColorRegions;
                ControlMother.enabledColorRegions    = enabledColorRegions;
                ControlFather.enabledColorRegions    = enabledColorRegions;
            }

            SetSpecies(offspring.Species);

            SetCreature(ControlOffspring, offspring);
            SetCreature(ControlMother, mother);
            SetCreature(ControlFather, father);

            void SetCreature(PedigreeCreature pc, Creature c)
            {
                if (c == null)
                {
                    pc.Visible = false;
                }
                else
                {
                    pc.Creature = c;
                    pc.Visible  = true;
                }
            }

            _lines[0].Clear();
            Pedigree.CreateGeneInheritanceLines(offspring, mother, father, _lines, 6, 60);

            Invalidate();
        }
示例#27
0
        /// <summary>
        /// Mutates a random connection splitting it with a node.
        /// </summary>
        public void Mutate_Node()
        {
            if (NodeGenes.Count >= Pedigree.MaxNodes)
            {
                return; //Do nothing if we have max nodes.
            }
            else if (ConnectionGenes.Count == 0)
            {
                return; //Literally cannot make a node.
            }


            ConnectionGene connectionGene = ConnectionGenes.RandomValue(Random).Take(1).ElementAt(0);

            if (connectionGene == null)
            {
                return;
            }


            NodeGene from = NodeGenes[connectionGene.ConnectionGenePattern.From.InnovationNumber];
            NodeGene to   = NodeGenes[connectionGene.ConnectionGenePattern.To.InnovationNumber];

            NodeGene created = Pedigree.Create_NodeGene(connectionGene);

            if (NodeGenes.ContainsKey(created.NodeGenePattern.InnovationNumber))
            {
                return; //TODO maybe retry here as well?
            }

            NodeGenes.Add(created.NodeGenePattern.InnovationNumber, created);


            ConnectionGene created_connectionGene_1 = Pedigree.Create_ConnectionGene(from, created, 1, true); //Default weight of 1.
            ConnectionGene created_connectionGene_2 = Pedigree.Create_ConnectionGene(created, to, connectionGene.Weight, connectionGene.Enabled);

            ConnectionGenes.Remove(connectionGene.ConnectionGenePattern.InnovationNumber);

            ConnectionGenes.Add(created_connectionGene_1.ConnectionGenePattern.InnovationNumber, created_connectionGene_1);
            ConnectionGenes.Add(created_connectionGene_2.ConnectionGenePattern.InnovationNumber, created_connectionGene_2);
        }
示例#28
0
        public IHttpActionResult DeletePedigree(int id)
        {
            User     loggedUser = this.Authenticate();
            Pedigree pedigree   = this.data.Pedigrees.GetById(loggedUser.Id, id);

            if (pedigree == null)
            {
                throw new FamilyException("The pedigree you are trying to delete doesn't exists. Maybe it was deleted.");
            }

            foreach (Person person in pedigree.People)
            {
                person.SpouseId = null;
            }

            this.data.Save();
            this.data.Pedigrees.Delete(pedigree);
            this.data.Save();
            IEnumerable <PedigreeSimpleDTO> pedigrees = this.data.Pedigrees.Get(loggedUser.Id).AsQueryable().Select(this.map.ToPedigreeSimpleDTO);

            return(Ok(pedigrees));
        }
示例#29
0
        public PedigreeDTO AddSpouse(int id, PersonInfoDTO personInfo)
        {
            User loggedUser = this.Authenticate();

            if (!ModelState.IsValid)
            {
                string errorMessage = GetModelStateErrors(ModelState);
                throw new FamilyValidationException(errorMessage);
            }

            Person person = this.data.People.GetFull(id, loggedUser.Id);

            if (person == null)
            {
                throw new FamilyException("No person found. Maybe the person is already deleted.");
            }

            if (person.Spouse != null)
            {
                throw new FamilyException("The person already has a spouse. Consider deleting or editing the existing one.");
            }

            Person dbSpouse = this.map.ToSinglePerson(personInfo);

            dbSpouse.PedigreeId = person.PedigreeId;
            // Adding spouse relashionship
            dbSpouse.Spouse = person;
            person.Spouse   = dbSpouse;
            // Adding child -> parent relashionship
            dbSpouse.ChildrenFirst  = person.ChildrenSecond;
            dbSpouse.ChildrenSecond = person.ChildrenFirst;

            this.data.Save();
            Pedigree    pedigree       = this.data.Pedigrees.GetById(loggedUser.Id, dbSpouse.PedigreeId);
            PedigreeDTO outputPedigree = this.map.ToSinglePedigreeDTO(pedigree);

            return(outputPedigree);
        }
示例#30
0
        public IEnumerable <PedigreeSimpleDTO> UpdatePedigree(int id, PedigreeAddDTO pedigree)
        {
            User loggedUser = this.Authenticate();

            Pedigree dbPedigree = this.data.Pedigrees.GetById(loggedUser.Id, id, false);

            if (dbPedigree == null)
            {
                throw new FamilyException("The pedigree you are trying to update doesn't exists. Maybe it is deleted.");
            }
            if (!ModelState.IsValid)
            {
                string errorMessage = GetModelStateErrors(ModelState);
                throw new FamilyValidationException(errorMessage);
            }

            this.map.UpdatePedigree(pedigree, dbPedigree);
            this.data.Pedigrees.Update(dbPedigree);
            this.data.Save();

            IEnumerable <PedigreeSimpleDTO> pedigrees = this.data.Pedigrees.Get(loggedUser.Id).AsQueryable().Select(this.map.ToPedigreeSimpleDTO);

            return(pedigrees);
        }
示例#31
0
 public void UpdatePedigree(PedigreeAddDTO newPedigree, Pedigree pedigreeToUpdate)
 {
     pedigreeToUpdate.Title = newPedigree.Title;
 }