Example #1
0
        public int CreateTicket(string spaceName, Ticket ticket)
        {
            var children = ticket.Children.ToList();
            ticket.Number = _ticketNumber++;

            foreach (var t in children)
            {
                t.Id = CreateTicket(spaceName, t);
            }

            var url = String.Format("https://api.assembla.com/v1/spaces/{0}/tickets.json", spaceName);
            var jsonResponse = GetPostResponse(url, ticket.ToObject());
            ticket.Id = jsonResponse["id"].Value<int>();

            foreach (var child in children)
            {
                CreateAssociation(spaceName, ticket.Number, child.Id);
            }
            return ticket.Id;
        }
Example #2
0
 private static void SetProperties(XElement rootElement, Ticket ticket)
 {
     var properties = ticket.GetType().GetProperties();
     foreach (var prop in properties)
     {
         var attribute = prop.CustomAttributes.First(x => x.AttributeType == typeof (XmlElementAttribute));
         if (attribute != null)
         {
             var elementName = attribute.ConstructorArguments.First().Value as string;
             var element = rootElement.Element(elementName);
             if (element != null)
             {
                 var elementType = element.Attribute("type");
                 if(elementType != null && GetTypeFromName(elementType.Value) == prop.PropertyType)
                 {
                     if (prop.PropertyType == typeof (int))
                     {
                         prop.SetValue(ticket, Convert.ToInt32(element.Value));
                     }
                     else if (prop.PropertyType == typeof (bool))
                     {
                         prop.SetValue(ticket, Convert.ToBoolean(element.Value));
                     }
                     else if (prop.PropertyType == typeof (DateTime))
                     {
                         prop.SetValue(ticket, Convert.ToDateTime(element.Value));
                     }
                 }
                 else if(elementType == null && prop.PropertyType == typeof(string)){
                     prop.SetValue(ticket, element.Value);
                 }
                 else
                 {
                     throw new StrongTypingException(elementName);
                 }
             }
         }
     }
 }
Example #3
0
 public IEnumerable<TicketAssociation> GetAssociations(String spaceName, Ticket ticket)
 {
     var url = String.Format("https://api.assembla.com/v1/spaces/{0}/tickets/{1}/ticket_associations.json", spaceName, ticket.Number);
     var json = GetJArrayResponse(url);
     return json.ToObject<IEnumerable<TicketAssociation>>();
 }
Example #4
0
 private Ticket GetHierarhcy(IEnumerable<Ticket> flatList, Ticket ticket)
 {
     flatList = flatList.ToList();
     var children = flatList.Where(x => x.ParentId == ticket.Id).ToList();
     ticket.Children = children.Select(x => GetHierarhcy(flatList, x));
     return ticket;
 }
 private Ticket CreateTicket(Actor actor, Story story)
 {
     var ticket = new Ticket()
     {
         Description = story.GetNarrative(actor),
         Summary = story.Title,
         Children = story.Children.Select(x => CreateTicket(actor, x)),
         Actor = actor.Name
     };
     return ticket;
 }
Example #6
0
 public static Ticket FromElement(XElement element)
 {
     var ticket = new Ticket();
     SetProperties(element, ticket);
     return ticket;
 }