public static void AddShare(int taskId, string objectId, string displayName) { //Share a task with a user or group GroupClaimContext db = new GroupClaimContext(); AadObject aadObject = db.AadObjects.Find(objectId); if (aadObject != null) { aadObject.DisplayName = displayName; } else { aadObject = new AadObject { AadObjectID = objectId, DisplayName = displayName, }; } Task task = db.Tasks.Find(taskId); List <AadObject> shares = task.SharedWith.ToList(); shares.Add(aadObject); task.SharedWith = shares; db.SaveChanges(); }
public static void AddTask(string taskText, string userObjectId, string userName) { // Add a new task to the db GroupClaimContext db = new GroupClaimContext(); Task newTask = new Task { Status = "NotStarted", TaskText = taskText, Creator = userObjectId, SharedWith = new List<AadObject>(), CreatorName = userName, }; // Get the AadObject representing from the user if it exists AadObject user = db.AadObjects.Find(userObjectId); if (user != null) { // Update the user's display name in case it has changed user.DisplayName = userName; } else { user = new AadObject { AadObjectID = userObjectId, DisplayName = userName, }; } newTask.SharedWith.Add(user); db.Tasks.Add(newTask); db.SaveChanges(); }
public static void AddTask(string taskText, string userObjectId, string userName) { // Add a new task to the db GroupClaimContext db = new GroupClaimContext(); Task newTask = new Task { Status = "NotStarted", TaskText = taskText, Creator = userObjectId, SharedWith = new List <AadObject>(), CreatorName = userName, }; // Get the AadObject representing from the user if it exists AadObject user = db.AadObjects.Find(userObjectId); if (user != null) { // Update the user's display name in case it has changed user.DisplayName = userName; } else { user = new AadObject { AadObjectID = userObjectId, DisplayName = userName, }; } newTask.SharedWith.Add(user); db.Tasks.Add(newTask); db.SaveChanges(); }
public static void DeleteTask(int taskId) { //Delete a task in the db GroupClaimContext db = new GroupClaimContext(); Task task = db.Tasks.Find(taskId); db.Tasks.Remove(task); db.SaveChanges(); }
public static void DeleteTask(int taskId) { //Delete a task in the db GroupClaimContext db = new GroupClaimContext(); Task task = db.Tasks.Find(taskId); db.Tasks.Remove(task); db.SaveChanges(); }
public static void UpdateTask(int taskId, string status) { // Update an existing task in the db GroupClaimContext db = new GroupClaimContext(); Task task = db.Tasks.Find(taskId); var captureSharedWith = task.SharedWith; if (task == null) throw new Exception("Task Not Found in DB"); task.Status = status; db.SaveChanges(); }
public static void UpdateTask(int taskId, string status) { // Update an existing task in the db GroupClaimContext db = new GroupClaimContext(); Task task = db.Tasks.Find(taskId); var captureSharedWith = task.SharedWith; if (task == null) { throw new Exception("Task Not Found in DB"); } task.Status = status; db.SaveChanges(); }
public static void DeleteShare(int taskId, string objectId) { // Remove access to a task for a user or group GroupClaimContext db = new GroupClaimContext(); Task task = db.Tasks.Find(taskId); List <AadObject> shares = task.SharedWith.ToList(); List <AadObject> aadObjects = shares.Where(a => a.AadObjectID.Equals(objectId)).ToList(); if (aadObjects.Count > 0) { shares.Remove(aadObjects.First()); } task.SharedWith = shares; db.SaveChanges(); }
public static void AddShare(int taskId, string objectId, string displayName) { //Share a task with a user or group GroupClaimContext db = new GroupClaimContext(); AadObject aadObject = db.AadObjects.Find(objectId); if (aadObject != null) { aadObject.DisplayName = displayName; } else { aadObject = new AadObject { AadObjectID = objectId, DisplayName = displayName, }; } Task task = db.Tasks.Find(taskId); List<AadObject> shares = task.SharedWith.ToList(); shares.Add(aadObject); task.SharedWith = shares; db.SaveChanges(); }
public static void DeleteShare(int taskId, string objectId) { // Remove access to a task for a user or group GroupClaimContext db = new GroupClaimContext(); Task task = db.Tasks.Find(taskId); List<AadObject> shares = task.SharedWith.ToList(); List<AadObject> aadObjects = shares.Where(a => a.AadObjectID.Equals(objectId)).ToList(); if (aadObjects.Count > 0) shares.Remove(aadObjects.First()); task.SharedWith = shares; db.SaveChanges(); }