protected void btnDeleteDelegation_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e) { int delegationID = int.Parse(e.CommandArgument.ToString()); InitializeWebAppProperties(); if (siteURLForDelegationsList != null) { using (SPSite delegationSite = new SPSite(siteURLForDelegationsList)) { DelegationsDataContext dc = new DelegationsDataContext(delegationSite.RootWeb.Url); EntityList<Delegation> delegations = dc.GetList<Delegation>("Delegations"); Delegation selectedDelegation = delegations.Where(d => d.Id == delegationID).FirstOrDefault(); delegations.DeleteOnSubmit(selectedDelegation); dc.SubmitChanges(); } } LoadDelegations(); }
void btnSubmit_Click(object sender, EventArgs e) { InitializeWebAppProperties(); if (siteURLForDelegationsList != null) { using (SPSite delegationSite = new SPSite(siteURLForDelegationsList)) { DelegationsDataContext dc = new DelegationsDataContext(delegationSite.RootWeb.Url); EntityList<Delegation> delegations = dc.GetList<Delegation>("Delegations"); string[] userValues = spPeoplePicker.CommaSeparatedAccounts.Split(','); SPUser assignedToUser = SPContext.Current.Web.EnsureUser(userValues[0]); Delegation delegation; if (string.IsNullOrEmpty(delegationID.Value)) { delegation = new Delegation() { DelegationFor = SPContext.Current.Web.CurrentUser.LoginName, DelegationForId = SPContext.Current.Web.CurrentUser.ID, StartDate = calDelegateFrom.SelectedDate, EndDate = calDelegateTo.SelectedDate, AssignedTo = assignedToUser.LoginName, AssignedToId = assignedToUser.ID, DelegationType = DelegationType.Self }; delegations.InsertOnSubmit(delegation); } else { delegation = delegations.Where(d => d.Id == int.Parse(delegationID.Value)).FirstOrDefault(); if (delegation != null) { delegation.StartDate = calDelegateFrom.SelectedDate; delegation.EndDate = calDelegateTo.SelectedDate; delegation.AssignedTo = assignedToUser.LoginName; delegation.AssignedToId = assignedToUser.ID; delegation.DelegationType = DelegationType.Self; } } dc.SubmitChanges(); } } //Reload the delegations LoadDelegations(); ResetNewDelegationPanel(); }
void btnSubmit_Click(object sender, EventArgs e) { string siteURLForDelegationsList = Utility.GetDelegationsListSite(); if (siteURLForDelegationsList != null) { using (SPSite delegationSite = new SPSite(siteURLForDelegationsList)) { DelegationsDataContext dc = new DelegationsDataContext(delegationSite.RootWeb.Url); EntityList<Delegation> delegations = dc.GetList<Delegation>("Delegations"); string selectedUser = ddlSubordinates.SelectedValue; SPUser assignedToUser = SPContext.Current.Web.EnsureUser(selectedUser); Delegation delegation = new Delegation() { DelegationFor = SPContext.Current.Web.CurrentUser.LoginName, DelegationForId = SPContext.Current.Web.CurrentUser.ID, StartDate = calDelegateFrom.SelectedDate, EndDate = calDelegateTo.SelectedDate, AssignedTo = assignedToUser.LoginName, AssignedToId = assignedToUser.ID, DelegationType = DelegationType.Self }; delegations.InsertOnSubmit(delegation); dc.SubmitChanges(); } } //Set value for message }