Ejemplo n.º 1
0
 public static async Task InsertItemAsync(ReasonValue item)
 {
     using (var clientContext = await(AuthenticationHelper.GetSharePointClientContextAsync(Permissions.Application)))
     {
         var list = clientContext.Web.Lists.GetByTitle(SPLists.ReasonValues.Title);;
         ListItemCreationInformation newItem = new ListItemCreationInformation();
         ListItem listItem = list.AddItem(new ListItemCreationInformation());
         listItem[SPLists.ReasonValues.Columns.Reason] = SharePointHelper.BuildSingleLookFieldValue(item.Reason.Id, item.Reason.Name);
         listItem[SPLists.ReasonValues.Columns.Date]   = item.InputDate;
         listItem[SPLists.ReasonValues.Columns.Value]  = item.Value;
         listItem.Update();
         clientContext.Load(listItem);
         clientContext.ExecuteQuery();
         item.Id = listItem.Id;
     }
 }
Ejemplo n.º 2
0
 public static async Task <Metric> InsertItemAsync(Metric item)
 {
     using (var clientContext = await(AuthenticationHelper.GetSharePointClientContextAsync(Permissions.Application)))
     {
         var      list     = clientContext.Web.Lists.GetByTitle(SPLists.Metrics.Title);
         ListItem listItem = list.AddItem(new ListItemCreationInformation());
         listItem[SPLists.Metrics.Columns.Issue]      = SharePointHelper.BuildSingleLookFieldValue(item.Issue.Id, item.Issue.Name);
         listItem[SPLists.Metrics.Columns.Title]      = item.Name;
         listItem[SPLists.Metrics.Columns.State]      = 1;
         listItem[SPLists.Metrics.Columns.TargetGoal] = item.TargetGoal;
         listItem[SPLists.Metrics.Columns.ValueType]  = item.ValueType;
         listItem.Update();
         clientContext.Load(listItem);
         clientContext.ExecuteQuery();
         return(listItem.ToMetric());
     }
 }
Ejemplo n.º 3
0
 public static async Task InsertItemAsync(Reason item)
 {
     using (var clientContext = await(AuthenticationHelper.GetSharePointClientContextAsync(Permissions.Application)))
     {
         var      list     = clientContext.Web.Lists.GetByTitle(SPLists.Reasons.Title);
         ListItem listItem = list.AddItem(new ListItemCreationInformation());
         listItem[SPLists.Reasons.Columns.Metric]            = SharePointHelper.BuildSingleLookFieldValue(item.Metric.Id, item.Metric.Name);
         listItem[SPLists.Reasons.Columns.Title]             = item.Name;
         listItem[SPLists.Reasons.Columns.State]             = 1;
         listItem[SPLists.Reasons.Columns.ReasonTracking]    = item.ReasonTracking;
         listItem[SPLists.Reasons.Columns.ValueType]         = item.ValueType;
         listItem[SPLists.Reasons.Columns.TrackingFrequency] = Convert.ToString(item.TrackingFrequency);
         listItem.Update();
         clientContext.Load(listItem);
         clientContext.ExecuteQuery();
         item.Id = listItem.Id;
     }
 }
Ejemplo n.º 4
0
 public static async Task InsertItemAsync(Issue item)
 {
     using (var clientContext = await(AuthenticationHelper.GetSharePointClientContextAsync(Permissions.Application)))
     {
         var list = clientContext.Web.Lists.GetByTitle(SPLists.Issues.Title);
         ListItemCreationInformation newItem = new ListItemCreationInformation();
         ListItem listItem = list.AddItem(new ListItemCreationInformation());
         listItem[SPLists.Issues.Columns.Category]    = SharePointHelper.BuildSingleLookFieldValue(item.Category.Id, item.Category.Name);
         listItem[SPLists.Issues.Columns.Title]       = item.Name;
         listItem[SPLists.Issues.Columns.State]       = item.State;
         listItem[SPLists.Issues.Columns.IssueMetric] = item.Metric;
         listItem[SPLists.Issues.Columns.TargetGoal]  = item.TargetGoal;
         listItem[SPLists.Issues.Columns.TeamId]      = item.MSTeamId;
         listItem.Update();
         clientContext.Load(listItem);
         clientContext.ExecuteQuery();
         item.Id = listItem.Id;
     }
 }
Ejemplo n.º 5
0
 public static async Task <int> InsertItemAsync(Issue item)
 {
     using (var clientContext = await(AuthenticationHelper.GetSharePointClientContextAsync(Permissions.Application)))
     {
         User newUser = clientContext.Web.EnsureUser(item.Owner);
         clientContext.Load(newUser);
         clientContext.ExecuteQuery();
         FieldUserValue userValue = new FieldUserValue();
         userValue.LookupId = newUser.Id;
         var      list     = clientContext.Web.Lists.GetByTitle(SPLists.Issues.Title);
         ListItem listItem = list.AddItem(new ListItemCreationInformation());
         listItem[SPLists.Issues.Columns.Category] = SharePointHelper.BuildSingleLookFieldValue(item.Category.Id, item.Category.Name);
         listItem[SPLists.Issues.Columns.Title]    = item.Name;
         listItem[SPLists.Issues.Columns.State]    = item.State;
         listItem[SPLists.Issues.Columns.TeamId]   = item.MSTeamId;
         listItem[SPLists.Issues.Columns.Owner]    = userValue;
         listItem.Update();
         clientContext.Load(listItem);
         clientContext.ExecuteQuery();
         return(listItem.Id);
     }
 }
Ejemplo n.º 6
0
        public static async Task UpdateItemAsync(Issue item)
        {
            using (var clientContext = await(AuthenticationHelper.GetSharePointClientContextAsync(Permissions.Application)))
            {
                User newUser = clientContext.Web.EnsureUser(item.Owner);
                clientContext.Load(newUser);
                clientContext.ExecuteQuery();
                FieldUserValue userValue = new FieldUserValue();
                userValue.LookupId = newUser.Id;

                var query = new CamlQuery();
                query.ViewXml =
                    @"<View>
                        <Query>
                            <Where>
                                <Eq>
                                    <FieldRef Name='" + SPLists.Issues.Columns.ID + @"'/>
                                    <Value Type='int'>" + item.Id + @"</Value>
                                </Eq>
                            </Where>
                         </Query>
                    </View>";
                var items     = clientContext.GetItems(SPLists.Issues.Title, query);
                var queryItem = items.FirstOrDefault();
                if (queryItem == null)
                {
                    return;
                }
                queryItem[SPLists.Issues.Columns.Category] = SharePointHelper.BuildSingleLookFieldValue(item.Category.Id, item.Category.Name);
                queryItem[SPLists.Issues.Columns.Title]    = item.Name;
                queryItem[SPLists.Issues.Columns.State]    = item.State;
                queryItem[SPLists.Issues.Columns.Owner]    = userValue;
                queryItem.Update();
                clientContext.ExecuteQuery();
            }
        }