public void PostAttachment(Stream fileContents)
        {
            try
            {
                var multipartParser = new MultipartParser(fileContents);
                var jsonContent = multipartParser.Contents.First(m => m.PropertyName == "jsonData");
                if (jsonContent == null) throw new Exception("jsonData parameter must be populated.");
                var json = jsonContent.StringData
                    .Replace("/r", string.Empty)
                    .Replace("/n", string.Empty)
                    .Trim();
                var javaScriptSerializer = new JavaScriptSerializer();
                var relaxWorkItemAttachment = javaScriptSerializer.Deserialize<RelaxWorkItemAttachment>(json);
                relaxWorkItemAttachment.Attachment = multipartParser.FileContents;

                var repository = new WorkItemRepository(relaxWorkItemAttachment);
                repository.Update(relaxWorkItemAttachment);
            }
            catch (Exception e)
            {
                _eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
            }
        }
        public ICollection<RelaxWorkItem> GetWorkItemsByPage(RelaxWorkItemType baseEntity, string page, string pageSize)
        {
            ICollection<RelaxWorkItem> workItems = new List<RelaxWorkItem>();

            try
            {
                int pg;
                int pgSize;

                int.TryParse(page, out pg);
                int.TryParse(pageSize, out pgSize);

                var repository = new WorkItemRepository(baseEntity);
                if (pg != 0 && pgSize != 0)
                    workItems = repository.GetWorkItems(baseEntity.TfsTeamProject, baseEntity.Name, pg, pgSize);
                else
                    workItems = repository.GetWorkItems(baseEntity.TfsTeamProject, baseEntity.Name, 1, 6);
            }
            catch (Exception e)
            {
                _eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
                return null;
            }
            return workItems;
        }
 public ICollection<RelaxWorkItemType> GetWorkItemTypes(RelaxTeamProject baseEntity)
 {
     var repository = new WorkItemRepository(baseEntity);
     return repository.GetWorkItemTypes(baseEntity.TfsTeamProject);
 }
        public ICollection<RelaxWorkItem> GetWorkItems(RelaxWorkItemType baseEntity)
        {
            ICollection<RelaxWorkItem> workItems = new List<RelaxWorkItem>();

            try
            {

                var repository = new WorkItemRepository(baseEntity);

                workItems = repository.GetWorkItems(baseEntity.TfsTeamProject, baseEntity.Name);
            }
            catch (Exception e)
            {
                _eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
                return null;
            }
            return workItems;
        }