Beispiel #1
0
        public Division AssignParentDivision(Division subDivision, Division parentDivision)
        {
            if (parentDivision.DivisionID == subDivision.DivisionID ||
                subDivision.ParentDivisionID != null ||
                parentDivision.SubdivisionsList.Any(x => x.DivisionID == subDivision.DivisionID))
            {
                return(null);
            }

            subDivision.ParentDivisionID = parentDivision.DivisionID;
            subDivision.ParentDivision   = parentDivision;
            parentDivision.SubdivisionsList.Add(subDivision);

            _parkSharkDbContext.Update(subDivision);
            _parkSharkDbContext.SaveChanges();


            return(subDivision);
        }