public void TestCardCoverage() { //This is to test to ensure the properties exist; this would not be used in practice var card = new Card() { Label = "" , Locked = false , Position = 1 , Required = false , Revision = 0 , Selectable = false , SequenceId = AssignmentUtils.ROOT_SEQUENCE_ID , Size = 1 , Subdued = false , TemplateId = "" , Updated = "" , UpdatedBy = SkyManager.IntegrationId }; card.SetDefaults(); Assert.NotNull(card.ToString()); Assert.NotNull(card.ToJson()); var cardNew = new CardNew().SetDefaults(); cardNew.Tags = new List <string>() { "tag1" }; cardNew.Voice = new List <string>() { "command" }; Assert.Single(cardNew.Voice); Assert.Single(cardNew.Tags); Assert.NotNull(cardNew.ToJson()); Assert.NotNull(cardNew.ToString()); var cardPatch = new CardPatch().SetDefaults(); Assert.NotNull(cardPatch.ToJson()); Assert.NotNull(cardPatch.ToString()); var cardUpdate = new CardUpdate().SetDefaults(); Assert.NotNull(cardUpdate.ToJson()); Assert.NotNull(cardUpdate.ToString()); }
static SequenceNew CreateSequence() { var sequence = new SequenceNew { Id = "sequence1", ViewMode = ViewMode.Native //This is the default view mode and will generally be used }; CardNew labelHelloCard = CreateLabelCard("Hello World"); labelHelloCard.Position = 1; labelHelloCard.Id = "card1"; //This could be a UUID -- as long as it's unique within the sequence, we're good //@skydocs.start(cards.tags) CardNew photoCaptureCard = CreatePhotoCaptureCard(); photoCaptureCard.Position = 2; photoCaptureCard.Id = "card2"; //We'll add a tag to the photo capture card so we can identify it when we handle the card updated event //An IMPORTANT NOTE is that any tags on this photo capture card will be added to any photos captured by this card, in the photo's metadata photoCaptureCard.Tags = new System.Collections.Generic.List <string> { PHOTO_CAPTURE_TAG }; CardNew markCompleteCard = CreateMarkCompleteCard(); markCompleteCard.Position = 3; markCompleteCard.Id = "card3"; //We'll add a tag to the mark complete card so we can look for it later when we handle the event markCompleteCard.Tags = new System.Collections.Generic.List <string> { MARK_COMPLETE_TAG }; //@skydocs.end() //Set the cards to live in the sequence. We could create more cards and add them in a similar manner sequence.Cards = new System.Collections.Generic.List <CardNew> { labelHelloCard , photoCaptureCard , markCompleteCard }; return(sequence); }
public void Post([FromBody] CardNew cu) { FinanceEntities db = new FinanceEntities(); CardDetail c = new CardDetail(); Random rd = new Random(); int rno = rd.Next(000000, 999999); c.CustomerID = (from a in db.Users where a.Username == cu.Username select a.CustomerID).FirstOrDefault(); c.CardID = "EMI" + rno; c.Validity = cu.Validity; c.CardType = cu.CardType; c.ActivationStatus = cu.ActivationStatus; c.TotalCredit = cu.TotalCredit; c.RemainingCredit = cu.RemainingCredit; c.EMIPendingStatus = cu.EmiPendingStatus; db.CardDetails.Add(c); db.SaveChanges(); }
static async Task CreateBulkAssignment() { //@skydocs.start(assignments.bulkcreate) //Retrieve the user to whom we'd like to assign this assignment var assignUser = await GetUserIdForUsername(TEST_ACCOUNT_USERNAME); if (assignUser == null) { Console.Error.WriteLine("User does not exist for bulk assignment creation"); return; } //Create the assignment body var assignment = new AssignmentNew { AssignedTo = assignUser, Description = "This is an assignment created by the SDK example.", IntegrationId = SkyManager.IntegrationId, Name = ASSIGNMENT_NAME }; //Create a sequence -- theoretically, this would be better placed in another function //We have placed this inline within this function for clarity in this example var sequenceOne = new SequenceNew { Id = ROOT_SEQUENCE_ID, ViewMode = ViewMode.Native //This is the default view mode and will generally be used }; //Create a card for sequence1 var sequenceOneCardOne = new CardNew { Footer = "Select to create a card that points to a new sequence", Id = CREATE_CARD_ID, //As long as the ID is unique within the sequence, we're good to go Label = "Append Card", Position = 1, //Position of cards is 1-indexed Size = 2, //Size can be 1, 2, or 3 and determines how much of the screen a card takes up (3 being fullscreen) Layout = new LayoutText(), Selectable = true, Component = new ComponentCompletion() { Done = new DoneOnSelect() } }; //Set the card to live in sequence1. We could create more cards and add them in a similar manner sequenceOne.Cards = new System.Collections.Generic.List <CardNew> { sequenceOneCardOne }; //Add the sequence to the assignment assignment.Sequences = new System.Collections.Generic.List <SequenceNew> { sequenceOne }; //Set the sequence to be the root sequence. This is especially important if we have more than one sequence assignment.RootSequence = sequenceOne.Id; //Create the request for the assignment creation API var request = new Skylight.Api.Assignments.V1.AssignmentRequests.CreateAssignmentRequest(assignment); //Now, the magic happens -- we make a single API call to create this assignment, sequences/cards and all. var result = await SkyManager.ApiClient.ExecuteRequestAsync(request); //Handle the resulting status code appropriately switch (result.StatusCode) { case System.Net.HttpStatusCode.Forbidden: Console.Error.WriteLine("Error creating assignment: Permission forbidden."); break; case System.Net.HttpStatusCode.Unauthorized: Console.Error.WriteLine("Error creating assignment: Method call was unauthenticated."); break; case System.Net.HttpStatusCode.Created: Console.WriteLine("Assignment successfully created."); break; default: Console.Error.WriteLine("Unhandled assignment creation status code: " + result.StatusCode); break; } //@skydocs.end() }
static async Task CreateCardSequence(string assignmentId, string sequenceId) { var newSequenceId = "sequence" + numSequencesCreated; //@skydocs.start(sequences.create) var newSequence = new SequenceNew() { Id = newSequenceId }; var newSequenceCard = new CardNew() { Footer = "Select to delete this sequence", Id = DELETE_CARD_ID, //As long as the ID is unique within the sequence, we're good to go Label = "Delete Sequence", Position = 1, //Position of cards is 1-indexed Size = 2, //Size can be 1, 2, or 3 and determines how much of the screen a card takes up (3 being fullscreen) Layout = new LayoutText(), Selectable = true, Component = new ComponentCompletion() { Done = new DoneOnSelect() } }; newSequence.Cards = new System.Collections.Generic.List <CardNew> { newSequenceCard }; //Create our sequence var sequenceCreateResult = await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Assignments.V1.SequenceRequests.CreateSequenceRequest(newSequence, assignmentId)); //Handle the resulting status code appropriately switch (sequenceCreateResult.StatusCode) { case System.Net.HttpStatusCode.Forbidden: Console.Error.WriteLine("Error creating sequence: Permission forbidden."); throw new Exception("Error creating sequence."); case System.Net.HttpStatusCode.Unauthorized: Console.Error.WriteLine("Error creating sequence: Method call was unauthenticated."); throw new Exception("Error creating sequence."); case System.Net.HttpStatusCode.NotFound: Console.Error.WriteLine("Error creating sequence: Assignment not found."); throw new Exception("Error creating sequence."); case System.Net.HttpStatusCode.Created: Console.WriteLine("Successfully created sequence."); break; default: Console.Error.WriteLine("Unhandled sequence creation status code: " + sequenceCreateResult.StatusCode); throw new Exception("Error creating sequence."); } //@skydocs.end() //Get our current sequence's cards information so we can add a new card to it var sequenceInfoRequest = await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Assignments.V1.CardRequests.GetSequenceCardsRequest(assignmentId, sequenceId)); //Handle the resulting status code appropriately switch (sequenceInfoRequest.StatusCode) { case System.Net.HttpStatusCode.Forbidden: Console.Error.WriteLine("Error retrieving sequence: Permission forbidden."); throw new Exception("Error creating sequence."); case System.Net.HttpStatusCode.Unauthorized: Console.Error.WriteLine("Error retrieving sequence: Method call was unauthenticated."); throw new Exception("Error retrieving sequence."); case System.Net.HttpStatusCode.NotFound: Console.Error.WriteLine("Error retrieving sequence: Assignment or sequence not found."); throw new Exception("Error retrieving sequence."); case System.Net.HttpStatusCode.OK: Console.WriteLine("Successfully retrieved sequence."); break; default: Console.Error.WriteLine("Unhandled sequence retrieval status code: " + sequenceInfoRequest.StatusCode); throw new Exception("Error retrieving sequence."); } var numCardsInSequence = sequenceInfoRequest.Content.Count; //@skydocs.start(cards.create) var openSequenceCard = new CardNew() { Footer = "Enter " + newSequenceId, Id = "card" + numSequencesCreated, //As long as the ID is unique within the sequence, we're good to go Label = "Sequence " + numSequencesCreated, Position = numCardsInSequence + 1, //Position of cards is 1-indexed Size = 1, //Size can be 1, 2, or 3 and determines how much of the screen a card takes up (3 being fullscreen) Layout = new LayoutText(), Selectable = true, Component = new ComponentOpenSequence() { SequenceId = newSequenceId } }; var cardCreateResult = await SkyManager.ApiClient.ExecuteRequestAsync(new Skylight.Api.Assignments.V1.CardRequests.CreateCardsRequest(new System.Collections.Generic.List <CardNew> { openSequenceCard }, assignmentId, ROOT_SEQUENCE_ID)); //Handle the resulting status code appropriately switch (cardCreateResult.StatusCode) { case System.Net.HttpStatusCode.Forbidden: Console.Error.WriteLine("Error creating card: Permission forbidden."); throw new Exception("Error creating card."); case System.Net.HttpStatusCode.Unauthorized: Console.Error.WriteLine("Error creating card: Method call was unauthenticated."); throw new Exception("Error creating card."); case System.Net.HttpStatusCode.NotFound: Console.Error.WriteLine("Error creating card: Assignment or sequence not found."); throw new Exception("Error creating card."); case System.Net.HttpStatusCode.Created: Console.WriteLine("Successfully created card."); break; default: Console.Error.WriteLine("Unhandled card creation status code: " + cardCreateResult.StatusCode); throw new Exception("Error creating card."); } //@skydocs.end() //Increment how many sequences we've created numSequencesCreated += 1; }