예제 #1
0
        /// <summary>
        /// Validate the passed well against the business rules
        /// </summary>
        /// <exception cref="DuplicatedWellNameException">Thrown when this Well has the same Unique Name as another Well already added to the list</exception>
        /// <exception cref="DuplicateWellLocationException">Thrown when this Well has the same location of another Well already added to the list</exception>
        /// <param name="toAdd">The group to be validated</param>
        private void ValidateWell(Well toAdd)
        {
            foreach (Well w in app.GetWells())
            {
                //Validate if uniqueName is unique
                if (w.GetUniqueName().Equals(toAdd.GetUniqueName()))
                {
                    throw new DuplicatedWellNameException($"{toAdd.GetUniqueName()} already exists");
                }

                //Validate if location is unique
                if (w.GetTopHole().Equals(toAdd.GetTopHole()))
                {
                    throw new DuplicateWellLocationException($"{toAdd.GetUniqueName()} in same location as {w.GetUniqueName()}");
                }
            }
        }