Esempio n. 1
0
        public static void Execute(CorrigoService service, int woid)
        {
            var specifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { nameof(WorkOrder.Estimate) + ".*" };
            var      workOrder  = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            }) as WorkOrder;

            workOrder.Estimate = null;
            var command = new UpdateCommand
            {
                Entity      = workOrder,
                PropertySet = new PropertySet {
                    Properties = properties
                }
            };

            var response = service.Execute(command) as OperationCommandResponse;

            Debug.Print(response?.ErrorInfo?.Description
                        ?? $"Successfully deleted WoEstimate for WorkOrder with id '{woid}'");
        }
Esempio n. 2
0
        public static void Execute(CorrigoService service, int woid, QuoteStatus newStatus)
        {
            var specifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { nameof(WorkOrder.Estimate) + ".*" };
            var      workOrder  = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            }) as WorkOrder;

            var oldStatus = workOrder.Estimate.StatusId;

            workOrder.Estimate.StatusId = newStatus;

            var command = new UpdateCommand
            {
                Entity      = workOrder,
                PropertySet = new PropertySet {
                    Properties = new[] { "Estimate.StatusId" }
                }
            };

            var response = service.Execute(command) as OperationCommandResponse;

            Debug.Print(response?.ErrorInfo?.Description
                        ?? $"Successfully updated an Estimate from status {oldStatus} to {newStatus}");
        }
Esempio n. 3
0
        public static WorkOrderCost Retrieve(CorrigoService service, int workOrderId)
        {
            Debug.Print($"Retrieving WorkOrderCost object for WorkOrder with id '{workOrderId}': ");

            var specifier = new EntitySpecifier {
                EntityType = EntityType.WorkOrderCost, Id = workOrderId
            };

            string[] properties =
            {
                "CustomerNte",
                "ChargeCode.Id",
                "Items.CostCategoryId",
                "Items.Quantity",
                "Items.Amount"
            };

            var response = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            })
                           as WorkOrderCost;

            Debug.Print(response == null ? "Failure!" : "Success!");

            return(response);
        }
Esempio n. 4
0
        public static Location Retrieve(CorrigoService service, int locationId)
        {
            var locationSpecifier = new EntitySpecifier
            {
                EntityType = EntityType.Location,
                Id         = locationId
            };

            string[] properties =
            {
                nameof(Location.Id),
                nameof(Location.Address) + ".*",
                nameof(Location.Info) + ".*",
                nameof(Location.IsTemplate),
                nameof(Location.ModelId),
                nameof(Location.Name),
                nameof(Location.Orphan),
                nameof(Location.ParentId),
                nameof(Location.RootId)
            };

            var response = service.Retrieve(locationSpecifier, new PropertySet {
                Properties = properties
            })
                           as Location;

            return(response);
        }
Esempio n. 5
0
        public static Space Execute(CorrigoService service, int id)
        {
            var entitySpecifier = new EntitySpecifier
            {
                EntityType = EntityType.Space,
                Id         = id
            };

            var properies = new PropertySet
            {
                Properties = new[]
                {
                    "CustomerId",
                    "Id",
                    "StatusId",
                    "StartDate",
                    "EndDate",
                    "MoveOutDate",
                    "Instructions",
                    "Asset.*",
                    "Community.*",
                    "Addresses.*",
                }
            };

            var result = service.Retrieve(entitySpecifier, properies);

            return(result as Space);
        }
Esempio n. 6
0
        public static Customer Execute(CorrigoService service, int id)
        {
            var entity = new EntitySpecifier
            {
                EntityType = EntityType.Customer,
                Id         = id
            };

            var properties = new[]
            {
                "DisplayAs",
                "Name",
                "Dba",
                "Instructions",
                "TenantCode",
                "TaxExempt",
                "Spaces.*",
                "CustomFields.*",
                "Notes.*",
                "Addresses.*",
                "GroupsBridge.*",
                "Contacts.*",
                "Contract.*",
                "WorkZone.*"
            };

            var response = service.Retrieve(entity, new PropertySet {
                Properties = properties
            });

            return(response as Customer);
        }
Esempio n. 7
0
        public static WoAssignment Retrieve(CorrigoService service, int?id)
        {
            var entitySpecifier = new EntitySpecifier
            {
                EntityType = EntityType.WoAssignment,
                Id         = id
            };

            string[] properties = { "WorkOrderId", "EmployeeId", "IsPrimary" };
            var      response   = service.Retrieve(entitySpecifier, new PropertySet {
                Properties = properties
            })
                                  as WoAssignment;

            return(response);
        }
Esempio n. 8
0
        public static int Retreive(CorrigoService service, int woid)
        {
            var entitySpecifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { "LastAction.*", "LastAction.Reason.*" };
            var      workOrder  = service.Retrieve(entitySpecifier, new PropertySet {
                Properties = properties
            })
                                  as WorkOrder;

            WoActionReasonLookup reason = workOrder?.LastAction?.Reason;

            return(reason?.Id ?? 0);
        }
Esempio n. 9
0
        public static RepairCode Retrieve(CorrigoService service, int id)
        {
            Debug.Print("Retrieving repair code entity:");

            var specifier = new EntitySpecifier {
                EntityType = EntityType.RepairCode, Id = id
            };

            string[] properties = { "Id", "DisplayAs", "ParentId", "IsRemoved", "Codes.*" };
            var      response   = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            })
                                  as RepairCode;

            Debug.Print(response == null ? "Failure!" : "Success!");

            return(response);
        }
Esempio n. 10
0
        public static int Execute(CorrigoService service, int woid)
        {
            var specifier = new EntitySpecifier
            {
                EntityType = EntityType.WorkOrder,
                Id         = woid
            };

            string[] properties = { nameof(WorkOrder.Estimate) + ".*" };
            var      workOrder  = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            }) as WorkOrder;

            var estimate = new WoEstimate
            {
                Id            = workOrder.Estimate?.Id ?? 0,
                ConcurrencyId = workOrder.Estimate?.ConcurrencyId ?? 0,
                Amount        = new MoneyValue {
                    Value = 10.1m, CurrencyTypeId = CurrencyType.USD
                },
                Comment     = "custom estimate 0",                                      //required
                ContactName = "Con 2 FN",                                               //required
                Reason      = "some custom reason",                                     //required
                StatusId    = QuoteStatus.WaitingForApproval,                           //required
            };

            workOrder.Estimate = estimate;

            var command = new UpdateCommand
            {
                Entity      = workOrder,
                PropertySet = new PropertySet {
                    Properties = properties
                }
            };

            var response   = service.Execute(command) as OperationCommandResponse;
            var estimateId = response?.NestedEntitiesOperationResults?[0]?.EntitySpecifier?.Id ?? 0;

            Debug.Print(response?.ErrorInfo?.Description
                        ?? $"Successfully created an Estimate with id '{estimateId}' for WO with id '{woid}'");

            return(estimateId);
        }
Esempio n. 11
0
        public static WoEstimate Retrieve(CorrigoService service, int estimateId)
        {
            Debug.Print($"Retrieving WoEstimate with id '{estimateId}'");

            var specifier = new EntitySpecifier {
                EntityType = EntityType.WoEstimate, Id = estimateId
            };

            string[] properties =
            {
                "Id",     "ConcurrencyId",
                "Amount", "Comment",      "ContactName","Reason", "StatusId",
            };
            var response = service.Retrieve(specifier, new PropertySet {
                Properties = properties
            })
                           as WoEstimate;

            Debug.Print(response == null ? "Failure!" : "Success!");
            return(response);
        }
Esempio n. 12
0
        public static WoNote Retrieve(CorrigoService service, int noteId)
        {
            var entitySpecifier = new EntitySpecifier {
                EntityType = EntityType.WoNote, Id = noteId
            };

            var propertySet = new PropertySet
            {
                Properties = new[]
                {
                    nameof(WoNote.Id),
                    nameof(WoNote.Body),
                    nameof(WoNote.CreatedDate),
                    //nameof(WoNote.PerformDeletion),
                    nameof(WoNote.NoteTypeId),
                    nameof(WoNote.WorkOrderId),
                    nameof(WoNote.CreatedBy) + ".*"
                }
            };

            var note = service.Retrieve(entitySpecifier, propertySet) as WoNote;

            return(note);
        }