コード例 #1
0
        // Create a new version of this object or use it from the lookup.
        public static CaseDtoGen Create(Coalesce.Domain.Case obj, ClaimsPrincipal user = null, string includes  = null,
                                        Dictionary <object, object> objects            = null, IncludeTree tree = null)
        {
            // Return null of the object is null;
            if (obj == null)
            {
                return(null);
            }

            if (objects == null)
            {
                objects = new Dictionary <object, object>();
            }

            includes = includes ?? "";

            // Applicable includes for Case


            // Applicable excludes for Case
            bool excludePersonListGen = includes == "PersonListGen";

            // Applicable roles for Case
            if (user != null)
            {
            }



            // See if the object is already created, but only if we aren't restricting by an includes tree.
            // If we do have an IncludeTree, we know the exact structure of our return data, so we don't need to worry about circular refs.
            if (tree == null && objects.ContainsKey(obj))
            {
                return((CaseDtoGen)objects[obj]);
            }

            var newObject = new CaseDtoGen();

            if (tree == null)
            {
                objects.Add(obj, newObject);
            }
            // Fill the properties of the object.
            newObject.CaseKey           = obj.CaseKey;
            newObject.Title             = obj.Title;
            newObject.Description       = obj.Description;
            newObject.OpenedAt          = obj.OpenedAt;
            newObject.AssignedToId      = obj.AssignedToId;
            newObject.ReportedById      = obj.ReportedById;
            newObject.Attachment        = obj.Attachment;
            newObject.Severity          = obj.Severity;
            newObject.Status            = obj.Status;
            newObject.DevTeamAssignedId = obj.DevTeamAssignedId;
            if (!(excludePersonListGen))
            {
                if (tree == null || tree[nameof(newObject.AssignedTo)] != null)
                {
                    newObject.AssignedTo = PersonDtoGen.Create(obj.AssignedTo, user, includes, objects, tree?[nameof(newObject.AssignedTo)]);
                }
            }
            if (!(excludePersonListGen))
            {
                if (tree == null || tree[nameof(newObject.ReportedBy)] != null)
                {
                    newObject.ReportedBy = PersonDtoGen.Create(obj.ReportedBy, user, includes, objects, tree?[nameof(newObject.ReportedBy)]);
                }
            }
            var propValCaseProducts = obj.CaseProducts;

            if (propValCaseProducts != null && (tree == null || tree[nameof(newObject.CaseProducts)] != null))
            {
                newObject.CaseProducts = propValCaseProducts.OrderBy("CaseProductId ASC").Select(f => CaseProductDtoGen.Create(f, user, includes, objects, tree?[nameof(newObject.CaseProducts)])).ToList();
            }
            else if (propValCaseProducts == null && tree?[nameof(newObject.CaseProducts)] != null)
            {
                newObject.CaseProducts = new CaseProductDtoGen[0];
            }


            newObject.DevTeamAssigned = DevTeamDtoGen.Create(obj.DevTeamAssigned, user, includes, objects, tree?[nameof(newObject.DevTeamAssigned)]);

            return(newObject);
        }
コード例 #2
0
        // Create a new version of this object or use it from the lookup.
        public static CompanyDtoGen Create(Coalesce.Domain.Company obj, ClaimsPrincipal user = null, string includes = null,
                                           Dictionary <object, object> objects = null, IncludeTree tree = null)
        {
            // Return null of the object is null;
            if (obj == null)
            {
                return(null);
            }

            if (objects == null)
            {
                objects = new Dictionary <object, object>();
            }

            includes = includes ?? "";

            // Applicable includes for Company


            // Applicable excludes for Company


            // Applicable roles for Company
            if (user != null)
            {
            }



            // See if the object is already created, but only if we aren't restricting by an includes tree.
            // If we do have an IncludeTree, we know the exact structure of our return data, so we don't need to worry about circular refs.
            if (tree == null && objects.ContainsKey(obj))
            {
                return((CompanyDtoGen)objects[obj]);
            }

            var newObject = new CompanyDtoGen();

            if (tree == null)
            {
                objects.Add(obj, newObject);
            }
            // Fill the properties of the object.
            newObject.CompanyId = obj.CompanyId;
            newObject.Name      = obj.Name;
            newObject.Address1  = obj.Address1;
            newObject.Address2  = obj.Address2;
            newObject.City      = obj.City;
            newObject.State     = obj.State;
            newObject.ZipCode   = obj.ZipCode;
            newObject.AltName   = obj.AltName;
            var propValEmployees = obj.Employees;

            if (propValEmployees != null && (tree == null || tree[nameof(newObject.Employees)] != null))
            {
                newObject.Employees = propValEmployees.OrderBy("PersonId ASC").Select(f => PersonDtoGen.Create(f, user, includes, objects, tree?[nameof(newObject.Employees)])).ToList();
            }
            else if (propValEmployees == null && tree?[nameof(newObject.Employees)] != null)
            {
                newObject.Employees = new PersonDtoGen[0];
            }

            return(newObject);
        }