public static WoPriority Retrieve(CorrigoService service, int id) { Console.WriteLine($"Retrieve WoPriority with id={id.ToString()}"); CorrigoEntity result = null; try { result = service.Retrieve( new EntitySpecifier { EntityType = EntityType.WoPriority, Id = id }, new PropertySet { Properties = new string[] { "Id", "DisplayAs", "IsEmergency", "RespondInMinutes", "DueInMinutes", "AcknowledgeInMinutes" } } //new AllProperties() ); } catch (Exception e) { if (!String.IsNullOrEmpty(e.Message)) { Console.WriteLine(e.Message); } } if (result == null) { Console.WriteLine("Retrieve failed"); return(null); } WoPriority toReturn = result as WoPriority; if (toReturn == null) { Console.WriteLine("Retrieve failed"); return(null); } Console.WriteLine(String.Concat("WoPriority.Id=".PadRight(30), toReturn.Id.ToString())); Console.WriteLine(String.Concat("WoPriority.DisplayAs=".PadRight(30), String.IsNullOrEmpty(toReturn.DisplayAs) ? "" : toReturn.DisplayAs)); Console.WriteLine(String.Concat("WoPriority.IsEmergency=".PadRight(30), toReturn.IsEmergency.ToString(), " //Escalate")); Console.WriteLine(String.Concat("WoPriority.RespondInMinutes =".PadRight(30), toReturn.RespondInMinutes.ToString(), " //Response minutes.")); Console.WriteLine(String.Concat("WoPriority.DueInMinutes=".PadRight(30), toReturn.DueInMinutes.ToString(), " //Complete minutes.")); Console.WriteLine(String.Concat("WoPriority.AcknowledgeInMinutes=".PadRight(30), toReturn.AcknowledgeInMinutes.ToString(), " //Complete minutes.")); Console.WriteLine(); return(toReturn); }
public static void Execute(CorrigoService service, WoPriority toUpdate) { if (toUpdate == null || service == null) { return; } toUpdate.DisplayAs = "-"; //Label toUpdate.DueInMinutes = 3; //Complete mins. toUpdate.IsEmergency = true; //Escalate toUpdate.RespondInMinutes = 5; //Responce mins. Console.WriteLine($"Update WoPriority with id={toUpdate.Id.ToString()}"); var resultUpdate = service.Execute(new UpdateCommand { Entity = toUpdate, PropertySet = new PropertySet { Properties = new[] { "DisplayAs", "IsEmergency", "RespondInMinutes", "DueInMinutes" } } }); if (resultUpdate == null) { Console.WriteLine("Update of WoPriority failed"); return; } if (resultUpdate.ErrorInfo != null && !string.IsNullOrEmpty(resultUpdate.ErrorInfo.Description)) { Console.WriteLine(resultUpdate.ErrorInfo.Description); Console.WriteLine("Update of WoPriority failed"); return; } Console.WriteLine("WoPriority is updated"); }
public static void CRUDExample(CorrigoService service, bool isCreateUpdateDelete = false) { if (service == null) { return; } WoPriority prio = isCreateUpdateDelete? Create.Execute(service) : null; if (prio != null) { Read.Retrieve(service, prio.Id); Update.Execute(service, prio); Read.Retrieve(service, prio.Id); Delete.Execute(service, prio.Id); } Read.RetrieveMultiple(service); Read.RetrieveByQuery(service); }